Project

Profile

Help

Bug #2234

closed

9.6 optimizations break relative XPath with predicates

Added by Jay MacDonald about 10 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
Start date:
2014-11-21
Due date:
% Done:

100%

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

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)

Please register to edit this issue

Also available in: Atom PDF