In XQuery 3.0 you could write the following:
element {"a"}{
(
namespace pre { "urn:u" },
element {fn:QName("pre", "pre:b")}{},
element {fn:QName("pre", "pre:c")}{}
)
}
http://try.zorba.io/queries/xquery/OEkkPFKllu7moQ5l6eCBTQ1fiBY%3D
On Fri, Jan 31, 2014 at 9:51 AM, Michael Kay <[email protected]> wrote:
>
> On 31 Jan 2014, at 08:12, Hermann Stamm-Wilbrandt <[email protected]> wrote:
>
>>
>> From (1):
>> In XPath Version 2.0, the namespace axis is deprecated and need not be
>> supported by a host language. A host language that does not support the
>> namespace axis need not represent namespace bindings in the form of nodes.
>>
>> XQuery (eg. Zorba or DataPower) does not support the namespace axis.
>>
>>
>> <a><pre:b xmlns:pre="urn:u"/><pre:c xmlns:pre="urn:u"/></a>
>>
>> can be created by computed element constructors (2) by this:
>>
>> element {"a"}{
>> (
>> element {fn:QName("urn:u", "pre:b")}{},
>> element {fn:QName("urn:u", "pre:c")}{}
>> )
>> }
>>
>> Is it true, that "equivalent" (not sure whether right term) XML
>> <a xmlns:pre="urn:u"><pre:b/><pre:c/></a>
>>
>> cannot be created by computed element constructors in XQuery?
>
> If we're talking about XQuery 1.0, then yes, I believe that there is no way
> you can create an element with a namespace that is (a) unused on that
> element, and (b) not known statically.
>
> (I might be wrong; I seem to recall David Carlisle coming up with a devious
> workaround, but it was so devious I don't recall how it works).
>
> Query 3.0 introduces dynamic namespace node constructors to solve this
> problem. This leaves the language in the rather absurd situation that there
> is a construct to create namespace nodes, but no construct to retrieve them.
>
> The XQuery WG was very reluctant to support the namespace axis because many
> vendors claimed that it was impossible to support it efficiently. Some of
> those vendors, when told to look at open source implementations like xt and
> Saxon that had efficient implementations, said that their company policy did
> not allow them to read open source code. Shame.
>
> Michael Kay
> Saxonica
>
>>
>>
>> It can be created by XSLT 1.0+EXSLT stylesheet:
>>
>> $ java -jar ~/Desktop/saxon6-5-5/saxon.jar dummy.xml compel.xsl ; echo
>> <a xmlns:pre="urn:u"><pre:b/><pre:c/></a>
>> $
>> $ cat compel.xsl
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:exslt = "http://exslt.org/common"
>>>
>> <xsl:output omit-xml-declaration="yes" />
>>
>> <xsl:template match="/">
>> <xsl:variable name="tmp">
>> <xsl:element name="a">
>> <xsl:attribute name="pre:ʎɯɯnp" xmlns:pre="urn:u"/>
>> <xsl:element name="pre:b" xmlns:pre="urn:u"/>
>> <xsl:element name="pre:c" xmlns:pre="urn:u"/>
>> </xsl:element>
>> </xsl:variable>
>>
>> <xsl:apply-templates select="exslt:node-set($tmp)/*"/>
>> </xsl:template>
>>
>> <xsl:template match="*">
>> <xsl:copy>
>> <xsl:copy-of select="namespace::*|attribute::*[local-name
>> ()!='ʎɯɯnp']"/>
>> <xsl:apply-templates select="*"/>
>> </xsl:copy>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>> $
>>
>>
>> (1) http://www.w3.org/TR/xpath20/#dt-in-scope-namespaces
>> (2) http://www.w3.org/TR/xquery/#id-computedElements
>>
>> Mit besten Gruessen / Best wishes,
>>
>> Hermann Stamm-Wilbrandt
>> Level 3 support for XML Compiler team and Fixpack team lead
>> WebSphere DataPower SOA Appliances
>> https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
>> https://twitter.com/HermannSW/
>> http://stamm-wilbrandt.de/GraphvizFiddle/
>> ----------------------------------------------------------------------
>> IBM Deutschland Research & Development GmbH
>> Vorsitzende des Aufsichtsrats: Martina Koederitz
>> Geschaeftsfuehrung: Dirk Wittkopp
>> Sitz der Gesellschaft: Boeblingen
>> Registergericht: Amtsgericht Stuttgart, HRB 243294
>>
>> _______________________________________________
>> [email protected]
>> http://x-query.com/mailman/listinfo/talk
>
>
> _______________________________________________
> [email protected]
> http://x-query.com/mailman/listinfo/talk
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk