Project

Profile

Help

Bug #3563

closed

Pattern schema-element(ITEM)/AUTHOR is not motionless

Added by Michael Kay almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Streaming
Sprint/Milestone:
-
Start date:
2017-12-08
Due date:
% Done:

100%

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

Description

In a streamable schema-aware stylesheet, use of a pattern such as

match="schema-element(ITEM)/AUTHOR"

passes static analysis as a motionless pattern, but fails at execution time saying:

java.lang.UnsupportedOperationException: net.sf.saxon.trans.XPathException: Navigation using child axis is not supported from a streamed input node

It appears to have been compiled as a GeneralNodePattern rather than as an AncestorQualifiedExpression.

Actions #1

Updated by Michael Kay almost 7 years ago

It seems that the schema-aware optimization has recognized that there can only be one AUTHOR in an ITEM, and has helpfully rewritten the expression as @schema-element(ITEM)/AUTHOR[1]@, In fact it seems to have done this twice, and changed it to @schema-element(ITEM)/AUTHOR[1][1]@. Adding the [1] is useful for XPath expressions, because it stops searching after finding one AUTHOR, and establishes a more accurate type for the expression; but it's counter-productive for XSLT patterns.

Actions #2

Updated by Michael Kay almost 7 years ago

The creation of a FirstItemExpression happens in AxisExpression.checkPlausibility(), line 509.

We can prevent the redundant first(first(X)) by changing this code to special-case the situation where the parent of the AxisExpression is already a FirstItemExpression.

With this change we now get an AncestorQualifiedPattern, but it is still non-streamable because of the [1] predicate.

To suppress the rewrite completely within a pattern, we introduce a switch ExpressionVisitor.optimizeForPatternMatching.

Actions #3

Updated by Michael Kay almost 7 years ago

  • Priority changed from Low to Normal
  • Applies to branch 9.8, trunk added
  • Fix Committed on Branch trunk added

Fixed on the development branch.

Actions #4

Updated by Michael Kay almost 7 years ago

Test case si-apply-templates-007 added (not yet working)

Actions #5

Updated by Michael Kay almost 7 years ago

  • Status changed from New to Resolved
  • Fix Committed on Branch 9.8 added

Fixed on 9.8 branch and trunk.

New test case is now passing - but on 9.8 it passes when run from the command line, but not from the test driver, because the test driver doesn't handle validation on streamed source documents.

Actions #6

Updated by O'Neil Delpratt almost 7 years ago

  • % Done changed from 0 to 100

Bug fix applied in the Saxon 9.8.0.7 maintenance release.

Actions #7

Updated by O'Neil Delpratt almost 7 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.8.0.7 added

Please register to edit this issue

Also available in: Atom PDF