[jdom-interest] Namespace help

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Jul 24 13:45:43 PDT 2002


At 2:46 PM -0400 7/24/02, Li Xu wrote:


>Now I don't know if this is a bug or FAD (feature as designed), but 
>if the child namespace is null thus its URI is null, then this can 
>be interpreted as the child implicitly inherits the parent's 
>namespace

No it cannot be so interpreted. This is a design decision, and a 
correct one, not a bug.

>(using elementFormDefault="qualified" attribute in the schema should 
>be all it needs).

That's not what elementFormDefault means at all. elementFormDefault 
refers to the elements named in the schema. It does not describe 
where the namespace declarations go in the instance document.

>  But the current JDOM implementation pretty much says "null" is not 
>the same as a specified parent namespace, thus I will print out this 
>empty namespace URI even though xmlns="" looks really silly.

If you want the elements to be in a namespace, you have to put them there.

>The consequence for me is that my client app receives this XML 
>output from the server as a string. If schema validation is turned 
>on on the client side when it parses the doc, then the XML is 
>invalid because of this xmlns="" issue.

That's because it is invalid.

>Can someone suggest what my options are here?
>

Use namespaces on all your elements.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
|              http://www.cafeconleche.org/books/xian2/              |
|  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/  |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list