[jdom-interest] escaped character handling

Jason Hunter jhunter at collab.net
Wed Aug 22 11:31:45 PDT 2001

Jussi Koiranen wrote:
> Is it possible to tell to JDOM not to transform
> escaped character to corresponding unicode characters?
> I have in XHTML file "–" and parsed JDOM document
> contains '–' character instead of string "–".

As it should.  JDOM text contains the true String character data.  It's
decoded on input and encoded on output.

> And when I output that to file I'd like to get string "–".

This is not done by default, because for most charsets it's not needed
and it slows output significantly, but you can accomplish this by
writing an outputter with an overridden escapeElementEntities() method.

BTW, John Pang's suggestion of setExpandEntities(false) doesn't apply
for character entities.  They're always expanded, because when you think
about it there's no alternative.


More information about the jdom-interest mailing list