mrglavas    2004/03/03 11:28:00

  Modified:    java/src/org/apache/xerces/dom CoreDocumentImpl.java
  Log:
  Fixing Bug #26994:

  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26994

  

  If a replace operation on a Document node would result

  in multiple DocumentType or document elements existing

  in the DOM a HEIRARCHY_REQUEST_ERR must be raised.

  

  Fixed thanks to the modified patch from Curt Arnold

  which was reviewed and fixed up by Naela Nissar.
  
  Revision  Changes    Path
  1.67      +13 -1     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.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- CoreDocumentImpl.java     2 Mar 2004 21:57:34 -0000       1.66
  +++ CoreDocumentImpl.java     3 Mar 2004 19:28:00 -0000       1.67
  @@ -434,6 +434,18 @@
           newChild instanceof DocumentTypeImpl) {
               ((DocumentTypeImpl) newChild).ownerDocument = this;
           }
  +
  +        if ((docType != null &&
  +            oldChild.getNodeType() != Node.DOCUMENT_TYPE_NODE && 
  +            newChild.getNodeType() == Node.DOCUMENT_TYPE_NODE) 
  +            || (docElement != null && 
  +            oldChild.getNodeType() != Node.ELEMENT_NODE && 
  +            newChild.getNodeType() == Node.ELEMENT_NODE)) {
  +             
  +            throw new DOMException(
  +                DOMException.HIERARCHY_REQUEST_ERR,
  +                DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"HIERARCHY_REQUEST_ERR", null));
  +        }
           super.replaceChild(newChild, oldChild);
   
           int type = oldChild.getNodeType();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to