Random photo
Loading...
Domains for sale
|
August 1, 2005XML Enhances JavaIf you thought it's only Microsoft who's working on integrating XML into the core of programming languages, look at what IBM does for Java. This is a manstream trend now. XML Enhancements for Java are an emerging technology from IBM, which provides a set of language extensions that facilitate XML processing in Java. What are XML Enhancements for JavaTM? In XJ, one can import XML schemas just as one does Java classes. All the element declarations in the XML schema are then available to programmers as if they were Java classes. Programmers can write inline XPath expressions on these classes, and the compiler checks them for correctness with respect to the XML schema. In addition, the compiler performs optimizations in order to improve the evaluation of XPath expressions. A programmer may construct new XML documents by writing XML directly inline. Again, the compiler ensures correctness with respect to the appropriate schema. By integrating XML and Java, XJ allows programmers to reuse existing Java libraries in the development of XML code and vice-versa.Here are some samples of what XJ allows: XPath integration: int min = 70; Sequence<year> ys = sd[|/year[sum(.//sales) > $min]|];Inline XML construction: region r = new region(<region>
<name>NorthEast</name>
<sales unit='GBP'>75</sales>
</region>);
Dynamic one:
float conversion = 1.9;
salesdata s =
new salesdata(
<salesdata>
<year>
{y}
<sales unit='Dollars'>{grossSales * conversion}</sales>
{r}
</year>
</salesdata>);
And many more. Find XJ documentation here.
August 1, 2005 1:58 PM
| #XML
Comments
Apparently you cannot do that in XJ, becuase of a strong typing: "To construct untyped XML, that is, XML that is not to be validated with respect to any XML Schema, one can use the XML literal constructor defined for XMLElement: XMLElement a = new XMLElement(<theyear>1998</theyear>); where the argument to the constructor is any well-formed block of XML data. The type of the XML value constructed is XMLElement. The variable a cannot be assigned to the variable y declared above even though they are constructed from the same literal XML. The variable a is an instance of XMLElement, and the variable y is an instance of theyear, and an XMLElement may not be assigned to a theyear. " Posted by: Oleg Tkachenko at August 1, 2005 6:24 PMI was wondering, is there a new "xml" type as well, so that I could say this: XmlType xml = <region> region r = new region(xml); Posted by: ben at August 1, 2005 5:51 PMWhat language does this remind me of.... ??? Oh, I know... It's COmega watered down! ;) Still, pretty cool stuff for sure! Posted by: M. David Peterson at August 1, 2005 3:56 PMPost a comment
Listed below are links to weblogs that reference this post:
"Native XML Support in Java not worth it", Gosling says from Val's Blog
On the need for native XML support in Java from Val's Blog
Native XML Support in Java (Round 2) from Val's Blog |