[jdom-interest] SAXBuilder.setExpandEntities

Elliotte Rusty Harold elharo at metalab.unc.edu
Thu May 16 07:14:53 PDT 2002


At 3:44 PM +0200 5/16/02, Ernst de Haan wrote:

>Problem is that when the document is stored, the character entities have been
>interpreted by JDOM and are replaced with '?' question marks in the file. So
>we never get back what we originally sent. All character entities are
>replaced by question marks. Pehaps special characters should be replaced by
>character entities by the XMLOutputter then?
>

Indeed they should be. If that's not happening then it's a bug. It 
could well be a bug in JDOM, but it's also possible it's a bug in 
your code. In particular if you're using a Writer for the output 
rather than an OutputStream, JDOM can't figure out which characters 
it needs to escape because there's no way to determine the underlying 
encoding of the Writer.

In the past, I've occasionally argued for removing the output(Writer, 
...) methods from XMLOutputter for precisely this reason, but Jason's 
always had a use case to stop me. Generally that was that servlets 
only provided writers, not output streams. However, I think that's 
changed in more recent versions of the Servlet API. ServletResponse 
now does have a getOutputStream() method.

Jason, you're our resident servlet guru. Can we now consider getting 
rid of the XMLOutputter(Writer, ...) methods, or is there something 
I'm forgetting?
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list