[jdom-interest] Default Namespace vs No-Namespace.

John Jefferson surfer97301 at yahoo.com
Thu Jul 3 11:02:37 PDT 2003


> >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.


Maybe you can enlighten me on this point.  Or point me
to something easier to digest than the xml namespace
spec.  

 
> >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.

Alright how can I, without iterating through all nodes
in the document, set the root element to have a
default namespace and have that namespace propogate
down to all children nodes which are not already
namespaced - other than the special no-namespace?

 
> >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.

Let me give you an example to make this more clear.  

The xml I have coming in looks like:

<root xmlns="http://notmynamespace"
xmlns:custom="http://www.custom.com/CUSTOM"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://notmynamespace
notmyname.xsd    http://www.custom.com/CUSTOM
custom.xsd">

<child1/>
<child2/>

</root>

Now I want to validate this document against the
default namespace of xmlns="http://mynamespace" and a
different set of schemas.  

How do I do this without changing the namespace?


Thanks for the response, any help is appreciated!

JJ


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



More information about the jdom-interest mailing list