qtspecs icon indicating copy to clipboard operation
qtspecs copied to clipboard

Declare namespace bindings in XPath

Open michaelhkay opened this issue 10 months ago • 0 comments

We have dropped the proposed "with" expression, which was in the spec but never reviewed by the WG.

We need to reconsider the requirement: do we need some kind of construct to declare namespace prefixes, and perhaps other parts of the static context, in XPath?

One thought here is that when XPath expressions are issued from a host language such as Javascript or Python, the typical pattern is to have lots of small independent XPath expressions within a program. It doesn't make sense for each such expression to have its own boilerplate to establish the context, which will usually be the same for each expression. Rather it makes sense for the XPath invocation API to supply a reference to a context object which is set up once and reused. However, this doesn't mean that there's no room for XPath syntax to establish the context. For example, one might envisage a program doing

XPath engine = new XPath();
engine.setStaticContext("declare namespace abc='http://abc.uri'; pqr = 'http://pqr.uri");
engine.evaluate("//x/@y");

so the syntax for creating the static context would be decoupled from the expression syntax.

michaelhkay avatar Mar 26 '24 22:03 michaelhkay