[jdom-interest]  Default Namespace vs No-Namespace.
    Elliotte Rusty Harold 
    elharo at metalab.unc.edu
       
    Thu Jul  3 10:36:20 PDT 2003
    
    
  
At 10:16 AM -0700 7/3/03, John Jefferson wrote:
>Hi,
>
>The default namespace is a feature of xml which allows
>you to declare one namespace at the top and for any
>element in the document which is not given a namespace
>that element will inherit the default namespace.
No, this statement is not true. Namespaces are quite a bit more 
complicated than that. When  designing an API, it's important to be 
really precise and clear about these things.
>Why is jdom's behavior set such that when I have a
>document and I set the default namespace at the root
>the child nodes of the root do not inherit the
>namespace but instead are set to the special
>no-namespace namespace.
Because that's what you asked for in your code.
>This is problematic for me.  What I am doing is
>receiving an xml file from an untrusted source.  What
>I then what to ensure is that this xml validate
>against my particular schema/dtd.
>In order to do this, I build the document with SAX.
>Get the root element and set the root elements
>namespaces, etc such that this document is using my
>schemas/dtds.  Now I write this document back out and
>read it in again in order to validate it but since the
>XmlOutputter gives the root children the no-namespace,
>the document fails validation.
Yet another fallacy. You do not need to change the document to 
validate it. The namespace name does *not* point to the schema.
-- 
   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