DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25346>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25346 DOM normalizer expands entity references incorrectly Summary: DOM normalizer expands entity references incorrectly Product: Xerces2-J Version: 2.6.0 Platform: Sun OS/Version: Solaris Status: NEW Severity: Normal Priority: Other Component: DOM AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] When the DOMConfiguration parameter 'entities' is set to false, the method org.w3c.dom.Document.normalizeDocument() removes an EntityReference to an Entity that is defined in the document type, but does not put its expansion to the document. The method description on the case, when the parameter 'entities' is set to false, reads: "Remove all EntityReference and Entity nodes from the document, putting the entity expansions directly in their place." So in the test below, the entity reference to the entity 'x' should be changed to its expansion text 'X', but the entity reference is just detached from the parent. To reproduce the bug place test.java and test.xml to your current directory, then compile and run test.java as shown in the log below: ------------------------------ import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.TestCase; import junit.textui.TestRunner; import org.apache.xerces.dom.DocumentImpl; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Bug extends TestCase { public Bug(String name) { super(name); } public static void main(String [] args) { TestRunner.run(Bug.class); } public void test1() throws Exception { DocumentImpl doc = (DocumentImpl)DocumentBuilderFactory.newInstance() .newDocumentBuilder().parse(Bug.class.getResource("test.xml").toExternalForm()); Element root = doc.getDocumentElement(); // add a new reference. The parser is allowed to expand the existing reference // in the document while parsing. root.appendChild(doc.createEntityReference("x")); doc.getDomConfig().setParameter("entities", Boolean.FALSE); doc.normalizeDocument(); Node child = root.getFirstChild(); assertNotNull(child); assertEquals( Node.TEXT_NODE, child.getNodeType() ); assertEquals("XX",child.getNodeValue()); } } ---------------------------------------------------- ------------------------------------------- test.xml <?xml version="1.0"?> <!DOCTYPE root [ <!ELEMENT root ANY> <!ENTITY x 'X'> ]> <root>&x;</root> ---------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
