[xsl] Xalan giving TransformerException for a defined variable

Subject: [xsl] Xalan giving TransformerException for a defined variable
From: "Brian J. Coan" <brianc@xxxxxxxxxxxxxx>
Date: Thu, 30 Sep 2004 12:01:08 -0700
I'm working with ATG Dynamo application server, attempting
to upgrade from a version that used a very old, pre- 1.0 certified
XSL parser, "LotusXSL Version 0.18.4, XML4J Version XML4J 2.0.15 ",
to a version that uses Xalan, "Xalan Version Xalan Java 2.4.1".

A stylesheet that worked with the Lotus parser blows up
when processed by Xalan, a NullPointerException when dealing
with a param variable. Has anyone seen this problem before,
or is this in some way illegal XSL the old parser allowed?

i'm attaching the stylesheet reduced down to the basics
that still blows up. if one removes the "$shippedOrder"
variable in the <xsl:sort> element, then the Xalan processor
will not blow up. also attaching the stacktrace.
Thanks for any help


------------- The XSL stylesheet ----------------- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >

<xsl:output method="xml" indent="yes"/>

<xsl:template match="ORDER_STATUS_DOCUMENT">
<xsl:element name="Shipments">
<xsl:apply-templates select="ORDER[ORDER_DETAIL/ITEM_STATUS/SHIP]"/>
</xsl:element>
</xsl:template>

<xsl:template match="ORDER">
<xsl:element name="Shipment">
<xsl:call-template name="generate_containers">
<xsl:with-param name="shippedOrder" select="."/>
</xsl:call-template>
</xsl:element>
</xsl:template>

<!-- key to generate a node-set of shipment elements that have a common
tracking number, hence should be in the same Container -->
<xsl:key name="container-group" match="//PACKAGE" use="TRACKING_NUMBER"/>

<!-- called from the /ORDER_STATUS_DOCUMENT/ORDER level -->
<xsl:template name="generate_containers">
<xsl:param name="shippedOrder"/>
<xsl:variable name="listoftrackingnumbers">
<xsl:for-each select=".//PACKAGE[generate-id(.) =
generate-id(key('container-group', TRACKING_NUMBER)[1])]">
<xsl:sort select="count($shippedOrder/ORDER_DETAIL[.//PACKAGE/TRACKING_NUMBER = current()/TRACKING_NUMBER])"
order="ascending" data-type="number"/>
<xsl:value-of select="concat(TRACKING_NUMBER, '~')"/>
</xsl:for-each>
</xsl:variable>
</xsl:template>


</xsl:stylesheet>
------------- END of The XSL stylesheet -----------------

------------- The EDUMP stacktrace -----------------
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: java.lang.NullPointerException
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1002)
at org.apache.xalan.xslt.Process.main(Process.java:769)
Caused by: javax.xml.transform.TransformerException: java.lang.NullPointerException
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:996)
... 1 more
Caused by: java.lang.NullPointerException
at org.apache.xpath.operations.Variable.getElemVariable(Variable.java:321)
at org.apache.xpath.operations.Variable.getAnalysisBits(Variable.java:380)
at org.apache.xpath.axes.FilterExprWalker.getAnalysisBits(FilterExprWalker.java:307)
at org.apache.xpath.axes.WalkingIterator.getAnalysisBits(WalkingIterator.java:76)
at org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:238)
at org.apache.xpath.functions.FunctionOneArg.fixupVariables(FunctionOneArg.java:158)
at org.apache.xpath.XPath.fixupVariables(XPath.java:114)
at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:384)
at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:173)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:356)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:336)
at org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:511)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:715)
at org.apache.xerces.impl.XMLNamespaceBinder.endDocument(XMLNamespaceBinder.java:704)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endDocument(XMLDTDValidator.java:985)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:437)
at org.apache.xerces.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1159)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3206)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(XMLEntityManager.java:2878)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(XMLDocumentScannerImpl.java:987)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:972)
... 1 more
---------
javax.xml.transform.TransformerException: java.lang.NullPointerException
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:996)
at org.apache.xalan.xslt.Process.main(Process.java:769)
Caused by: java.lang.NullPointerException
at org.apache.xpath.operations.Variable.getElemVariable(Variable.java:321)
at org.apache.xpath.operations.Variable.getAnalysisBits(Variable.java:380)
at org.apache.xpath.axes.FilterExprWalker.getAnalysisBits(FilterExprWalker.java:307)
at org.apache.xpath.axes.WalkingIterator.getAnalysisBits(WalkingIterator.java:76)
at org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:238)
at org.apache.xpath.functions.FunctionOneArg.fixupVariables(FunctionOneArg.java:158)
at org.apache.xpath.XPath.fixupVariables(XPath.java:114)
at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:384)
at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:173)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:356)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:336)
at org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:511)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:715)
at org.apache.xerces.impl.XMLNamespaceBinder.endDocument(XMLNamespaceBinder.java:704)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endDocument(XMLDTDValidator.java:985)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:437)
at org.apache.xerces.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1159)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3206)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(XMLEntityManager.java:2878)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(XMLDocumentScannerImpl.java:987)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:972)
... 1 more
---------
java.lang.NullPointerException
at org.apache.xpath.operations.Variable.getElemVariable(Variable.java:321)
at org.apache.xpath.operations.Variable.getAnalysisBits(Variable.java:380)
at org.apache.xpath.axes.FilterExprWalker.getAnalysisBits(FilterExprWalker.java:307)
at org.apache.xpath.axes.WalkingIterator.getAnalysisBits(WalkingIterator.java:76)
at org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:238)
at org.apache.xpath.functions.FunctionOneArg.fixupVariables(FunctionOneArg.java:158)
at org.apache.xpath.XPath.fixupVariables(XPath.java:114)
at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:384)
at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:173)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:356)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:336)
at org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:511)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:715)
at org.apache.xerces.impl.XMLNamespaceBinder.endDocument(XMLNamespaceBinder.java:704)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endDocument(XMLDTDValidator.java:985)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:437)
at org.apache.xerces.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1159)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3206)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(XMLEntityManager.java:2878)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(XMLDocumentScannerImpl.java:987)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:972)
at org.apache.xalan.xslt.Process.main(Process.java:769)
---------
java.lang.NullPointerException
at org.apache.xpath.operations.Variable.getElemVariable(Variable.java:321)
at org.apache.xpath.operations.Variable.getAnalysisBits(Variable.java:380)
at org.apache.xpath.axes.FilterExprWalker.getAnalysisBits(FilterExprWalker.java:307)
at org.apache.xpath.axes.WalkingIterator.getAnalysisBits(WalkingIterator.java:76)
at org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:238)
at org.apache.xpath.functions.FunctionOneArg.fixupVariables(FunctionOneArg.java:158)
at org.apache.xpath.XPath.fixupVariables(XPath.java:114)
at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:384)
at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:173)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:356)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:361)
at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:336)
at org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:511)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:715)
at org.apache.xerces.impl.XMLNamespaceBinder.endDocument(XMLNamespaceBinder.java:704)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endDocument(XMLDTDValidator.java:985)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:437)
at org.apache.xerces.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1159)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(XMLEntityManager.java:3206)
at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(XMLEntityManager.java:2878)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(XMLDocumentScannerImpl.java:987)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1148)
at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:972)
at org.apache.xalan.xslt.Process.main(Process.java:769)
------------- END of The EDUMP stacktrace -----------------


Current Thread