elena 2003/01/29 12:04:17 Modified: java/src/org/apache/xerces/dom AttributeMap.java Log: while adding default attribute from the DTD back (after removal) we must also copy a namespace from the attribute we are trying to remove. Revision Changes Path 1.24 +19 -14 xml-xerces/java/src/org/apache/xerces/dom/AttributeMap.java Index: AttributeMap.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttributeMap.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- AttributeMap.java 29 Aug 2002 18:34:58 -0000 1.23 +++ AttributeMap.java 29 Jan 2003 20:04:17 -0000 1.24 @@ -334,23 +334,30 @@ if (hasDefaults() && addDefault) { // If there's a default, add it instead - NamedNodeMapImpl defaults = ((ElementImpl) ownerNode).getDefaultAttributes(); + Node d; if (defaults != null && (d = defaults.getNamedItem(name)) != null && findNamePoint(name, index+1) < 0) { - - NodeImpl clone = (NodeImpl)d.cloneNode(true); - clone.ownerNode = ownerNode; - clone.isOwned(true); - clone.isSpecified(false); - nodes.setElementAt(clone, index); - if (attr.isIdAttribute()) { - ownerDocument.putIdentifier(clone.getNodeValue(), + NodeImpl clone = (NodeImpl)d.cloneNode(true); + if (d.getLocalName() !=null){ + // we must rely on the name to find a default attribute + // ("test:attr"), but while copying it from the DOCTYPE + // we should not loose namespace URI that was assigned + // to the attribute in the instance document. + ((AttrNSImpl)clone).namespaceURI = attr.getNamespaceURI(); + } + clone.ownerNode = ownerNode; + clone.isOwned(true); + clone.isSpecified(false); + + nodes.setElementAt(clone, index); + if (attr.isIdAttribute()) { + ownerDocument.putIdentifier(clone.getNodeValue(), (ElementImpl)ownerNode); - } + } } else { nodes.removeElementAt(index); } @@ -444,9 +451,7 @@ if (j>=0 && findNamePoint(nodeName, j+1) < 0) { NodeImpl clone = (NodeImpl)d.cloneNode(true); clone.ownerNode = ownerNode; - // REVISIT: can we assume that if we reach here it is - // always attrNSImpl - if (clone instanceof AttrNSImpl) { + if (d.getLocalName() != null) { // we must rely on the name to find a default attribute // ("test:attr"), but while copying it from the DOCTYPE // we should not loose namespace URI that was assigned
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]