[xquery-talk] QName in content

Andrew Welch andrew.j.welch at gmail.com
Thu Nov 25 05:18:10 PST 2010


> But I'd like something that, once I serialize a QName, and schema-validating
> it
> as a Qname, I get my (full) QName back, please.

This has always been the problem - how do you write a namespaced name
so you can write an xpath without having to first provide the prefix
bindings.  The common use case is just typing an xpath into the
command line to query an xml document, currently you would need to map
the prefixes to namespaces before writing the xpath... there's no
standard way to skip the first part.

If we can solve that, then we have the serialisation format - the fact
that you only get the local name when getting the string value of a
QName is, as far as I know, because there is no standard way yet.

As Florent says, you could perhaps use Clark notation:

/{http://www.w3.org/1999/xhtml}html/{http://www.w3.org/1999/xhtml}head

or maybe Per's solution:

/x{http://www.w3.org/1999/xhtml}:html/x{http://www.w3.org/1999/xhtml}\head

Per's is round-trippable, but long winded to type by hand in the
command line scenario.

Also, I can't remember why now, but the use of braces { } causes an
issue, maybe with AVTs, so those should be avoided.

As drunken guess at something, you could put the namespace mappings at
the start, followed by a standard xpath:

[x:http://www.w3.org/1999/xhtml]/x:html/x:head

There's no doubt a good reason why that can't be done, but you get the idea.


-- 
Andrew Welch
http://andrewjwelch.com


More information about the talk mailing list