FileDocCategorySizeDatePackage
GetAttributeNodeNS.javaAPI DocAndroid 1.5 API4075Wed May 06 22:41:06 BST 2009tests.org.w3c.dom

GetAttributeNodeNS

public 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.
author
NIST
author
Mary Brady
see
http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElGetAtNodeNS

Fields Summary
DOMDocumentBuilderFactory
factory
DocumentBuilder
builder
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        try {
            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
                    .getConfiguration2());
            builder = factory.getBuilder();
        } catch (Exception e) {
            fail("Unexpected exception" + e.getMessage());
        }
    
protected voidtearDown()

        factory = null;
        builder = null;
        super.tearDown();
    
public voidtestGetAttributeNodeNS1()
Runs the test case.

throws
Throwable Any uncaught exception causes test to fail

        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 voidtestGetAttributeNodeNS2()

        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);