[jdom-interest] Namespace help

bob mcwhirter bob at werken.com
Wed Jul 24 15:02:49 PDT 2002


On Wed, 24 Jul 2002, Li Xu wrote:

> Thanks for all the clarification. I'm not sure if I stated my problem clearly. I understand that if I want a namespace with an element, I need to put it there. But in this case, I did not want any and didn't put any in those 2nd level elements. So why i
s Outputter still printing out xmlns=""? I didn't assign "" namespace to those elements.
> 
> To illustrate, (<level2> has no namespace set) I want the output to be :
> 
> ===============
> <root_elem xmlns="http://my.com" ....>
> 	<level2>
> 		<level3>xyz</level3>
> 	</level2>
> </root_elem>
> ===============

Yeahbut... <level2> -does- have a namespace in this example.

The same namespace that <root_elem> has.

> but XMLOutputter is giving this:
> 
> ===============
> ===============
> <root_elem xmlns="http://my.com" ....>
> 	<level2 xmlns="">
> 		<level3>xyz</level3>
> 	</level2>
> </root_elem>
> ===============
> 
> Notice <level3> is perfectly fine without any namespace? Please tell me what I'm missing here.

Right, because <level2> and <level3> are both not in namespaces,
and semantically, that's what this document says.

Sounds like you should probably give the XML-Namespaces spec another
once over.  This is not at all a JDOM issue, but rather a namespace
comprehension issue, I believe.

	-bob




More information about the jdom-interest mailing list