W3C home > Mailing lists > Public > public-qt-comments@w3.org > February 2006

Re: Requirement: Dynamically add namespaces to new created elements.

From: David Carlisle <davidc@nag.co.uk>
Date: Tue, 21 Feb 2006 12:10:17 GMT
Message-Id: <200602211210.MAA13894@penguin.nag.co.uk>
To: ihr@xbrl.org
CC: public-qt-comments@w3.org

  Looking at the current XQuery spec 1.0 I realized that it is not possible to
  dynamically create a namespace declaration to an element when you are
  dynamically creating the element or when using a QName as element content.

If I understand your example can't you just copy the measure element
from your input (the namespace declaration will be added by the
serialiser). If you do need to generate an in-scope namespace from
scratch from a namespace that is neither in the source file nor query,
it's true that XQuery doesn't have an analogue of XSLT's xsl:namespace
instruction but it is still possible. Consider for example the following
function which generates an element with specified name and a namespace
declaration with a specifed prefix and URI.

It's called with three string literals below and generates
<foobar xmlns:x="http://example.org"/>
but of course the three parameters could be any string-valued


declare function local:f ($elem as xs:string,$prefix as xs:string,$ns as xs:string) as element() {
element {QName($ns,concat($prefix,":wibble"))}{
element {$elem}{}


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
Received on Tuesday, 21 February 2006 12:18:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:10 UTC