xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anne Thomas Manes" <a...@manes.net>
Subject RE: Namespaces inherited?
Date Thu, 13 Mar 2003 20:12:14 GMT
Tim,

In the first example:

> <ns:elemA xmlns:ns="urn:myNS">
>   <elemB/> <!-- this elem would implicitly be in the 'ns' namespace -->
> </ns:elemA>

ElemB is either unqualified or it is qualified by the default namespace (the
xmlns="some-uri" declaration, if there is one). There's no assumption that
it belongs to its parent's namespace.

Namespace *declarations* are inherited. In other words, you don't have to
redeclare your namespaces for each child element. So, for example:

<elemA   <!-- this elem is in the default namespace -->
   xmlns="urn:myNS"
   xmlns:joe="urn:joeNS"
   xmlns:fred="urn:fredNS">
   <elemB>  <!-- this elem is in the default namespace -->
     <joe:elemB/>  <!-- this elem is in the "joe" namespace -->
     <fred:elemB/>  <!-- this elem is in the "fred" namespace -->
   </elemB>
</elemA>

If you couldn't inherit namespace declarations then you would need to do
this:

<elemA xmlns="urn:myNS">
   <elemB xmlns="urn:myNS">
     <elemB xmlns="urn:joeNS"/>
     <elemB xmlns="urn:fredNS"/>
   </elemB>
</elemA>

Anne

> -----Original Message-----
> From: Watts, Tim T [mailto:timothy.watts@bankofamerica.com]
> Sent: Thursday, March 13, 2003 2:22 PM
> To: general@xml.apache.org
> Subject: Namespaces inherited?
>
>
> Hello,
>
> I read that child elements "inherit" the namespace of their
> parent by default ("Professional Java SOAP", p30, Wrox Press).
> The W3C spec says that they're in scope for all children. But
> that's not the same as inheriting. To my understanding,
> "inheriting" would mean that the children automatically become
> members of the parent's namespace unless explicitly overridden
> while "in scope" means that the namespace is merely *available*
> to the children.
>
> According to the book, the following examples are semantically equivalent:
>
> <ns:elemA xmlns:ns="urn:myNS">
>   <elemB/> <!-- this elem would implicitly be in the 'ns' namespace -->
> </ns:elemA>
>
> <ns:elemA xmlns:ns="urn:myNS">
>   <ns:elemB/>
> </ns:elemA>
>
> I don't think this is correct but I would like to hear from more
> knowledgable sources. The behavior of the Xerces implementation
> of DOM does not conform to the above.
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
>


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message