NullPointerException thrown during comparison

  • 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
    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][/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']" />
                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: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?)
        <!-- the fragment this returns causes failures, when passed to string(_) -->
        <xsl:template name="temp1">
            <xsl:param name="para" />
            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):
            these do not fail (text with non-text siblings):
        <!-- the fragment this returns does not cause failures -->
        <xsl:template mode="temp2" match="node()">
            <xsl:param name="para" />

    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.effectiveBooleanValue(GeneralComparis
    at net.sf.saxon.value.SequenceExtent.<init>(
    at net.sf.saxon.expr.ExpressionTool.evaluate(
    at net.sf.saxon.instruct.Instruction.assembleParams(
    at net.sf.saxon.instruct.CallTemplate.process(
    at net.sf.saxon.instruct.Instruction.iterate(
    at net.sf.saxon.expr.Atomizer.iterate(
    at net.sf.saxon.expr.UntypedAtomicConverter.iterate(UntypedAtomicConverter.jav
    at net.sf.saxon.expr.ItemChecker.iterate(
    at net.sf.saxon.functions.StringJoin.evaluateItem(
    at net.sf.saxon.expr.CastExpression.evaluateItem(
    at net.sf.saxon.instruct.ValueOf.processLeavingTail(
    at net.sf.saxon.instruct.Instruction.process(
    at net.sf.saxon.instruct.ElementCreator.processLeavingTail(
    at net.sf.saxon.instruct.Template.applyLeavingTail(
    at net.sf.saxon.Controller.transformDocument(
    at net.sf.saxon.Controller.transform(
    at test.Test.main(

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

  • 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