You are viewing a plain text version of this content. The canonical link for it is here.
Posted to crimson-cvs@xml.apache.org by ed...@apache.org on 2001/04/11 04:52:37 UTC

cvs commit: xml-crimson/src/org/apache/crimson/tree ElementNode2.java

edwingo     01/04/10 19:52:37

  Modified:    src/org/apache/crimson/tree ElementNode2.java
  Log:
  Fix Element.removeAttribute() throws DOMException with undeclared code
  
  Revision  Changes    Path
  1.11      +20 -14    xml-crimson/src/org/apache/crimson/tree/ElementNode2.java
  
  Index: ElementNode2.java
  ===================================================================
  RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/ElementNode2.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ElementNode2.java	2001/04/11 02:27:56	1.10
  +++ ElementNode2.java	2001/04/11 02:52:37	1.11
  @@ -1,5 +1,5 @@
   /*
  - * $Id: ElementNode2.java,v 1.10 2001/04/11 02:27:56 edwingo Exp $
  + * $Id: ElementNode2.java,v 1.11 2001/04/11 02:52:37 edwingo Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -513,9 +513,17 @@
       {
   	if (readonly)
   	    throw new DomEx (DomEx.NO_MODIFICATION_ALLOWED_ERR);
  -	if (attributes == null)
  -	    throw new DomEx (DomEx.NOT_FOUND_ERR);
  -        attributes.removeNamedItem (name);
  +	if (attributes == null) {
  +            return;
  +        }
  +        try {
  +            attributes.removeNamedItem (name);
  +        } catch (DOMException x) {
  +            // DOM2 does not allow a NOT_FOUND_ERR exception to be thrown
  +            if (x.code != DOMException.NOT_FOUND_ERR) {
  +                throw x;
  +            }
  +        }
       }
   
       /**
  @@ -528,7 +536,14 @@
   	if (readonly) {
   	    throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR);
           }
  -        attributes.removeNamedItemNS(namespaceURI, localName);
  +        try {
  +            attributes.removeNamedItemNS(namespaceURI, localName);
  +        } catch (DOMException x) {
  +            // DOM2 does not allow a NOT_FOUND_ERR exception to be thrown
  +            if (x.code != DOMException.NOT_FOUND_ERR) {
  +                throw x;
  +            }
  +        }
       }
   
       /** <b>DOM:</b>  returns the attribute */
  @@ -570,15 +585,6 @@
   	removeAttribute (attr.getNodeName ());
   	return attr;
       }
  -
  -//     void printClone(ElementNode2 n) {
  -//         System.out.println("n=" + n);
  -//         System.out.println("n.od=" + n.getOwnerDocument());
  -//         Node n2 = n.attributes.getNamedItem("id");
  -//         System.out.println("n2.value=" + n2.getNodeValue());
  -//         System.out.println("n2.od=" + n2.getOwnerDocument());
  -//         System.out.println("n2.oe=" + ((Attr)n2).getOwnerElement());
  -//     }
   
       /**
        * Creates a new unparented node whose attributes are the same as
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: crimson-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: crimson-cvs-help@xml.apache.org