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:27:56 UTC

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

edwingo     01/04/10 19:27:56

  Modified:    src/org/apache/crimson/tree ElementNode2.java
                        ElementNode.java AttributeNode1.java
                        AttributeNode.java
  Log:
  Fix localName is not null for clone of Element/Attr object created by DOM1
  methods
  
  Revision  Changes    Path
  1.10      +23 -15    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ElementNode2.java	2001/03/20 20:17:01	1.9
  +++ ElementNode2.java	2001/04/11 02:27:56	1.10
  @@ -1,5 +1,5 @@
   /*
  - * $Id: ElementNode2.java,v 1.9 2001/03/20 20:17:01 edwingo Exp $
  + * $Id: ElementNode2.java,v 1.10 2001/04/11 02:27:56 edwingo Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -106,7 +106,7 @@
    */
   public class ElementNode2 extends NamespacedNode implements ElementEx
   {
  -    private AttributeSet	attributes;
  +    protected AttributeSet	attributes;
       private String		idAttributeName;
       private Object		userObject;
   
  @@ -120,17 +120,18 @@
       }
   
       /**
  -     * Constructor used for cloneNode()
  +     * Make a clone of this node and return it.  Used for cloneNode().
        */
  -    private ElementNode2(ElementNode2 original) {
  -        super(original.namespaceURI, original.qName);
  -        if (original.attributes != null) {
  -            attributes = new AttributeSet(original.attributes, true);
  -            attributes.setOwnerElement(this);
  -        }
  -        idAttributeName = original.idAttributeName;
  -        userObject = original.userObject;
  -        ownerDocument = original.ownerDocument;
  +    ElementNode2 makeClone() {
  +        ElementNode2 retval = new ElementNode2(namespaceURI, qName);
  +        if (attributes != null) {
  +            retval.attributes = new AttributeSet(attributes, true);
  +            retval.attributes.setOwnerElement(retval);
  +        }
  +        retval.idAttributeName = idAttributeName;
  +        retval.userObject = userObject;
  +        retval.ownerDocument = ownerDocument;
  +        return retval;
       }
   
       /**
  @@ -570,6 +571,15 @@
   	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
        * this node's attributes; if <em>deep</em> is true, the children
  @@ -578,9 +588,7 @@
       public Node cloneNode (boolean deep)
       {
   	try {
  -	    ElementNode2 retval;
  -
  -            retval = new ElementNode2(this);
  +	    ElementNode2 retval = makeClone();
   	    if (deep) {
   		for (int i = 0; true; i++) {
   		    Node	node = item (i);
  
  
  
  1.8       +16 -1     xml-crimson/src/org/apache/crimson/tree/ElementNode.java
  
  Index: ElementNode.java
  ===================================================================
  RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/ElementNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ElementNode.java	2001/02/24 03:23:47	1.7
  +++ ElementNode.java	2001/04/11 02:27:56	1.8
  @@ -1,5 +1,5 @@
   /*
  - * $Id: ElementNode.java,v 1.7 2001/02/24 03:23:47 edwingo Exp $
  + * $Id: ElementNode.java,v 1.8 2001/04/11 02:27:56 edwingo Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -82,6 +82,21 @@
        */
       public ElementNode(String name) {
           super(null, name);
  +    }
  +
  +    /**
  +     * Make a clone of this node and return it.  Used for cloneNode().
  +     */
  +    ElementNode2 makeClone() {
  +        ElementNode2 retval = new ElementNode(qName);
  +        if (attributes != null) {
  +            retval.attributes = new AttributeSet(attributes, true);
  +            retval.attributes.setOwnerElement(this);
  +        }
  +        retval.setIdAttributeName(getIdAttributeName());
  +        retval.setUserObject(getUserObject());
  +        retval.ownerDocument = ownerDocument;
  +        return retval;
       }
   
       /**
  
  
  
  1.2       +12 -1     xml-crimson/src/org/apache/crimson/tree/AttributeNode1.java
  
  Index: AttributeNode1.java
  ===================================================================
  RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/AttributeNode1.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributeNode1.java	2001/02/24 03:23:48	1.1
  +++ AttributeNode1.java	2001/04/11 02:27:56	1.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: AttributeNode1.java,v 1.1 2001/02/24 03:23:48 edwingo Exp $
  + * $Id: AttributeNode1.java,v 1.2 2001/04/11 02:27:56 edwingo Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -67,6 +67,17 @@
                             String defaultValue)
       {
           super(null, name, value, specified, defaultValue);
  +    }
  +
  +    /**
  +     * Make a clone of this node and return it.  Used for cloneNode().
  +     */
  +    AttributeNode makeClone() {
  +        AttributeNode retval = new AttributeNode1(qName, getValue(),
  +                                                  getSpecified(),
  +                                                  getDefaultValue());
  +        retval.ownerDocument = ownerDocument;
  +        return retval;
       }
   
       /**
  
  
  
  1.11      +11 -8     xml-crimson/src/org/apache/crimson/tree/AttributeNode.java
  
  Index: AttributeNode.java
  ===================================================================
  RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/AttributeNode.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AttributeNode.java	2001/03/16 21:54:54	1.10
  +++ AttributeNode.java	2001/04/11 02:27:56	1.11
  @@ -1,5 +1,5 @@
   /*
  - * $Id: AttributeNode.java,v 1.10 2001/03/16 21:54:54 edwingo Exp $
  + * $Id: AttributeNode.java,v 1.11 2001/04/11 02:27:56 edwingo Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -100,7 +100,7 @@
    *
    * @author David Brownell
    * @author Rajiv Mordani
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    */
   public class AttributeNode extends NamespacedNode implements Attr
   {
  @@ -123,11 +123,14 @@
           this.defaultValue = defaultValue;
       }
   
  -    // Used for cloneNode()
  -    private AttributeNode(AttributeNode original) {
  -        this(original.namespaceURI, original.qName,
  -             original.value, original.specified, original.defaultValue);
  -        ownerDocument = original.ownerDocument;
  +    /**
  +     * Make a clone of this node and return it.  Used for cloneNode().
  +     */
  +    AttributeNode makeClone() {
  +        AttributeNode retval = new AttributeNode(namespaceURI, qName, value,
  +                                                 specified, defaultValue);
  +        retval.ownerDocument = ownerDocument;
  +        return retval;
       }
   
       /**
  @@ -295,7 +298,7 @@
        */
       AttributeNode cloneAttributeNode(boolean deep) {
           try {
  -            AttributeNode attr = new AttributeNode(this);
  +            AttributeNode attr = makeClone();
               if (deep) {
                   Node node;
                   for (int i = 0; (node = item (i)) != null; i++) {
  
  
  

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