Bug #2715
closedXPath parsing edge cases
100%
Description
See https://lists.w3.org/Archives/Public/public-xsl-query/2016Mar/0037.html
The WG believes that the XPath grammar allows expressions such as
12!(12 div.)
12 div-3
3!(12 div-.)
which Saxon cannot parse. The key point is that Saxon is reading the "." or "-" as a continuation of the token starting "div", which it should not do, because the tokenization rule is to accept the longest token consistent with the grammar, and in these contexts, an NCName containing a "." or "-" is not consistent with the grammar.
Updated by Michael Kay over 8 years ago
- Status changed from New to Resolved
- Applies to branch 9.7, 9.8 added
- Fix Committed on Branch 9.7, 9.8 added
I've tweaked the tokenizer to handle these cases, though the solution might not be completely general. Essentially the fix is as follows:
if we encounter "." or "-" when reading (what appears to be) a name, then we check whether the following conditions are true:
(a) the content of the token so far is a valid operator/keyword
(b) the preceding token is not classified as an operator symbol (token number > LAST_OPERATOR) and is not "?" or "*:"
(c) the preceding token is not a name that is equal to a valid operator/keyword
if all these conditions are true then we stop the tokenizing at the "." or "-" and return the operator token.
Condition (c) was found to be necessary because when we are parsing a FLWOR expression, keywords such as "in" and "return" are returned as NAME tokens rather than as specific operator tokens.
I'm committing a patch on the 9.7 and 9.8 branches.
Updated by O'Neil Delpratt over 8 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.7.0.5 added
Bug fix applied in the Saxon 9.7.0.5 maintenance release.
Updated by O'Neil Delpratt over 7 years ago
- Applies to branch trunk added
- Applies to branch deleted (
9.8)
Updated by O'Neil Delpratt over 7 years ago
- Fix Committed on Branch trunk added
- Fix Committed on Branch deleted (
9.8)
Please register to edit this issue