Bug #2234
closed9.6 optimizations break relative XPath with predicates
100%
Description
I'm fairly new to XSLT, so forgive me if my terms are incorrect.
I am using saxonHE-9.6 to run XPath queries from a shell script and discovered that when a predicate is used in a relative XPath it does not work properly. I ran it with -explain and saw the "OPT : Rewrote descendant::X/child::Y as descendant::Y[parent::X]" note, which I googled and found the optimization note at http://www.saxonica.com/documentation/html/changes/v9.6/optimization.html. I decided to try the same query using saxonHE-9.5 and 9.4 and both worked as expected.
To reproduce the error:
foo.xml:
<property key='firstname'>
<stringValue>Robert</stringValue>
</property>
<property key='middlename'>
<stringValue>William</stringValue>
</property>
<property key='lastname'>
<stringValue>MacKenzie</stringValue>
</property>
foo.xslt:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:value-of select="//property[@key='firstname']/stringValue" />
</xsl:template>
</xsl:stylesheet>
Result from 9.6 (incorrect, returns all stringValue nodes as if predicate is ignored):
Robert William MacKenzie
Result from 9.5 & 9.5 (correct):
Robert
The command line I am using is:
$JAVA_HOME/bin/java -jar saxonHE-9.6.0.2.jar -s:foo.xml -xsl:foo.xslt
Java version is: Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Updated by Michael Kay about 10 years ago
- Category set to XSLT conformance
- Status changed from New to In Progress
- Assignee set to Michael Kay
- Priority changed from Low to Normal
- Found in version set to 9.6
Thanks for reporting it. I've reproduced the problem: it occurs in Saxon-HE but not in Saxon-EE.
Updated by Michael Kay about 10 years ago
- Status changed from In Progress to Resolved
Now fixed (source patched on the 9.6 and 9.7 branches). The optimizer rewrite was indeed dropping the predicate. The reason this slipped through is that in the case where there is a predicate of this kind, Saxon-EE applies a more powerful optimisation to create an index, and because most of our testing is under Saxon-EE, this masked the problem.
Updated by O'Neil Delpratt almost 10 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.6.0.3
Bug fix patch applied to the Saxon 9.6.0.3 maintenance release
Updated by O'Neil Delpratt almost 9 years ago
- Sprint/Milestone set to 9.6.0.3
- Applies to branch 9.6 added
- Fix Committed on Branch 9.6 added
- Fixed in Maintenance Release 9.6.0.3 added
Please register to edit this issue