<xsl:sort select="..." xmlns:xs=http://www.w3.o
Posted: Wed Jul 05, 2006 2:21 pm
In Xalan <xsl:sort select="..." xmlns:xs=http://www.w3.org/1999/XSL/> seems to cause a NullPointerException.
In a template being called by name I have this:
<xsl:template name="makeSortedChoices">
...
<xsl:variable name="choices">
<choices xmlns="">
<xsl:for-each select="...">
<choice>
<originalvalue><xsl:value-of select="..."/><originalvalue>
<returnvalue>...</returnvalue>
<sortvalue>...</sortvalue>
<name>...</name>
<namelang>....</namelang>
</choice>
</for-each>
</choices>
</xsl:variable>
<choices xmlns="">
<xsl:for-each select="com:node-set($choices)/choices/choice>
<xsl:sort select="sortvalue" lang="{$sortLang}" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<choice xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<originalvalue><xsl:value-of select="originalvalue"/></originalvalue>
<returnvalue>...</returnvalue>
<sortvalue>...</sortvalue>
<name>...</name>
<namelang>...</namelang>
<index><xsl:value-of select="position() - 1"/></index>
</choice>
</xsl:for-each>
</choices>
</xsl:template>
I realize that associating the xsl: prefix with the XSL namespace for the elements inside the xsl:for-each is superfluous; however those elements are really "included" in the template using an unparsed entity. I seem to recall at least one parser which needed the namespaces to be defined in the entity.
Xalan throws a NPE when creating the transformer for this template. If I remove the namespace associate from the xsl:sort, however, then the NPE disappears, even though I retain it on the other elements.
Question: Is this a bug in Xalan, or is there some logical explanation? In Saxon retaining the namespace associations is not a problem.
Regards,
Richard
In a template being called by name I have this:
<xsl:template name="makeSortedChoices">
...
<xsl:variable name="choices">
<choices xmlns="">
<xsl:for-each select="...">
<choice>
<originalvalue><xsl:value-of select="..."/><originalvalue>
<returnvalue>...</returnvalue>
<sortvalue>...</sortvalue>
<name>...</name>
<namelang>....</namelang>
</choice>
</for-each>
</choices>
</xsl:variable>
<choices xmlns="">
<xsl:for-each select="com:node-set($choices)/choices/choice>
<xsl:sort select="sortvalue" lang="{$sortLang}" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<choice xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<originalvalue><xsl:value-of select="originalvalue"/></originalvalue>
<returnvalue>...</returnvalue>
<sortvalue>...</sortvalue>
<name>...</name>
<namelang>...</namelang>
<index><xsl:value-of select="position() - 1"/></index>
</choice>
</xsl:for-each>
</choices>
</xsl:template>
I realize that associating the xsl: prefix with the XSL namespace for the elements inside the xsl:for-each is superfluous; however those elements are really "included" in the template using an unparsed entity. I seem to recall at least one parser which needed the namespaces to be defined in the entity.
Xalan throws a NPE when creating the transformer for this template. If I remove the namespace associate from the xsl:sort, however, then the NPE disappears, even though I retain it on the other elements.
Question: Is this a bug in Xalan, or is there some logical explanation? In Saxon retaining the namespace associations is not a problem.
Regards,
Richard