Project

Profile

Help

Bug #4645

closed

Pattern x/(a|b) is rejected

Added by Michael Kay almost 4 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2020-07-14
Due date:
% Done:

100%

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

Description

The match pattern x/(a|b) is legal in XSLT 3.0 but Saxon-J rejects it.

Test case match-265 added to XSLT3 test suite.

Actions #1

Updated by Michael Kay almost 4 years ago

For the particular pattern in this example, fixing this should be fairly easy - extend PatternMaker.getAxisForPathStep() to recognise a union expression in which all subexpressions use the same axis.

A more challenging case is x/(child::a | descendant::b) which also appears to be a legal pattern. To handle the general case we may be best off expanding this to x/child::a | x/descendant::b.

Note in passing: this doesn't actually affect the outcome, but it appears that Saxon fails to remove the document-order sort operation from the path expression x/(a|b), i.e it fails to detect that the expression is "naturally sorted".

Actions #2

Updated by Michael Kay almost 4 years ago

Actually I think the sort will be removed from x/(a|b) during the optimization phase, by virtue of the fact that (child::a|child::b) is effectively rewritten as child::*[self::a or self::b]. But for various (probably sound) reasons, the conversion of an expression to a pattern occurs before the optimisation phase is run.

Actions #3

Updated by Wendell Piez almost 4 years ago

Where this comes up in our use case, we are producing the paths (match patterns) programmatically, and they take the form of (a | b/c) / (d | e/f) / (x | y/z) of arbitrary length (though rarely more than two). We could perhaps find a way to produce better paths (and maybe should do so in any case).

Many thanks! Wendell

Actions #4

Updated by Michael Kay over 3 years ago

Added some more permutations of paths and unions in tests match-266 to -268.

Actions #5

Updated by Michael Kay over 3 years ago

I have fixed the case where the branches of the union use the same axis (tests match-265, -269) by adding another condition to PatternMaker.getAxisForPathStep.

Actions #6

Updated by Michael Kay over 3 years ago

For the asymmetric case such as a/(child::b | descendant::c) it seems best to distribute the ancestry condition, turning it into a/child::b | a/descendant::b.

I have adopted this approach and these tests now pass.

Actions #7

Updated by Michael Kay over 3 years ago

  • Status changed from New to Resolved
  • Applies to branch 10, trunk added
  • Fix Committed on Branch 10, trunk added
Actions #8

Updated by O'Neil Delpratt over 3 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.2 added

Bug fix applied in the Saxon 10.2 maintenance release.

Actions #9

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to Closed
Actions #10

Updated by Michael Kay almost 2 years ago

  • Applies to branch 9.9 added
  • Applies to branch deleted (trunk)

Note that the bug is also present in 9.9 and earlier releases, and is not being fixed on those branches.

Please register to edit this issue

Also available in: Atom PDF