Bug #3212
closed
NullPointerException evaluating if (A = B to C)
Category:
XPath conformance
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:
Description
A stylesheet contains the logic
<xsl:variable name="range" select="f:eval(@a) to f:eval(@b)"/>
<xsl:if test="f:eval(X) = $range">...</xsl:if>
Saxon successfully identifies the opportunity to turn this into an IntegerRangeTest (A = B to C) which is evaluated essentially as (A>=B and A<=C).
However, it seems that the optimized code fails to take account of the fact that f:eval() is capable of returning an empty sequence, in which case the boolean expression should evaluate to false.
This code has been in the product for a long time!
Reproduced by this simple test case (added to W3C as math-0107)
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="http://local.functions/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all">
<!-- Simulate Saxon bug 3212 -->
<xsl:function name="f:parseInt" as="xs:integer?">
<xsl:param name="in" as="xs:string?"/>
<xsl:sequence select="xs:integer($in)"/>
</xsl:function>
<xsl:template match="/">
<out>
<xsl:variable name="range" select="f:parseInt(()) to f:parseInt('123')"/>
<xsl:if test="42 = $range">
<matched/>
</xsl:if>
</out>
</xsl:template>
</xsl:stylesheet>
- Status changed from New to Resolved
- Fix Committed on Branch 9.7, 9.8 added
Patch committed for 9.7 and 9.8. Confirmed that the bug has been in the code since at least 9.3 and probably much longer.
- Fix Committed on Branch trunk added
- Fix Committed on Branch deleted (
9.8)
- Applies to branch deleted (
9.8)
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.7.0.19 added
Bug fix applied in the 9.7.0.19 maintenance release.
Please register to edit this issue
Also available in: Atom
PDF