665 qualifiedName);
666 if (attributes == null) {
667 attributes = new AttributeMap(this, null);
668 }
669 newAttr.setNodeValue(value);
670 attributes.setNamedItemNS(newAttr);
671 }
672 else {
673 if (newAttr instanceof AttrNSImpl){
674 String origNodeName = ((AttrNSImpl) newAttr).name;
675 String newName = (prefix!=null) ? (prefix+":"+localName) : localName;
676
677 ((AttrNSImpl) newAttr).name = newName;
678
679 if (!newName.equals(origNodeName)) {
680 // Note: we can't just change the name of the attribute. Names have to be in sorted
681 // order in the attributes vector because a binary search is used to locate them.
682 // If the new name has a different prefix, the list may become unsorted.
683 // Maybe it would be better to resort the list, but the simplest
684 // fix seems to be to remove the old attribute and re-insert it.
685 // -- Norman.Walsh@Sun.COM, 2 Feb 2007
686 newAttr = (Attr) attributes.removeItem(newAttr, false);
687 attributes.addItem(newAttr);
688 }
689 }
690 else {
691 // This case may happen if user calls:
692 // elem.setAttribute("name", "value");
693 // elem.setAttributeNS(null, "name", "value");
694 // This case is not defined by the DOM spec, we choose
695 // to create a new attribute in this case and remove an old one from the tree
696 // note this might cause events to be propagated or user data to be lost
697 newAttr = new AttrNSImpl((CoreDocumentImpl)getOwnerDocument(), namespaceURI, qualifiedName, localName);
698 attributes.setNamedItemNS(newAttr);
699 }
700
701 newAttr.setNodeValue(value);
702 }
703
704 } // setAttributeNS(String,String,String)
705
|
665 qualifiedName);
666 if (attributes == null) {
667 attributes = new AttributeMap(this, null);
668 }
669 newAttr.setNodeValue(value);
670 attributes.setNamedItemNS(newAttr);
671 }
672 else {
673 if (newAttr instanceof AttrNSImpl){
674 String origNodeName = ((AttrNSImpl) newAttr).name;
675 String newName = (prefix!=null) ? (prefix+":"+localName) : localName;
676
677 ((AttrNSImpl) newAttr).name = newName;
678
679 if (!newName.equals(origNodeName)) {
680 // Note: we can't just change the name of the attribute. Names have to be in sorted
681 // order in the attributes vector because a binary search is used to locate them.
682 // If the new name has a different prefix, the list may become unsorted.
683 // Maybe it would be better to resort the list, but the simplest
684 // fix seems to be to remove the old attribute and re-insert it.
685 newAttr = (Attr) attributes.removeItem(newAttr, false);
686 attributes.addItem(newAttr);
687 }
688 }
689 else {
690 // This case may happen if user calls:
691 // elem.setAttribute("name", "value");
692 // elem.setAttributeNS(null, "name", "value");
693 // This case is not defined by the DOM spec, we choose
694 // to create a new attribute in this case and remove an old one from the tree
695 // note this might cause events to be propagated or user data to be lost
696 newAttr = new AttrNSImpl((CoreDocumentImpl)getOwnerDocument(), namespaceURI, qualifiedName, localName);
697 attributes.setNamedItemNS(newAttr);
698 }
699
700 newAttr.setNodeValue(value);
701 }
702
703 } // setAttributeNS(String,String,String)
704
|