[jdom-interest] XMLOutputter/SAXBuilder

Gary Bentley gb at opengroup.org
Fri Sep 14 03:35:48 PDT 2001

Right here's my problem folks,

I am dynamically building a chunk of WML and then getting a combination of 
SAXBuilder and XMLOutputter to format the string of WML for me.  This saves 
me a lot of time and lets me not have to worry about the format of the intput 

Now the problem:

If I pass this chunk of WML to SAXBuilder and then XMLOutputter (via a 
StringReader and StringWriter combination)

<?xml version="1.0"?>
<card newcontext="true" id="main">
<onevent type="onenterforward">
<go href="#card1"/>

Then what I actually get at the end of it is this:

<?xml version="1.0" encoding="UTF-8"?>
  <card newcontext="true" id="main" ordered="true">
    <onevent type="onenterforward">
      <go href="#card1" method="get" sendreferer="false" 
enctype="application/x-www-form-urlencoded" />

Now there are a few problems here, the main one (and I consider this either a 
major bug or undocumented feature...take your pick) is that either SAXBuilder 
(my current No 1 suspect and I haven't had chance to do a full investigation) 
or XMLOutputter is adding in attributes to various elements, for example the 
<card> element now has an "ordered" attribute that I certainly didn't ask 
for, and the <go> element has the "sendreferer", "method" and "enctype" 
attributes added.  It appears to be applying default attributes that are 
specified in the DTD.  My suspicion is that one of the classes is examining 
the DTD and being "clever", which is nice, but not the documented or required 

If this is a bug can it please be fixed, if it's not then can it please be 
"switchable" so that I can turn it off, the application I am building needs 
to be able to specify ALL the WML, not have it interpreted for me.

A further problem is that there seems to be a newline added after the <go> 
element and the end of the <onevent> element.  I know for there are no 
newlines present in the string prior to conversion since I strip them with:

	wml = wml.replace ('\n', ' ');

And then use:

	XMLOutputter xout = new XMLOutputter ();

	xout.setIndent ("  ");
	xout.setNewLines (true);
	xout.setTextNormalize (true);

Any ideas anyone...



More information about the jdom-interest mailing list