GetAttributeNodeNSpublic final class GetAttributeNodeNS extends DOMTestCase The "getAttributeNodeNS(namespaceURI,localName)" method retrieves an
attribute node by local name and NamespaceURI.
Retrieve the first emp:address element node. The getAttributeNodeNS method
returns an Attr node, the "value" can be examined to ensure the proper
attribute node was retrieved. This attribute value should be null since there
is no such attribute. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
Methods Summary |
---|
protected void | setUp()
super.setUp();
try {
factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
.getConfiguration2());
builder = factory.getBuilder();
} catch (Exception e) {
fail("Unexpected exception" + e.getMessage());
}
| protected void | tearDown()
factory = null;
builder = null;
super.tearDown();
| public void | testGetAttributeNodeNS1()Runs the test case.
String namespaceURI = "http://www.nist.gov";
String localName = "invalidlocalname";
Document doc;
NodeList elementList;
Element testAddr;
Attr attribute;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = (Element) elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
attribute = testAddr.getAttributeNodeNS(namespaceURI, localName);
assertNull("throw_Null", attribute);
| public void | testGetAttributeNodeNS2()
Document doc;
NodeList elementList;
Element testAddr;
Attr attribute;
String attrName;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = (Element) elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
attribute = testAddr.getAttributeNodeNS("http://www.nist.gov",
"domestic");
attrName = attribute.getNodeName();
assertEquals("attrName", "emp:domestic", attrName);
|
|