You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2003/11/13 00:38:09 UTC
DO NOT REPLY [Bug 24667] New: -
Problems with isEqualNode for DocumentType nodes.
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=24667>.
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=24667
Problems with isEqualNode for DocumentType nodes.
Summary: Problems with isEqualNode for DocumentType nodes.
Product: Xerces2-J
Version: 2.5.0
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: DOM
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: nddelima@ca.ibm.com
The DOM L3 Core method isEqualNode [1] tests whether two nodes are equal and
returns true if they are.
For two DocumentType nodes to be equal, the following conditions must also be
satisfied:
The following string attributes are equal: publicId, systemId, internalSubset.
The entities NamedNodeMaps are equal.
The notations NamedNodeMaps are equal.
For DocType nodes it appears as if Xerces simply checks the qualifiedName and
incorrectly reports true for DocType nodes that have the same qualifiedName.
See the following test case.
Test.java
=========
import java.io.ByteArrayInputStream;
import org.w3c.dom.*;
import javax.xml.parsers.*;
public class Test {
public void testIsEqual() {
String data = "<?xml version=\"1.0\"?> "
+ "<!DOCTYPE root ["
+ " <!ELEMENT root (#PCDATA)>"
+ " <!ENTITY ent 'blah'>"
+ "]>"
+ "<root>&ent;</root>";
Document doc;
Node replaced;
try {
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance ();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(new ByteArrayInputStream(data.getBytes
()));
DocumentType docType = doc.getDoctype();
String docTypeName = docType.getName();
String pubId = docType.getPublicId();
String sysId = docType.getSystemId();
DOMImplementation domImpl = doc.getImplementation();
DocumentType docType2 = domImpl.createDocumentType
(docTypeName, "bad1", "bad2");
boolean isEqual = docType.isEqualNode(docType2);
System.out.println("EXPECTED OUTPUT: " + false + "
ACTUAL OUTPUT: " + isEqual);
} catch (Exception e ) {
System.err.println ("Exception: " + e.getMessage());
e.printStackTrace();
}
}
public static void main(String[] args) {
Test test = new Test();
test.testIsEqual();
}
}
[1] http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core.html#Node3-
isEqualNode
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org