Search in sources :

Example 56 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project robovm by robovm.

the class NamedNodeMapGetNamedItemNS method testGetNamedItemNS2.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
// Assumes validation.
//    public void testGetNamedItemNS1() throws Throwable {
//        Document doc;
//        DocumentType docType;
//        NamedNodeMap entities;
//        NamedNodeMap notations;
//        Entity entity;
//        Notation notation;
//
//        String nullNS = null;
//
//        doc = (Document) load("staffNS", builder);
//        docType = doc.getDoctype();
//        entities = docType.getEntities();
//        assertNotNull("entitiesNotNull", entities);
//        notations = docType.getNotations();
//        assertNotNull("notationsNotNull", notations);
//        entity = (Entity) entities.getNamedItemNS(nullNS, "ent1");
//        assertNotNull("entityNull", entity);
//        notation = (Notation) notations.getNamedItemNS(nullNS, "notation1");
//        assertNotNull("notationNull", notation);
//    }
public void testGetNamedItemNS2() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    Attr attribute;
    NodeList elementList;
    String attrName;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
    element = elementList.item(1);
    attributes = element.getAttributes();
    attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov", "domestic");
    attrName = attribute.getNodeName();
    assertEquals("namednodemapgetnameditemns02", "emp:domestic", attrName);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 57 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project robovm by robovm.

the class NamedNodeMapRemoveNamedItemNS method testRemoveNamedItemNS1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testRemoveNamedItemNS1() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    Attr attribute;
    NodeList elementList;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
    element = elementList.item(1);
    attributes = element.getAttributes();
    attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov", "domestic");
    attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov", "domestic");
    assertNull("namednodemapremovenameditemns01", attribute);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 58 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project robovm by robovm.

the class NamedNodeMapRemoveNamedItemNS method testRemoveNamedItemNS6.

// Assumes validation.
//    public void testRemoveNamedItemNS5() throws Throwable {
//        Document doc;
//        DocumentType docType;
//        NamedNodeMap entities;
//        NamedNodeMap notations;
//
//        String nullNS = null;
//
//        doc = (Document) load("staffNS", builder);
//        docType = doc.getDoctype();
//        entities = docType.getEntities();
//        assertNotNull("entitiesNotNull", entities);
//        notations = docType.getNotations();
//        assertNotNull("notationsNotNull", notations);
//
//        try {
//            entities.removeNamedItemNS(nullNS, "ent1");
//            fail("entity_throw_DOMException");
//
//        } catch (DOMException ex) {
//            switch (ex.code) {
//            case 8:
//                break;
//            case 7:
//                break;
//            default:
//                throw ex;
//            }
//        }
//
//        try {
//            notations.removeNamedItemNS(nullNS, "notation1");
//            fail("notation_throw_DOMException");
//
//        } catch (DOMException ex) {
//            switch (ex.code) {
//            case 8:
//                break;
//            case 7:
//                break;
//            default:
//                throw ex;
//            }
//        }
//    }
public void testRemoveNamedItemNS6() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    NodeList elementList;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee");
    element = elementList.item(1);
    attributes = element.getAttributes();
    {
        boolean success = false;
        try {
            attributes.removeNamedItemNS("http://www.Nist.gov", "domestic");
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_FOUND_ERR);
        }
        assertTrue("throw_NOT_FOUND_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document)

Example 59 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project robovm by robovm.

the class NamedNodeMapRemoveNamedItemNS method testRemoveNamedItemNS7.

public void testRemoveNamedItemNS7() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    NodeList elementList;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "employee");
    element = elementList.item(1);
    attributes = element.getAttributes();
    {
        boolean success = false;
        try {
            attributes.removeNamedItemNS("http://www.nist.gov", "domestic");
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_FOUND_ERR);
        }
        assertTrue("throw_NOT_FOUND_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document)

Example 60 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project robovm by robovm.

the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS2.

public void testSetNamedItemNS2() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Element element;
    Attr attribute;
    Attr attribute1;
    String attrName;
    doc = (Document) load("staffNS", builder);
    element = doc.createElementNS("http://www.w3.org/DOM/Test", "root");
    attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att");
    attributes = element.getAttributes();
    attributes.setNamedItemNS(attribute1);
    attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L1", "att");
    attrName = attribute.getNodeName();
    assertEquals("namednodemapsetnameditemns02", "L1:att", attrName);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Aggregations

NamedNodeMap (org.w3c.dom.NamedNodeMap)993 Node (org.w3c.dom.Node)690 NodeList (org.w3c.dom.NodeList)339 Attr (org.w3c.dom.Attr)295 Element (org.w3c.dom.Element)238 Document (org.w3c.dom.Document)154 ArrayList (java.util.ArrayList)92 HashMap (java.util.HashMap)91 DocumentBuilder (javax.xml.parsers.DocumentBuilder)59 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)58 IOException (java.io.IOException)53 SAXException (org.xml.sax.SAXException)41 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)40 List (java.util.List)36 Map (java.util.Map)33 File (java.io.File)27 InputStream (java.io.InputStream)26 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)25 DOMException (org.w3c.dom.DOMException)25 ByteArrayInputStream (java.io.ByteArrayInputStream)19