[xquery-talk] namespace declarations in an element

Michael Kay mike at saxonica.com
Thu May 26 07:27:35 PDT 2011

On 26/05/2011 15:14, Leo Studer wrote:
> Hi Michael and Ghislain
> thank you for your input. Indeed with those two functions I get the prefixes and the namespaces as I need them.
> Now a related question. How do I generate such namespaces in an element with xQuery?

XQuery 1.0 does not have a facility for generating namespaces 
dynamically (i.e. namespaces that aren't known at compile time, and 
aren't used in element or attribute names.) This is fixed in 3.0.

There's a workaround invented by David Carlisle which I can't lay my 
hands on at the moment. It involves using a computed attribute 
constructor to create an attribute in the desired namespace, copying 
this attribute to the target element, then discarding the attribute 
again - but I forget the details.

Michael Kay

More information about the talk mailing list