Bug #1933
closedNullPointerException when current() used in a pattern predicate
100%
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
Updated by Michael Kay about 11 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.
Updated by O'Neil Delpratt almost 11 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