- From: Michael Kay <mhk@mhk.me.uk>
- Date: Tue, 21 Feb 2006 12:59:24 -0000
- To: "'David Carlisle'" <davidc@nag.co.uk>, <ihr@xbrl.org>
- Cc: <public-qt-comments@w3.org>
This is a workaround (it depends on copy-namespaces mode being set to the default value of "inherit, preserve") - but it doesn't alter the fact that there's a requirement here which we ought to take on board for XQuery 2.0. Saxon incidentally has a saxon:namespace-node() extension function to fill this gap. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: public-qt-comments-request@w3.org > [mailto:public-qt-comments-request@w3.org] On Behalf Of David Carlisle > Sent: 21 February 2006 12:10 > To: ihr@xbrl.org > Cc: public-qt-comments@w3.org > Subject: Re: Requirement: Dynamically add namespaces to new > created elements. > > > > > 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 > expressions. > > David > > > > > 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}{} > }/*}; > > > > local:f("foobar","x","http://example.org") > > > > ______________________________________________________________ > __________ > 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: > http://www.star.net.uk > ______________________________________________________________ > __________ > >
Received on Tuesday, 21 February 2006 12:59:37 UTC