[jdom-interest] XMLOutputter and empty elements

Brett McLaughlin brett.mclaughlin at lutris.com
Wed Sep 13 19:57:30 PDT 2000


Wow. This was such a good and simple suggestion that I put it into CVS
right now. Get the latest version, Nick, and do this:

XMLOutputter outputter = new XMLOutputter();
outputter.setExpandEmptyElements(true);
outputter.output(myDoc);

Now aren't I a nice guy ;-)

Thanks,
Brett

Nick Crossley wrote:
> 
> For various reasons (post processing by other tools that are not proper XML
> parsers),
> I need to have empty elements in my XML shown as <TAG></TAG> and not as
> <TAG/>.
> 
> I am doing this by extending from XMLOutputter, and redefining printElement.
> However, with the current structure of printElement, I have to repeat a lot
> of code
> I really do not want to know about, in the handling of name spaces.
> 
> It would be convenient if there was an option not to abbreviate empty
> elements,
> or if printElement was restructured to make subclassing more convenient.
> 
> Nick Crossley.
> ndjc at continuus.com
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list