elementremoveattributepublic final class elementremoveattribute extends org.w3c.domts.DOMTestCase The "removeAttribute(name)" removes an attribute by name.
If the attribute has a default value, it is immediately
replaced.
Retrieve the attribute named "street" from the last child
of the fourth employee, then remove the "street"
attribute by invoking the "removeAttribute(name)" method.
The "street" attribute has a default value defined in the
DTD file, that value should immediately replace the old
value. |
Constructors Summary |
---|
public elementremoveattribute(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
org.w3c.domts.DocumentBuilderSetting[] settings =
new org.w3c.domts.DocumentBuilderSetting[] {
org.w3c.domts.DocumentBuilderSetting.validating
};
DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
setFactory(testFactory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staff", true);
|
Methods Summary |
---|
public java.lang.String | getTargetURI()Gets URI that identifies the test.
return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattribute";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(elementremoveattribute.class, args);
| public void | runTest()Runs the test case.
Document doc;
NodeList elementList;
Element testEmployee;
String attrValue;
doc = (Document) load("staff", true);
elementList = doc.getElementsByTagName("address");
testEmployee = (Element) elementList.item(3);
testEmployee.removeAttribute("street");
attrValue = testEmployee.getAttribute("street");
assertEquals("streetYes", "Yes", attrValue);
|
|