removeNamedItemNS03public final class removeNamedItemNS03 extends org.w3c.domts.DOMTestCase The "removeNamedItemNS(namespaceURI,localName)" method for a
NamedNodeMap should raise NO_MODIFICATION_ALLOWED_ERR DOMException if
this map is readonly.
Retrieve a list of "gender" elements. Get access to the THIRD element
which contains an ENTITY_REFERENCE child node. Try to remove the attribute
in the node's map with method removeNamedItemNS(namespaceURI,localName).
This should result in NO_MODIFICATION_ALLOWED_ERR
DOMException. |
Constructors Summary |
---|
public removeNamedItemNS03(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
org.w3c.domts.DocumentBuilderSetting[] settings =
new org.w3c.domts.DocumentBuilderSetting[] {
org.w3c.domts.DocumentBuilderSetting.namespaceAware
};
DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
setFactory(testFactory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staffNS", true);
|
Methods Summary |
---|
public java.lang.String | getTargetURI()Gets URI that identifies the test.
return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/removeNamedItemNS03";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(removeNamedItemNS03.class, args);
| public void | runTest()Runs the test case.
String namespaceURI = "http://www.w3.org/2000/xmlns/";
String localName = "local1";
Document doc;
NodeList elementList;
Node testAddress;
NodeList nList;
Node child;
NodeList n2List;
Node child2;
NamedNodeMap attributes;
Node removedNode;
int nodeType;
doc = (Document) load("staffNS", true);
elementList = doc.getElementsByTagName("gender");
testAddress = elementList.item(2);
nList = testAddress.getChildNodes();
child = nList.item(0);
nodeType = (int) child.getNodeType();
if (equals(1, nodeType)) {
child = doc.createEntityReference("ent4");
assertNotNull("createdEntRefNotNull", child);
}
n2List = child.getChildNodes();
child2 = n2List.item(0);
assertNotNull("notnull", child2);
attributes = child2.getAttributes();
{
boolean success = false;
try {
removedNode = attributes.removeNamedItemNS(namespaceURI, localName);
} catch (DOMException ex) {
success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success);
}
|
|