[jdom-interest] Problems outputting HTML

Robert Taylor rtaylor at mulework.com
Tue Apr 27 12:56:12 PDT 2004


Greetings, I'm trying to use Outputter to output the contents of an Document
as a string so I can populate the body of an email message and am running into 
some frustrations.

The problems stem from the fact that I have the following code which imports
Javascript functions.

<script language="JavaScript" src="http://www.newatlanta.com/shared/us.js"></script>

Although the body of this tag is empty, it is expanded because, if it is not, then
some browsers won't import the script library.

I also use <br/> in various places for formatting reasons. 

I must adjust the format (Explicitely set the Format for the XMLOutputter) 
of the document so it won't output the declaration. (Yes, I also have the
<xsl:output method="html"/> set in the XSL document)

It appears that unless I set expandEmptyElements(true), then XMLOutputter
will collapse empty elements (although this is not stated in the Javadocs).
(It seems like there should be an collapseEmptyElements(boolean flag) since
<tag></tag> is still well-formed XML..)

Not a problem...until <br/> tags are expanded. The browser interprets both
<br> and <br/> as line breaks!

One solutions was proposed over a year ago (sublass XMLOutputter and implement an HTMLOutputter...)
http://www.servlets.com/archive/servlet/ReadMsg?msgId=335507&listName=jdom-interest

Is this still the case? Are there any other solutions?

robert



More information about the jdom-interest mailing list