-
Bug
-
Resolution: Fixed
-
P4
-
1.1
-
1.1fcs
-
sparc
-
solaris_7
Name: inR10064 Date: 11/17/2000
JAXP 1.1 method
org.w3c.dom.Element.removeAttributeNS(String namespaceURI, String localName)
does not replace the attribute which has a default value. Instead of this it removes
the attribute (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-745549614) says:
" removeAttributeNS introduced in DOM Level 2
Removes an attribute by local name and namespace URI. If the removed
attribute has a default value it is immediately replaced. "
This bug presents in build jaxp-1.1ea2-b10-03_nov_2000
and affects the new test in TCK JAXP 1.1
api/org_w3c_dom/Element/RemoveAttributeNSTests.html#removeAttributeNSTest002
------------------------------------test.java-----------------------------
import org.w3c.dom.Document;
import org.w3c.dom.Element;
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\">" +
"</test:root>";
ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes());
Document document = documentBuilder.parse(in);
Element element = (Element)document
.getElementsByTagNameNS("http://xxxx.xx/", "root")
.item(0);
System.out.println("Before: " +
element.getAttributeNS("http://xxxx.xx/", "c"));
element.removeAttributeNS("http://xxxx.xx/", "c");
System.out.println("After: " +
element.getAttributeNS("http://xxxx.xx/", "c"));
} catch (Exception e) {
System.out.println("Unexpected " + e + " was thrown");
}
}
}
---------------------------------------------------------------------------
---------------------------------------------------------------------------
% java -cp .:jaxp1.1/jaxp.jar:jaxp1.1/crimson.jar test
Before: b
After:
---------------------------------------------------------------------------
======================================================================
- relates to
-
JDK-4397614 NamedNodeMap.removeNamedItemNS() doesn't replace an attribute with default value
-
- Closed
-