NullPointerException thrown during comparison

Help
2010-09-22
2012-10-08
  • Benny Craig

    Benny Craig - 2010-09-22

    Hello Saxon Team,
    I have a reproducible error which i believe to be a bug in your new
    saxon9he.jar.
    The error is not thrown from an older version of saxon9.jar.
    I'm surprised to see no option to attach here, so I resort to pasting my code.
    Please advise and I would be happy to e-mail you a better-formed example.
    I have done my best to make a minimal example, but have added a lot of
    comments for various cases, to save you time.

    input (test.xml):

    <foo bar="1" />
    

    transformation (test.xsl):

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet xmlns:xsl="[url]http://www.w3.org/1999/XSL/Transform[/url]" version="1.1">
        <xsl:template match="/">
            <xsl:variable name="var">
                <xsl:call-template name="temp1">
                    <xsl:with-param name="para" select="foo[@bar='1']" />
    
                    <!--
                    this also fails (bad match):
                        <xsl:with-param name="para" select="foo[@bar='2']" />
                    this also fails (no names):
                        <xsl:with-param name="para" select="*[@*='1']" />
                    this does not fail (integer type right-operand):
                        <xsl:with-param name="para" select="foo[@bar=1]" />
                    these do not fail (name mismatch):
                        <xsl:with-param name="para" select="foos[@bar='1']" />
                        <xsl:with-param name="para" select="foo[@bars='1']" />
                    this does not fail (explicit pre-evaluate string(_))
                        <xsl:with-param name="para" select="foo[string(@bar)='1']" />
                    -->
                </xsl:call-template>
    
                <!--
                this does not fail (apply instead of call):
                    <xsl:apply-templates mode="temp2"><xsl:with-param name="para" select="foo[@bar='1']" /></xsl:apply-templates>
                -->
    
            </xsl:variable>
    
            <x>
                <xsl:value-of select="$var" />
    
                <!--
                this does not fail (copy instead of value):
                    <xsl:copy-of select="$var1" />
                this does not fail (text instead of fragment):
                    <xsl:value-of select="$var1/text()" />
                    (doesn't this violate the spec , since $var1 is a fragment and should not support the "/" operator?)
                -->
            </x>
        </xsl:template>
    
        <!-- the fragment this returns causes failures, when passed to string(_) -->
        <xsl:template name="temp1">
            <xsl:param name="para" />
    
            <xsl:text>stuff1</xsl:text>
            <!--
            this also fails (empty text node):
                <xsl:text />
            this also fails (several text nodes):
                <xsl:text>stuff1</xsl:text>free<xsl:text />
            this does not fail (no content at all):
    
            this does not fail (fragment containing element rather than text):
                <y>stuff1</y>
            these do not fail (text with non-text siblings):
                <xsl:text>stuff1</xsl:text><xsl:comment>mint</xsl:comment>
                <xsl:comment>mint</xsl:comment><xsl:text>stuff1</xsl:text>
            -->
        </xsl:template>
    
        <!-- the fragment this returns does not cause failures -->
        <xsl:template mode="temp2" match="node()">
            <xsl:param name="para" />
    
            <xsl:text>stuff2</xsl:text>
        </xsl:template>
    </xsl:stylesheet>
    

    When I apply the latter transform to the former input xml example, I receive
    the following error:
    Exception in thread "main" java.lang.NullPointerException
    at net.sf.saxon.expr.GeneralComparison10.compare(GeneralComparison10.java:324)
    at net.sf.saxon.expr.GeneralComparison10.effectiveBooleanValue(GeneralComparis
    on10.java:264)
    at
    net.sf.saxon.expr.FilterIterator$NonNumeric.matches(FilterIterator.java:182)
    at
    net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.java:65)
    at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:44)
    at net.sf.saxon.value.SequenceExtent.<init>(SequenceExtent.java:98)
    at
    net.sf.saxon.value.SequenceExtent.makeSequenceExtent(SequenceExtent.java:134)
    at net.sf.saxon.expr.ExpressionTool.evaluate(ExpressionTool.java:313)
    at
    net.sf.saxon.instruct.GeneralVariable.getSelectValue(GeneralVariable.java:378)
    at net.sf.saxon.instruct.Instruction.assembleParams(Instruction.java:147)
    at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:261)
    at net.sf.saxon.instruct.Instruction.iterate(Instruction.java:328)
    at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:180)
    at net.sf.saxon.expr.UntypedAtomicConverter.iterate(UntypedAtomicConverter.jav
    a:165)
    at net.sf.saxon.expr.ItemChecker.iterate(ItemChecker.java:132)
    at net.sf.saxon.functions.StringJoin.evaluateItem(StringJoin.java:48)
    at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:316)
    at net.sf.saxon.instruct.ValueOf.processLeavingTail(ValueOf.java:246)
    at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
    at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java
    :301)
    at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:229)
    at
    net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:354)
    at net.sf.saxon.Controller.transformDocument(Controller.java:1849)
    at net.sf.saxon.Controller.transform(Controller.java:1700)
    at test.Test.main(Test.java:13)

    Thank you guys (in particular Mr. Kay) for the poweful library and priceless
    forum contributions.
    Cheers,
    -Ben

     
  • Benny Craig

    Benny Craig - 2010-09-22

    Please pardon the extraneous semicolon in the opening element of the
    stylesheet, and also note the error persists using xsl version 1.0 as well.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks