[jdom-interest] suppress empty tags

Jason Hunter jhunter at xquery.com
Wed Feb 25 16:39:23 PST 2004

Why remove elements that have no text content or child elements?  Seems 
like an odd request.  Empty elements are elements too.

XMLOutputter does not and should not have a way to selecively remove 
elements during output.  Remove them before output if you must.  Or 
subclass the builder to change its behavior.  But first think to make 
sure you really want to do that.

Perhaps you just want to write <foo></foo> as <foo/> and that can 
certainly be done because they're semantically identical.


Kilian Braune wrote:

> Hi!
> I am desperately looking for a soultion on "how to suppress empty tags" 
> while creating an XML via JDOM. For the time being I am checking for 
> each built element if its content is null and if not then build element. 
> But it would be much more "elegant" if i would have a general method for 
> this perhaps referring to the XMLOutputter.
> Do you have an idea how i could suppress empty tags easier as the way I 
> do it right now? How can I e.g. remove children tags in dependance on 
> their content resp. "no content"?
> Thanks
> K.
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com 

More information about the jdom-interest mailing list