Search in sources :

Example 21 with DOMException

use of org.w3c.dom.DOMException 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 22 with DOMException

use of org.w3c.dom.DOMException 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 23 with DOMException

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

the class Prefix method _testGetPrefix6.

public void _testGetPrefix6() throws Throwable {
    Document doc;
    NodeList elementList;
    Node employeeNode;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagName("employee");
    employeeNode = elementList.item(0);
    {
        boolean success = false;
        try {
            employeeNode.setPrefix("pre^fix xmlns='http//www.nist.gov'");
        } catch (DOMException ex) {
            success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
        }
        assertTrue("throw_INVALID_CHARACTER_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document)

Example 24 with DOMException

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

the class Prefix method testGetPrefix10.

public void testGetPrefix10() throws Throwable {
    Document doc;
    NodeList elementList;
    Node employeeNode;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagName("employee");
    employeeNode = elementList.item(1);
    {
        boolean success = false;
        try {
            employeeNode.setPrefix("xml");
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("throw_NAMESPACE_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document)

Example 25 with DOMException

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

the class Prefix method _testGetPrefix9.

// Assumes validation.
//    public void testGetPrefix8() throws Throwable {
//        Document doc;
//        NodeList genderList;
//        Node genderNode;
//        Node entRef;
//        Node entElement;
//
//        int nodeType;
//        doc = (Document) load("staff", builder);
//        genderList = doc.getElementsByTagName("gender");
//        genderNode = genderList.item(2);
//        entRef = genderNode.getFirstChild();
//        nodeType = (int) entRef.getNodeType();
//
//        if (1 == nodeType) {
//            entRef = doc.createEntityReference("ent4");
//            assertNotNull("createdEntRefNotNull", entRef);
//        }
//        entElement = entRef.getFirstChild();
//        assertNotNull("entElement", entElement);
//        doc.createElement("text3");
//
//        {
//            boolean success = false;
//            try {
//                entElement.setPrefix("newPrefix");
//            } catch (DOMException ex) {
//                success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
//            }
//            assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success);
//        }
//    }
public void _testGetPrefix9() throws Throwable {
    Document doc;
    NodeList elementList;
    Element addrNode;
    Attr addrAttr;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagName("address");
    addrNode = (Element) elementList.item(3);
    addrAttr = addrNode.getAttributeNode("xmlns");
    {
        boolean success = false;
        try {
            addrAttr.setPrefix("xxx");
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("throw_NAMESPACE_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Aggregations

DOMException (org.w3c.dom.DOMException)323 Document (org.w3c.dom.Document)165 Element (org.w3c.dom.Element)131 Node (org.w3c.dom.Node)73 NodeList (org.w3c.dom.NodeList)57 DocumentBuilder (javax.xml.parsers.DocumentBuilder)42 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)42 Attr (org.w3c.dom.Attr)40 DOMImplementation (org.w3c.dom.DOMImplementation)37 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)28 FrameworkException (org.structr.common.error.FrameworkException)27 IOException (java.io.IOException)26 NamedNodeMap (org.w3c.dom.NamedNodeMap)25 DocumentType (org.w3c.dom.DocumentType)19 ArrayList (java.util.ArrayList)17 Text (org.w3c.dom.Text)17 DOMNode (org.structr.web.entity.dom.DOMNode)16 XPathExpressionException (javax.xml.xpath.XPathExpressionException)15 SAXException (org.xml.sax.SAXException)13 TransformerException (javax.xml.transform.TransformerException)12