How to use Xalan in Oxygen 7.1?

Here should go questions about transforming XML with XSLT and FOP.
rrliu
Posts: 37
Joined: Sun Feb 12, 2006 10:34 pm

How to use Xalan in Oxygen 7.1?

Post by rrliu » Thu Mar 09, 2006 12:36 pm

When I configure a transformation scenario to use Oxygen 7.1's Xalan I get a java.lang.NullPointerException. I hesitate to include here my XML and XSLT because it's pretty voluminous.

The transformation works as expect with Saxon 6.5.5. Here are the aspects of the transformation that might be significant:

(1) The XML uses a DTD to set default values of some attributes and validates against a W3C XML Schema schema.

(2) The XSLT uses an extension function, nodeset.

(3) The XSLT uses a DTD to define entities used in the templates.

Can anybody spot gross oversights on my part. It must be something fairly obvious, because the transformation fails almost immediately.

Thanks,
Richard

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Thu Mar 09, 2006 1:28 pm

Hi Richard,

The problem is probably caused by the use of the node-set extension, if you use the Saxon node-set like below for instance:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:saxon="http://icl.com/saxon">
<xsl:template match="/*">
<xsl:variable name="test">
<xsl:copy-of select="."/>
</xsl:variable>
<xsl:variable name="copy" select="saxon:node-set($test)"/>
<xsl:copy-of select="$copy"/>
</xsl:template>
</xsl:stylesheet>
You should use the EXSLT node-set extension instead as it is implemented also by Xalan:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:exslt="http://exslt.org/common">
<xsl:template match="/*">
<xsl:variable name="test">
<xsl:copy-of select="."/>
</xsl:variable>
<xsl:variable name="copy" select="exslt:node-set($test)"/>
<xsl:copy-of select="$copy"/>
</xsl:template>
</xsl:stylesheet>
Let us know if that was indeed the case.

Best Regards,
George

rrliu
Posts: 37
Joined: Sun Feb 12, 2006 10:34 pm

Post by rrliu » Fri Mar 10, 2006 2:36 am

George,

Thanks for your as ever prompt reply. Regarding node-set I have the following in my XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wbr="http://www.ubs.com/namespaces/wbml-render" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:xalan="http://xml.apache.org/xalan" xmlns:libxslt="http://xmlsoft.org/XSLT/namespace" xmlns:com="http://exslt.org/common" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="wbr msxml xalan libxslt com svg xlink">
...
<xsl:variable name="_xsltengine">
<xsl:choose>
<xsl:when test="function-available('xalan:nodeset')">xalan</xsl:when>
<xsl:when test="function-available('libxslt:node-set')">libxslt</xsl:when>
<xsl:when test="function-available('com:node-set')">com</xsl:when>
<xsl:when test="function-available('msxml:node-set')">msxml</xsl:when>
<xsl:otherwise>
No node-set or nodeset extension function while setting t.
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

Whenever I use node-set (or nodeset) I do that in a xsl:choose that tests $_xsltengine. I even tried moving the third xsl:when, which checks for the exslt library, to the first position in the xsl:choose, but the null pointer exception was still raised. In fact, by examing the value of $_xsltengine I see that Saxon 6.5.5, which is the default XSLT transformer, is using the exslt library.

Regards,
Richard

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Fri Mar 10, 2006 12:55 pm

Hi Richard,

Saxon, Xalan and XSLTProc should all work with the exslt node-set extension as in the example I posted above. It will help if you can get a cut down version of a stylesheet that shows the problem and send it to us.

Best Regards,
George

Post Reply