-
Notifications
You must be signed in to change notification settings - Fork 5
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
Proposal - namespace binding in XPath #20
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I certainly think it would be useful to be able to supply the namespace context as part of the expression. Are you proposing that this can appear anywhere an expression appears, or only at the top level? Can it be used to set the default namespace [for elements and types]? Might it be better to use the XQuery syntax (declare namespace) - I prefer your syntax, but compatibility is a thing...
On Thu, 2020-09-03 at 00:43 -0700, Michael Kay wrote:
@michaelhkay commented on this pull request.
Yes, I certainly think it would be useful to be able to supply the
namespace context as part of the expression. Are you proposing that
this can appear anywhere an expression appears, or only at the top
level?
Anywhere an expression can appear - so e.g. one could use it in the
body of a function in XQuery.
Can it be used to set the default namespace [for elements and
types]?
Not as written but that would be a good addition, thank you!
Might it be better to use the XQuery syntax (declare namespace) - I
prefer your syntax, but compatibility is a thing...
Because it can appear in the body of an expression, it's doing
something different, and we don't currently have semicolon-terminated
declarations in XPath.
I was thinking that this does no more than introduce a prefix - it does
not for example directly affect the in-scope namespaces any differently
than using an EQName in an expression.
…--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
|
This seems like a sensible addition to me. I was thinking to myself "this could be nicely expressed as a Pragma", then I realised of course that Pragma is only in XQuery. Let's leave this open for a couple of days for any more comments, and then all being well, let's merge it... |
Do we also want to provide support for declaring the default element namespace (something like And I guess that new prefixes will shadow existing ones? |
So let's try and flesh out the proposal. We have a new kind of PrimaryExpr: [56] PrimaryExpr ::= .... | WithPrefixExpr Semantics: The result of a WithPrefixExpr is the result of the EnclosedExpr, evaluated with a static context that varies the set of namespace bindings. Specifically, for each "prefix" clause, the static context for EnclosedExpr (the "inner context) is based on the static context of the WithPrefixExp (the "outer context") altered as follows:
** if the URILiteral is a zero-length string, any binding of the NCName to a URI in the outer context will be absent from the inner context (if there is no such binding in the outer context, then the declaration has no effect) ** Otherwise, the set of statically known namespaces in the inner context contains a (prefix, URI) binding for this NCName and the corresponding URILiteral, replacing any binding for this NCName that exists in the outer context
Error conditions:
Note:
|
On Sun, 2020-09-06 at 04:37 -0700, Michael Kay wrote:
So let's try and flesh out the proposal.
Hah! I saw Adam's comment and was about to sit down & try and make a
more formal propoosal, and it had already happened! Thank you for doing
that.
I think the changes - default, and using = instead of :- = are fine (i
used := by analogy with let but since both are in use this is fine
too).
We have a new kind of PrimaryExpr:
[56] PrimaryExpr ::= .... | WithPrefixExpr
[56a] WithPrefixExpr ::= "with" "prefix" NCName? "=" URILiteral (","
"prefix" NCName? ":=" URILiteral)* ) EnclosedExpr
Does this work without ambiguity in XQuery as well as XPath?
If it wasn't so long and wordy,
with namespace = "http:/example.og/" /a/b[ c= 7]/d
is clearer than with prefix, and still works for
with namespace xs = "https://www.w3.org/2001/xsd/" xs:integer
but i'm happy either way, thanks again for looking at this.
…--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
|
No description provided.