Monday, April 18, 2011

XML Feature Pack Tech Preview Available

Just in time for IBM Impact, the IBM XML team cranked out an updated tech preview of the XML Feature Pack with three key new features.

First - XQuery modules is a way to break up larger XQuery based programs into modular units. This was the last optional feature of XQuery not yet supported and rounds out the XQuery 1.0 support. Not only does this feature help you break up your own XQuery programs, but it also allows you to use open source XQuery libraries such as FunctX.

Next is support for easier to bind Java functions. In previous releases you could binding to existing Java logic and data, but now binding to existing Java logic is even easier. The support is common across both XSLT 2.0 and XQuery and supports invocation of both instance and static methods. Here is an example that I showed at Impact:


package org.company;

public class Calculator {
public static int sqrt(int val) {
return (int)Math.sqrt(val);
}
}



<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xltxe="http://www.ibm.com/xmlns/prod/xltxe-j"
xmlns:calc="http://com.example/myApp/calculator">

<xltxe:java-extension prefix="calc“ class="org.company.Calculator"/>

<xsl:template match="/">
<xsl:value-of select=“calc:sqrt(64) "/>
</xsl:template>

</xsl:stylesheet>


You can see in the XSLT that using our extention, we were able to map any functions starting with calc to Java calls to org.company.Calculator. Specifically the function sqrt was called in this example. With this support, no Java code is needed to link existing Java logic to an XSLT or XQuery program.

Finally, we spent alot of time on runtime error messages. We have made sure that error messages now include line and column numbers that help you track back to the error that caused execution to fail.

You can read more about these features on developerWorks and download the tech preview from the IBM download site.

0 comments: