[jdom-interest] SAXBuilder.setExpandEntities

Elliotte Rusty Harold elharo at metalab.unc.edu
Thu May 16 06:12:51 PDT 2002


At 1:11 PM +0200 5/16/02, Ernst de Haan wrote:
>Hi,
>
>SAXBuilder.setExpandEntities does not work the way I expect it to. At least
>not with Xerces 1.4.4 nor with Saxon 7.1. Attached is a test program.
>
>See:
>http://jdom.org/docs/apidocs/org/jdom/input/SAXBuilder.html#setExpandEntities(boolean)
>
>When I have an XML document containing:
>
>    <a>b&amp;&#169;</a>
>
>then I want Element.getContent() to return one org.jdom.Text element and 2
>org.jdom.EntityRef objects. Is there a SAX driver that allows me to do this?
>

This is never going to happen. SAX parsers *always* expand the five 
predefined entity references including &amp; and all numeric 
character references such as &#169;. Off the top of my head, I'm not 
aware of any API which would inform you of this information. 
Furthermore, I'm willing to state that unless you're writing an 
editor (and maybe not even then) you don't need this. XML 
applications that rely on such low-levels of syntax detail are 
broken. The one that comes to mind is WML. In these cases the 
application needs to be fixed, not the API.
-- 

+-----------------------+------------------------+-------------------+
| 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