Bugs item #527062, was opened at 2002-03-07 09:57
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=116035&aid=527062&group_id=16035

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Incorrect entity handling.

Initial Comment:
dom4j 1.2 and Xerces 2.0+ SAXContentHandler Entity handling bug (probably StringBuffer 
reset/overwrite bug?).  Described below.  Workaround is to use DOMReader instead of 
SAXReader (performance penalty).

test.xml
---- cut here ----
<?xml version="1.0"?>
<!DOCTYPE broked [
        <!ELEMENT junk (#PCDATA)>
        <!ELEMENT broked (junk*)>
        <!ENTITY LmInclude SYSTEM "junk.xml">
]>
<broked>
        &LmInclude;
</broked>
---- cut here ----

junk.xml
---- cut here ----
<junk>hi there</junk><junk>hello world</junk>
---- cut here ----


Java code (main())
--

SAXReader reader = new SAXReader();
reader.setValidation(true);
Document doc = reader.read(args[0]);
List l = doc.selectNodes("//broked/junk");
for (int i = 0; i < l.size(); i++) {
    System.out.println("Found node: " +
        ((Element)l.get(i)).getStringValue());
}

--

Correct output
--
unixPrompt> java test.Broked test.xml
Found node: hi there
Found node: hello world
--

Incorrect (and current, as of dom4j 1.2) output:
--
unixPrompt> java test.Broked test.xml
Found node: &LmInclude; there
Found node: hello world
--

Thanks.



----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=116035&aid=527062&group_id=16035

_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to