Bug #4645
closedPattern x/(a|b) is rejected
100%
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.
Updated by Michael Kay over 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".
Updated by Michael Kay over 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.
Updated by Wendell Piez over 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
Updated by Michael Kay over 4 years ago
Added some more permutations of paths and unions in tests match-266 to -268.
Updated by Michael Kay over 4 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
.
Updated by Michael Kay over 4 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.
Updated by Michael Kay over 4 years ago
- Status changed from New to Resolved
- Applies to branch 10, trunk added
- Fix Committed on Branch 10, trunk added
Updated by O'Neil Delpratt over 4 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.
Updated by O'Neil Delpratt over 4 years ago
- Status changed from Resolved to Closed
Updated by Michael Kay over 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