[jdom-interest] XMLOutputter/SAXBuilder

Gary Bentley gb at opengroup.org
Fri Sep 14 07:02:16 PDT 2001

Thanks for that.

Do you know who I can bug for SAX?

My application doesn't choke on them it's just that I need it to not add 
them, all I'm doing is spooling the built WML out.

Thanks for the feedback.  My workaround is a bit clumsy but it works...


On Friday 14 September 2001 14:45, Brett McLaughlin wrote:
> on 9/14/01 5:35 AM, Gary Bentley at gb at opengroup.org wrote:
> > 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 behaviour.
> It's actually not JDOM at all. SAX reports default attributes on an
> element, and does not give any indication that these attributes /are/
> default. In other words, it's a "bug/feature" of SAX 2.0 itself. I don't
> know of anyway to turn that processing off, and since SAX doesn't yet
> provide any additional typing or related information about default vs.
> declared attributes, I'm not sure how we could take care of it if we wanted
> to.
> If you've got any ideas, I'm certainly all ears! However, I will point out
> that the DTD specifying these as default attributes (actually, IMPLIED),
> means that your application should /not/ choke on them, because they are
> essentially "on" the element anyway. So you may have a bigger problem, such
> as with WML documents that someone else creates.
> > 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);
> Alex Chaffee is our XMLOutputter superhero, so maybe he will comment here.
> Alex, any ideas?
> Thanks

More information about the jdom-interest mailing list