[jdom-interest] SAXBuilder.setExpandEntities

Ernst de Haan ernsth at nl.euro.net
Thu May 16 04:11:37 PDT 2002


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?

You can use the Ant build file to test this. The output on my system:


ernst at zaphod$ ant
Buildfile: build.xml

init:
     [echo] Expecting jdom.jar at /home/ernst/jdom-b8/build/jdom.jar
     [echo] Expecting xerces.jar at /home/ernst/xerces-1_4_4/xerces.jar
     [echo] Expecting saxon.jar at /home/ernst/saxon/saxon7.jar

compile:
    [javac] Compiling 1 source file to /usr/home/ernst/EntityTest

run:
     [java] >> Loading SAX2 driver org.apache.xerces.parsers.SAXParser... DONE
     [java] >> Testing org.apache.xerces.parsers.SAXParser(false):  FAILED
     [java]    Contents of the root element:
     [java]    0: org.jdom.Text
     [java]
     [java] >> Testing org.apache.xerces.parsers.SAXParser(true):  FAILED
     [java]    Contents of the root element:
     [java]    0: org.jdom.Text
     [java]
     [java] >> Loading SAX2 driver net.sf.saxon.aelfred.SAXDriver... DONE
     [java] >> Testing net.sf.saxon.aelfred.SAXDriver(false):  FAILED
     [java]    Contents of the root element:
     [java]    0: org.jdom.Text
     [java]
     [java] >> Testing net.sf.saxon.aelfred.SAXDriver(true):  FAILED
     [java]    Contents of the root element:
     [java]    0: org.jdom.Text
     [java]

BUILD SUCCESSFUL

Total time: 3 seconds
ernst at zaphod$



Ernst

-- 
Ernst de Haan
EuroNet Internet B.V.

    "Come to me all who are weary and burdened
        and I will give you rest" -- Jesus Christ

-------------- next part --------------
A non-text attachment was scrubbed...
Name: EntityTest.java
Type: text/x-java
Size: 2026 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20020516/07f7aa1f/EntityTest.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.xml
Type: text/xml
Size: 857 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20020516/07f7aa1f/build.xml


More information about the jdom-interest mailing list