[jdom-interest] Character reference representation

Jason Hunter jhunter at apache.org
Thu Dec 20 11:35:04 PST 2001


> This is fine for an app to interpret, but for a person its not clear
> just from looking at the doc which whitespace is relevant and which 
> isn't.

Even though your char entity helps a person reading the text file know,
when a person receives the XML programmatically (using SAX, DOM, or
JDOM) they won't be able to tell because that char entity would be
converted to a normal \n.  So you may want to rethink your model for
indicating what whitespace is important, and use xml:space or some such
indicator instead.

> Is there any straightforward way to force such chars to be 
> represented by their escaped character reference form, i.e. 
> force it to write 
 on output?

The model is to subclass XMLOutputter and override the methods that are
responsible for the escaping.  Of course, you'll have a hard time
knowing which newlines to escape, because the SAX parser converts the
char entity to its \n char on read, so JDOM never sees the entity and it
will look like any other newline.

-jh-



More information about the jdom-interest mailing list