Namespace Prefixes

View: New views
2 Messages — Rating Filter:   Alert me  

Namespace Prefixes

by David M Sledge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Do namespace prefixes matter in xqueries or just the associated
namespace URIs?  Provided that the document biblio.rdf is exactly the
same for each of the following queries, should each query give me the
exact same result?

QUERY 1
_______
xquery version "1.0";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";

for $root in doc('biblio.rdf')/rdf:root
return $root

QUERY 2
_______
xquery version "1.0";
declare namespace blah="http://www.w3.org/1999/02/22-rdf-syntax-ns#";

for $root in doc('biblio.rdf')/blah:root
return $root

QUERY 3
_______
xquery version "1.0";
declare default element namespace
"http://www.w3.org/1999/02/22-rdf-syntax-ns#";

for $root in doc('biblio.rdf')/root
return $root


Thanks,

David


RE: Namespace Prefixes

by Michael Kay-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


These queries are equivalent. The prefix is just a shorthand for the URI.

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

> -----Original Message-----
> From: www-ql-request@... [mailto:www-ql-request@...] On
> Behalf Of David Sledge
> Sent: 04 April 2006 18:31
> To: www-ql@...
> Subject: Namespace Prefixes
>
>
> Do namespace prefixes matter in xqueries or just the associated
> namespace URIs?  Provided that the document biblio.rdf is exactly the
> same for each of the following queries, should each query give me the
> exact same result?
>
> QUERY 1
> _______
> xquery version "1.0";
> declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
>
> for $root in doc('biblio.rdf')/rdf:root
> return $root
>
> QUERY 2
> _______
> xquery version "1.0";
> declare namespace blah="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
>
> for $root in doc('biblio.rdf')/blah:root
> return $root
>
> QUERY 3
> _______
> xquery version "1.0";
> declare default element namespace
> "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
>
> for $root in doc('biblio.rdf')/root
> return $root
>
>
> Thanks,
>
> David
>
>



LightInTheBox - Buy quality products at wholesale price!