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:[EMAIL PROTECTED]
> Sent: Thursday, March 13, 2003 2:22 PM
> To: [EMAIL PROTECTED]
> 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:     [EMAIL PROTECTED]
> To unsubscribe, e-mail:          [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to