[jdom-interest] output with namespace only on root element

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Jun 9 08:11:36 PDT 2003


At 11:04 AM -0400 6/9/03, tballen at copart.com wrote:
>I guess I did not phrase my question properly.
>The child elements *are* in the same namespace since the parent 
>element is in the default namespace.  (At least I think so.)

And I repeat: I don't think you understand how namespaces work. JDOM 
is giving you what you need and what you want, not what you think you 
want. Consider this document:

<cprt:root xmlns:cprt="http://www.myserver.com/schema">
   <test>Hello</test>
</cprt:root>

The test element is *not* in the http://www.myserver.com/schema 
namespace. It is no namespace at all.

Your latest example suggests you are using the W3C XML schema 
language. In particular, I strongly suspect you are using unqualified 
local elements. Don't do that. This is a very confusing and poorly 
designed part of a very confusing and poorly designed schema 
language. Set elementFormDefault="qualified" in your schema. 
Remember, the schema has *nothing* to do with which elements are in 
which namespaces. That is completely determined by namespace 
declarations and prefixes.
-- 

   Elliotte Rusty Harold
   elharo at metalab.unc.edu
   Processing XML with Java (Addison-Wesley, 2002)
   http://www.cafeconleche.org/books/xmljava
   http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA



More information about the jdom-interest mailing list