Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn’t distinguish PathExpr from PrimaryExpr #3

Closed
simonjwright opened this issue Jun 25, 2021 · 3 comments
Closed

Doesn’t distinguish PathExpr from PrimaryExpr #3

simonjwright opened this issue Jun 25, 2021 · 3 comments

Comments

@simonjwright
Copy link
Owner

(quoting from XSLT Programmer’s Reference, Michael Kay, Wrox Press, 2000 page 387):

//section/para[1] returns all para elements that are the first para child of a section parent.
(//section/para)[1]returns the first element in the document that is a para child of a section parent.

XIA treats the first case as the second, and finds the second case syntactically incorrect.

@simonjwright
Copy link
Owner Author

I think the heart of the problem is that XIA’s grammar starts at Location_Path rather than at Expr: the specification says in the Introduction that

The primary syntactic construct in XPath is the expression. An expression matches the production Expr.

This may be a major change ...

@simonjwright
Copy link
Owner Author

I think the heart of the problem is that XIA’s grammar starts at Location_Path rather than at Expr: the specification says in the Introduction that

The primary syntactic construct in XPath is the expression. An expression matches the production Expr.

This may be a major change ...

Actually, to my huge surprise, I can simply change the %start LocationPath in the grammar to %start Expr! so the syntax problem is easily fixed. That leaves moving the point at which a Predicate is applied much earlier, to the result of applying the Step’s location path to the individual input context node rather than to the union of applying the location path to all the input context nodes.

The XPath 1.0 spec is so much shorter than the Ada LRM; but I suppose it shouldn’t be a surprise that there are deeply serious implications of apparently innocuous phrasings!

@simonjwright
Copy link
Owner Author

Fixed in release 1.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant