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

John Jefferson surfer97301 at yahoo.com
Thu Jul 3 13:56:53 PDT 2003


No I can't assume anything about what they pass in. 
They might not even declare any namespaces.  


--- "New, Cecil (GEAE)" <cecil.new at ae.ge.com> wrote:
> If you can assume the namespace prefix is the same,
> changing the root references
> should be all you need to do.  If you can't, then
> change to the root namespace
> references will be a bit tricker.  But, nonetheless,
> I think that's all you need
> to do.
> 
> Of course, others on this list are much more savvy
> than myself about these
> matters.
> 
> But I think your use case is clear.  And I think it
> will be one that will be
> very common in an age of web services/soap.
> 
> Jason once referred to such incoming XML documents
> as "viruses" -- making the
> point very well.
> 
> Cheers.
> 
> -----Original Message-----
> From: John Jefferson [mailto:surfer97301 at yahoo.com]
> Sent: Thursday, July 03, 2003 2:03 PM
> To: Elliotte Rusty Harold
> Cc: 'jdom-interest at jdom.org'
> Subject: Re: [jdom-interest] Default Namespace vs
> No-Namespace.
> 
> 
> > >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
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.co
> m


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



More information about the jdom-interest mailing list