[jdom-interest] Entities

Todd O'Bryan toddobryan at mac.com
Wed Jul 11 10:44:45 PDT 2001


I need to parse XML in which some undefined entities are placed (okay, 
so technically it's not well-formed XML, but it's remarkably XML-like), 
and I don't want any entities (including & < and >) to be 
replaced with the values they stand for during parsing.

So, I wrote an extension to Reader that changes all & to & as it 
reads the file, thus

cliché < simile & metaphor

in a file would come out of my Reader as

cliché < simile & metaphor

When this gets parsed, the &s should get replaced by & characters, 
and the parsed document looks like the document I passed in, plus I 
don't get SAXParseExceptions about undefined entities (for example, the 
é).

The problem is that when I output the parsed document (using 
XMLOutputter), I still have &s where I want just & characters. Is 
there any way to turn off XMLOutputter's desire to replace the three 
special characters (&, >, and <) with their entity values?

Todd




More information about the jdom-interest mailing list