-
Bug
-
Resolution: Fixed
-
P4
-
1.1
-
1.1.1
-
sparc
-
solaris_7
-
Verified
Name: inR10064 Date: 12/13/2000
JAXP 1.1 method
org.w3c.dom.NamedNodeMap.removeNamedItemNS(String namespaceURI,
String localName)
does not replace the attribute which has a default value. Instead of this it removes
the attribute from the map (See test.java below).
Definition of the method in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
(http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1780488922) reads:
" removeNamedItemNS introduced in DOM Level 2
Removes a node specified by local name and namespace URI. A removed attribute
may be known to have a default value when this map contains the attributes
attached to an element, as returned by the attributes attribute of the Node
interface. If so, an attribute immediately appears containing the default value
as well as the corresponding namespace URI, local name, and prefix when
applicable. "
This bug is found in builds jaxp-1.1ea-b07, jaxp-1.1ea-b08, jaxp-1.1ea-b09,
jaxp-1.1ea2-b10, jaxp-1.1ea2-b11, jaxp-1.1ea2-b12, jaxp-1.1ea2-b13, jaxp-1.1ea2-b14
and affects the new test in TCK JAXP 1.1
api/org_w3c_dom/NamedNodeMap/RemoveNamedItemNSTests.html#removeNamedItemNSTest006
------------------------------------test.java-----------------------------
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Element;
import org.w3c.dom.Attr;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import java.io.ByteArrayInputStream;
public class test {
public static void main(String argv[]) {
try {
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
String data =
"<?xml version=\"1.0\" ?>" +
"<!DOCTYPE test:root [" +
"<!ELEMENT test:root ANY>" +
"<!ATTLIST test:root xmlns:test CDATA #REQUIRED>" +
"<!ATTLIST test:root test:c (a|b) \"a\">" +
"]>" +
"<test:root xmlns:test=\"http://xxxx.xx/\" test:c=\"b\"/>";
ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes());
Document document = documentBuilder.parse(in);
Element root = (Element)document
.getElementsByTagNameNS("http://xxxx.xx/", "root")
.item(0);
NamedNodeMap nodeMap = root.getAttributes();
/* Map state before */
System.out.println("Before: " +
nodeMap.getNamedItemNS("http://xxxx.xx/", "c"));
/* remove an attribute from the map */
Attr attr = (Attr)nodeMap.removeNamedItemNS("http://xxxx.xx/", "c");
/* Map state after */
System.out.println("After: "
+ nodeMap.getNamedItemNS("http://xxxx.xx/", "c"));
} catch (Exception e) {
System.out.println("Unexpected exception: " + e);
}
}
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
% java -showversion -cp .:jaxp1.1ea/jaxp.jar:jaxp1.1ea/crimson.jar test
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
Before: org.apache.crimson.tree.AttributeNode@7c6768
After: null
---------------------------------------------------------------------------
======================================================================
- relates to
-
JDK-4390293 Element.removeAttributeNS() doesn't replace the attribute with default value
- Resolved