Project

Profile

Help

Bug #2234

closed

9.6 optimizations break relative XPath with predicates

Added by Jay MacDonald over 9 years ago. Updated over 8 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)

Actions #1

Updated by Michael Kay over 9 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.

Actions #2

Updated by Michael Kay over 9 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.

Actions #3

Updated by O'Neil Delpratt over 9 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

Actions #4

Updated by O'Neil Delpratt over 8 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

Also available in: Atom PDF