mrglavas    2004/11/04 13:40:35

  Modified:    java/src/org/apache/xerces/dom NamedNodeMapImpl.java
  Log:
  DOM Level 3 specifies an attribute called strictErrorChecking [1] which when set to 
false
  allows an implementation to not test every possible error case. Reducing the amount
  of checking performed when strictErrorChecking is false. This patch is thanks to
  Naela Nissar.
  
  [1] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Document3-strictErrorChecking
  
  Revision  Changes    Path
  1.38      +45 -39    xml-xerces/java/src/org/apache/xerces/dom/NamedNodeMapImpl.java
  
  Index: NamedNodeMapImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/NamedNodeMapImpl.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- NamedNodeMapImpl.java     5 Oct 2004 17:12:49 -0000       1.37
  +++ NamedNodeMapImpl.java     4 Nov 2004 21:40:35 -0000       1.38
  @@ -167,31 +167,34 @@
        * @exception org.w3c.dom.DOMException The exception description.
        */
       public Node setNamedItem(Node arg)
  -        throws DOMException {
  -
  -     if (isReadOnly()) {
  -            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
  -        }
  -     if (arg.getOwnerDocument() != ownerNode.ownerDocument()) {
  -            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  -            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
  +    throws DOMException {
  +        
  +        CoreDocumentImpl ownerDocument = ownerNode.ownerDocument();
  +        if (ownerDocument.errorChecking) {
  +            if (isReadOnly()) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +                throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
msg);
  +            }
  +            if (arg.getOwnerDocument() != ownerDocument) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +                throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
  +            }
           }
  -
  -     int i = findNamePoint(arg.getNodeName(),0);
  -     NodeImpl previous = null;
  -     if (i >= 0) {
  +        
  +        int i = findNamePoint(arg.getNodeName(),0);
  +        NodeImpl previous = null;
  +        if (i >= 0) {
               previous = (NodeImpl) nodes.elementAt(i);
               nodes.setElementAt(arg,i);
  -     } else {
  +        } else {
               i = -1 - i; // Insert point (may be end of list)
               if (null == nodes) {
                   nodes = new Vector(5, 10);
               }
               nodes.insertElementAt(arg, i);
           }
  -     return previous;
  -
  +        return previous;
  +        
       } // setNamedItem(Node):Node
   
       /**
  @@ -206,28 +209,31 @@
        *      one.
        */
       public Node setNamedItemNS(Node arg)
  -        throws DOMException {
  -
  -     if (isReadOnly()) {
  -            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
  -        }
  -    
  -     if(arg.getOwnerDocument() != ownerNode.ownerDocument()) {
  -            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  -            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
  +    throws DOMException {
  +        
  +        CoreDocumentImpl ownerDocument = ownerNode.ownerDocument();
  +        if (ownerDocument.errorChecking) {
  +            if (isReadOnly()) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +                throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
msg);
  +            }
  +            
  +            if(arg.getOwnerDocument() != ownerDocument) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +                throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
  +            }
           }
  -
  -     int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
  -     NodeImpl previous = null;
  -     if (i >= 0) {
  +        
  +        int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
  +        NodeImpl previous = null;
  +        if (i >= 0) {
               previous = (NodeImpl) nodes.elementAt(i);
               nodes.setElementAt(arg,i);
  -     } else {
  -         // If we can't find by namespaceURI, localName, then we find by
  -         // nodeName so we know where to insert.
  -         i = findNamePoint(arg.getNodeName(),0);
  -            if (i >=0) {
  +        } else {
  +            // If we can't find by namespaceURI, localName, then we find by
  +            // nodeName so we know where to insert.
  +            i = findNamePoint(arg.getNodeName(),0);
  +            if (i >= 0) {
                   previous = (NodeImpl) nodes.elementAt(i);
                   nodes.insertElementAt(arg,i);
               } else {
  @@ -238,9 +244,9 @@
                   nodes.insertElementAt(arg, i);
               }
           }
  -     return previous;
  -
  -    } // setNamedItem(Node):Node
  +        return previous;
  +        
  +    } // setNamedItemNS(Node):Node
      
       /**
        * Removes a node specified by name.
  
  
  

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

Reply via email to