[xquery-talk] Serialized namespace prefixes

Pierrick Brihaye pierrick.brihaye at free.fr
Thu Sep 29 19:37:53 PDT 2005


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.








More information about the talk mailing list