[xquery-talk] Serialized namespace prefixes

Michael Kay mhk at mhk.me.uk
Thu Sep 29 19:19:37 PDT 2005


The data model defines that a QName is a triple, consisting of prefix, uri,
and local-name. The node-name of an element is a QName, which retains all
three components from the original XML. Your query is selecting the original
node, and then serializing it. Serialization uses the prefix present on the
element node in the data model. (When constructing new elements and
attributes the rules are more complex, but there is no construction involved
here.)

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Pierrick Brihaye
> Sent: 29 September 2005 17:38
> To: talk at xquery.com
> Subject: [xquery-talk] Serialized namespace prefixes
> 
> Hi,
> 
> Given the following XML file (called "rdf.rdf") :
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>           xmlns:dc="http://purl.org/dc/elements/1.1/"
>           xmlns:x="http://exist.sourceforge.net/dc-ext">
>     <rdf:Description id="3">
>       <dc:title>title</dc:title>
>       <dc:creator>creator</dc:creator>
>       <x:place>place</x:place>
>       <x:edition>place</x:edition>
>    </rdf:Description>
> </rdf:RDF>
> 
> The following XQuery :
> 
> declare namespace x = "http://www.foo.com";
> let $a := doc("rdf.rdf")
> return $a//x:edition
> 
> ... returns the empty sequence with Saxon 8.5.1.
> 
> This demonstrates that the "declare namespace" statement has 
> precedence 
> over the declarations in the document. Fine.
> 
> Now, the following XQuery :
> 
> declare namespace x = "http://www.foo.com";
> declare namespace y = "http://exist.sourceforge.net/dc-ext";
> let $a := doc("rdf.rdf")
> return $a//y:edition
> 
> ... returns :
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <x:edition
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:dc="http://purl.org/dc/elements/1.1/"
> xmlns:x="http://exist.sourceforge.net/dc-ext">place</x:edition>
> 
> Fine. The document takes the prolog's "declare namespace" 
> statement into 
> account.
> 
> Fine ? Not so sure... why a "x" prefix-binding whereas I 
> asked for a "y" 
> one ?
> 
> Can anybody explain me what happens ?
> 
> Cheers,
> 
> p.b.
> 
> 
> 
> 
> 
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 




More information about the talk mailing list