Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Proposed syntax for namespace binding in XPath

From: "Michael Kay" <mike@------------>
To:
Date: 3/31/2007 10:59:00 PM
I'd like to solicit reactions to a proposal to define an informal standard
for binding namespaces in strings containing XPath expressions.

I see a lot of people using XPath from Java and also using saxon:evaluate to
evaluate dynamically-constructed XPath expressions from XSLT or XQuery. One
of the difficulties with such interfaces has always been that defining the
namespace bindings is messy - in fact, in saxon:evaluate, it can't be done
dynamically at all.

Clearly a vendor-defined API can take as input some string that contains a
set of namespace bindings followed by an XPath expression. This doesn't
violate XPath conformance; it just means that the string passed to the API
contains an XPath expression embedded in something else. Hopefully other
systems that offer XPath APIs will follow suit, and we can establish an
informal standard rather along the lines of the Clark notation for expanded
QNames "{uri}local".

In choosing a syntax I'd like something that falls back to standard XPath if
there are no namespace bindings, and where it's very easy to spot that
namespace bindings are present if this is the case. I think that in the
XPath house-style, it should also be less wordy than the XQuery prolog which
uses

declare default element namespace x = "uri";

I would also like something that can be written in an XML attribute, so
characters such as "<" (and ideally quotes) should be avoided.

XPointer has a mechanism that's one possible candidate: the xmlns() scheme:

http://www.w3.org/TR/xptr-xmlns/

An example is

xmlns(abc=http://example.com/ns/abc)

or in context,

xmlns(c=http://example.org/customer)
xmlns(p=http://example.org/personal-info)
xpointer(/c:customer/p:name)

There are several disadvantages to adopting this directly. It doesn't allow
the default namespace to be bound; it's not easily distinguishable from a
function call; it can't handle a URI containing an unpaired right bracket;
and it doesn't fall back to pure XPath when there are no bindings.

The syntax I'm thinking of using is:

(:# xmlns=http://default/uri xmlns:p=http://other/uri #:) xpath-expression

Using a special comment has the advantage that XPath processors that don't
understand the notation will ignore it (though I freely admit that
"meaningful comments" have their drawbacks). It avoids use of quotes which
makes it easy to embed in an XML attribute, and it uses space to delimit the
URI - although there is no absolute ban on having a space in a namespace
URI, there are already plenty of things that will break if you do it, so
it's unlikely to cause any new problems.

Michael Kay
http://www.saxonica.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent