You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/06/19 15:03:28 UTC

DO NOT REPLY [Bug 20908] New: - NullPointerException when sorting using a child of a variable.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20908>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20908

NullPointerException when sorting using a child of a variable.

           Summary: NullPointerException when sorting using a child of a
                    variable.
           Product: XalanJ2
           Version: 2.5
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Xalan
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: mstephenson@openworld.co.uk


It would seem that xalan 2.5.1 doesn't like doing anything of the form:

    <xsl:apply-templates select="people">
      <xsl:sort select="$request/parameter=name"/>
    </xsl:apply-templates>

ie. sorting a set of elements based on whether one of their children coincides
with a child of a variable.

Previous versions of xalan (2.4.1 and 2.1.0 are the only two I've tried) have
allowed this. 

It seems the easiest way to work around this is to reference the element
represented by the variable absolutely, ie in the example below replace
'$request' with 'request'.

Although the example below is demonstrated from the command line the problem is
not specific to it.

Thanks for you time!

mstephen@monkey:~$ /usr/local/java/jdk/bin/java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
mstephen@monkey:~$ cat broken.xsl 
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>

  <xsl:template match="/">

    <xsl:variable name="request" select="request"/>

    <xsl:apply-templates select="people">
      <xsl:sort select="$request/parameter=name"/>
    </xsl:apply-templates>

  </xsl:template>
</xsl:stylesheet>
mstephen@monkey:~$ /usr/local/java/jdk/bin/java org.apache.xalan.xslt.Process
-XSL broken.xsl -EDUMP

javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException: java.lang.NullPointerException
	at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:922)
	at org.apache.xalan.xslt.Process.main(Process.java:759)
---------
javax.xml.transform.TransformerException: java.lang.NullPointerException
	at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:916)
	at org.apache.xalan.xslt.Process.main(Process.java:759)
---------
java.lang.NullPointerException
	at org.apache.xpath.operations.Variable.getElemVariable(Variable.java:312)
	at org.apache.xpath.operations.Variable.getAnalysisBits(Variable.java:362)
	at
org.apache.xpath.axes.FilterExprWalker.getAnalysisBits(FilterExprWalker.java:305)
	at org.apache.xpath.axes.WalkingIterator.getAnalysisBits(WalkingIterator.java:129)
	at
org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:235)
	at org.apache.xpath.operations.Operation.fixupVariables(Operation.java:91)
	at org.apache.xpath.XPath.fixupVariables(XPath.java:111)
	at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:382)
	at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:157)
	at org.apache.xalan.templates.ElemCallTemplate.compose(ElemCallTemplate.java:150)
	at
org.apache.xalan.templates.ElemApplyTemplates.compose(ElemApplyTemplates.java:164)
	at
org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:358)
	at
org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:363)
	at
org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:363)
	at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:338)
	at
org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:479)
	at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
	at
org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown
Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:892)
	at org.apache.xalan.xslt.Process.main(Process.java:759)
---------
java.lang.NullPointerException
	at org.apache.xpath.operations.Variable.getElemVariable(Variable.java:312)
	at org.apache.xpath.operations.Variable.getAnalysisBits(Variable.java:362)
	at
org.apache.xpath.axes.FilterExprWalker.getAnalysisBits(FilterExprWalker.java:305)
	at org.apache.xpath.axes.WalkingIterator.getAnalysisBits(WalkingIterator.java:129)
	at
org.apache.xpath.axes.WalkingIteratorSorted.fixupVariables(WalkingIteratorSorted.java:235)
	at org.apache.xpath.operations.Operation.fixupVariables(Operation.java:91)
	at org.apache.xpath.XPath.fixupVariables(XPath.java:111)
	at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:382)
	at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:157)
	at org.apache.xalan.templates.ElemCallTemplate.compose(ElemCallTemplate.java:150)
	at
org.apache.xalan.templates.ElemApplyTemplates.compose(ElemApplyTemplates.java:164)
	at
org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:358)
	at
org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:363)
	at
org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:363)
	at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:338)
	at
org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:479)
	at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
	at
org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown
Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:892)
	at org.apache.xalan.xslt.Process.main(Process.java:759)