Project

Profile

Help

Bug #1933

closed

NullPointerException when current() used in a pattern predicate

Added by Adrian Buza over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2013-11-06
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

When running this stylesheet (XML input is not relevant) with Saxon-EE 9.5.0.2 and later (also tested with 9.5.1.3)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:my="my"
    exclude-result-prefixes="xs my"
    version="2.0">
    
    <xsl:function name="my:test" as="xs:boolean">
        <xsl:param name="elt" as="node()" />
        <xsl:param name="ancestor-elt" as="element(*)" />
        <xsl:sequence select="true()"/>
    </xsl:function>
    
    <xsl:template match="A[B[my:test(., current())]]"/>
    

the result is the following stack trace (this is from 9.5.1.3):

        at net.sf.saxon.expr.UserFunctionCall.computeArgumentEvaluationModes(UserFunctionCall.java:346)
        at net.sf.saxon.expr.UserFunctionCall.replaceSubExpression(UserFunctionCall.java:371)
        at net.sf.saxon.pattern.Pattern.replaceCurrent(Pattern.java:83)
        at net.sf.saxon.pattern.Pattern.replaceCurrent(Pattern.java:85)
        at net.sf.saxon.pattern.PatternWithPredicate.bindCurrent(PatternWithPredicate.java:44)
        at net.sf.saxon.style.StyleElement.typeCheck(StyleElement.java:1257)
        at net.sf.saxon.style.XSLTemplate.validate(XSLTemplate.java:274)
        at net.sf.saxon.style.StyleElement.validateSubtree(StyleElement.java:1361)
        at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(PrincipalStylesheetModule.java:275)
        at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:378)
        at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:236)
        at net.sf.saxon.PreparedStylesheet.compile(PreparedStylesheet.java:114)
        at net.sf.saxon.Transform.doTransform(Transform.java:565)
        at net.sf.saxon.Transform.main(Transform.java:82)

Related issues

Related to Saxon - Bug #1942: Function current should have been resolved at compile timeClosedMichael Kay2013-12-02

Actions
Actions #1

Updated by Michael Kay over 10 years ago

  • Subject changed from NullPointerException during type check at stylesheet compile time to NullPointerException when current() used in a pattern predicate
  • Status changed from New to Resolved

The NullPointerException occurs during the static type-checking; the circumstances are a call to current() as an argument of a call to a user-defined function within a predicate of a match pattern. It occurs because when a call to a user-defined function is modified during tree-rewriting, the evaluation mode of each argument is re-assessed; but in this case the target function is not yet known.

A patch has been raised on the 9.5 branch. The test case has also been run on the 9.6 branch; the Saxon code in this case is significantly different because of changes to function binding for support of packages.

Actions #2

Updated by O'Neil Delpratt over 10 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.4

Bug fix applied in Saxon maintenance release 9.5.1.4

Please register to edit this issue

Also available in: Atom PDF