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

DocumentGetElementsByTagnameNS

public final class DocumentGetElementsByTagnameNS extends DOMTestCase
The method getElementsByTagNameNS returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree. Invoke the getElementsByTagNameNS method on a new Document object with the values of namespaceURI=* and localName=*. This should return a nodeList of 1 item.
author
IBM
author
Neil Delima
see
http://www.w3.org/TR/DOM-Level-2-Core/core
see
http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS
see
http://www.w3.org/Bugs/Public/show_bug.cgi?id=259

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 voidtestGetElementsByTagNameNS1()
Runs the test case.

throws
Throwable Any uncaught exception causes test to fail

        Document doc;
        Document newDoc;
        DocumentType docType = null;

        DOMImplementation domImpl;
        NodeList childList;
        String nullNS = null;

        doc = (Document) load("staffNS", builder);
        domImpl = doc.getImplementation();
        newDoc = domImpl.createDocument(nullNS, "root", docType);
        childList = newDoc.getElementsByTagNameNS("*", "*");
        assertEquals("documentgetelementsbytagnameNS01", 1, childList
                .getLength());
    
public voidtestGetElementsByTagNameNS2()

        Document doc;
        Element docElem;
        Element element;
        NodeList childList;
        
        doc = (Document) load("staffNS", builder);
        docElem = doc.getDocumentElement();
        element = doc.createElementNS("test", "employeeId");
        docElem.appendChild(element);
        childList = doc.getElementsByTagNameNS("*", "employeeId");
        assertEquals("documentgetelementsbytagnameNS02", 6, childList
                .getLength());
    
public voidtestGetElementsByTagNameNS3()

        Document doc;
        NodeList childList;
        doc = (Document) load("staffNS", builder);
        childList = doc.getElementsByTagNameNS("**", "*");
        assertEquals("documentgetelementsbytagnameNS03", 0, childList
                .getLength());
    
public voidtestGetElementsByTagNameNS4()

        Document doc;
        NodeList childList;
        String nullNS = null;

        doc = (Document) load("staffNS", builder);
        childList = doc.getElementsByTagNameNS(nullNS, "0");
        assertEquals("documentgetelementsbytagnameNS04", 0, childList
                .getLength());
    
public voidtestGetElementsByTagNameNS5()

        Document doc;
        NodeList childList;
        doc = (Document) load("staffNS", builder);
        childList = doc.getElementsByTagNameNS("null", "elementId");
        assertEquals("documentgetelementsbytagnameNS05", 0, childList
                .getLength());