You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@apache.org on 2002/05/03 19:06:21 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/dom CoreDocumentImpl.java
lehors 02/05/03 10:06:20
Modified: java/src/org/apache/xerces/dom CoreDocumentImpl.java
Log:
allow doctype node to be inserted after doc is created.
The DOM spec was not clear on whether this is forbidden or not, but the
DOM Level 3 makes it legal
Revision Changes Path
1.15 +15 -6 xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java
Index: CoreDocumentImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- CoreDocumentImpl.java 24 Apr 2002 19:26:36 -0000 1.14
+++ CoreDocumentImpl.java 3 May 2002 17:06:20 -0000 1.15
@@ -109,7 +109,7 @@
* @author Joe Kesselman, IBM
* @author Andy Clark, IBM
* @author Ralf Pfeiffer, IBM
- * @version $Id: CoreDocumentImpl.java,v 1.14 2002/04/24 19:26:36 elena Exp $
+ * @version $Id: CoreDocumentImpl.java,v 1.15 2002/05/03 17:06:20 lehors Exp $
* @since PR-DOM-Level-1-19980818.
*/
public class CoreDocumentImpl
@@ -387,7 +387,11 @@
"DOM006 Hierarchy request error");
}
}
-
+ // Adopt orphan doctypes
+ if (newChild.getOwnerDocument() == null &&
+ newChild instanceof DocumentTypeImpl) {
+ ((DocumentTypeImpl) newChild).ownerDocument = this;
+ }
super.insertBefore(newChild,refChild);
// If insert succeeded, cache the kid appropriately
@@ -395,7 +399,7 @@
docElement = (ElementImpl)newChild;
}
else if (type == Node.DOCUMENT_TYPE_NODE) {
- docType=(DocumentTypeImpl)newChild;
+ docType = (DocumentTypeImpl)newChild;
}
return newChild;
@@ -409,8 +413,8 @@
* REVISIT: According to the spec it is not allowed to alter neither the
* document element nor the document type in any way
*/
- public Node removeChild(Node oldChild)
- throws DOMException {
+ public Node removeChild(Node oldChild) throws DOMException {
+
super.removeChild(oldChild);
// If remove succeeded, un-cache the kid appropriately
@@ -419,7 +423,7 @@
docElement = null;
}
else if (type == Node.DOCUMENT_TYPE_NODE) {
- docType=null;
+ docType = null;
}
return oldChild;
@@ -436,6 +440,11 @@
public Node replaceChild(Node newChild, Node oldChild)
throws DOMException {
+ // Adopt orphan doctypes
+ if (newChild.getOwnerDocument() == null &&
+ newChild instanceof DocumentTypeImpl) {
+ ((DocumentTypeImpl) newChild).ownerDocument = this;
+ }
super.replaceChild(newChild, oldChild);
int type = oldChild.getNodeType();
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org