[xquery-talk] X Query NameSpace related Query
Michael Kay
mhk at mhk.me.uk
Thu Aug 24 18:35:22 PDT 2006
In XQuery, if you want to find an element named
{http://www.kroger.com/JDE}thing (that is, an element whose namespace URI is
http://www.kroger.com/JDE and whose local name is "thing") then you can
either
(a) bind the default namespace to http://www.kroger.com/JDE and select it as
"thing":
declare default element namespace "http://www.kroger.com/JDE";
//thing
or (b) bind an explicit prefix to http://www.kroger.com/JDE and select it as
"pre:thing":
declare namespace pre = "http://www.kroger.com/JDE";
//pre:thing
I assume you are aware that if your document contains
xmlns="http://www.kroger.com/JDE" in its outermost element [please don't
call it the root tag - it's not a tag and it's not the root], then all the
unprefixed elements are in this namespace.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: talk-bounces at xquery.com
> [mailto:talk-bounces at xquery.com] On Behalf Of Taranmeet Kindra
> Sent: 24 August 2006 15:05
> To: talk at xquery.com
> Subject: [xquery-talk] X Query NameSpace related Query
>
>
> Hi
>
> I am able to retrieve desired results when I don't specify
> the namespace in the root tag of xml.
>
> I use "declare namespace
> xs='http://www.w3.org/2001/XMLSchema';"+ Query
>
> This approach works with no namespace specified.
>
> Now my root tag in xml is
>
> <ContractHeader xmlns="http://www.kroger.com/JDE"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.kroger.com/JDE
> D:\kroger\xmlbeans-2.1.0\k_xsd\JDE_Interface.xsd">
>
> My root tag in XSD is:
>
> <xs:schema targetNamespace="http://www.kroger.com/JDE"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:JDE="http://www.kroger.com/JDE" elementFormDefault="qualified"
> attributeFormDefault="unqualified">
>
>
>
> It tried:
> "declare namespace JDE='http://www.kroger.com/JDE';" + Query
>
>
> But it did not work, I also tried in Google to find out how
> to use namespaces in XQuery but didn't find much,
>
>
> Thanks
> Taran
>
> **************************************************************
> **************************************************************
> *****************************************
> "This message and any attachments are solely for the intended
> recipient and may contain confidential or privileged
> information. If you are not the intended recipient,any
> disclosure,copying, use, or distribution of the information
> included in this message and any attachments is prohibited.
> If you have received this communication in error, please
> notify us by reply e-mail and immediately and permanently
> delete this message and any attachments. Thank you."
> **************************************************************
> **************************************************************
> *****************************************
>
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
More information about the talk
mailing list