[jdom-interest] escape characters

Jason Hunter jhunter at acm.org
Thu Jul 26 16:09:23 PDT 2001


"Baum, Karl" wrote:
> 
> I have a program that loads information for a database and outputs to an xml
> file using jdom.  The code looks to filter certain characters and replaces
> them with their escape character equivalence.  For example, the character
> with a code of 162 is replaced with &#162.  However when I output to an xml
> file using jdom, this is represented as &#162.  Instead of coming up as
> a cent sign in html, it looks like &#162.  Is there a way I can tell jdom
> not to replace the &#162 with &#162.  Thanks.
> 
> Karl

You have full control over entity escape behavior by subclassing
XMLOutputter (check the code, it's easy to follow).  But before you make
any custom changes, you should know that JDOM is doing the right thing
here.  Your text string in memory is "&#162" so when you output that
string JDOM needs to escape the ampersand to keep the text string
correct on the next read.  The right fix here is to skip the escaping on
input.

-jh-





More information about the jdom-interest mailing list