Search in sources :

Example 11 with DOMException

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

the class NodeSetPrefix method testSetPrefix5.

// Relies on validation, which we don't support.
//    public void testSetPrefix4() throws Throwable {
//        Document doc;
//        Element element;
//        Attr attribute;
//        NodeList elementList;
//        String nullNS = null;
//
//        doc = (Document) load("staffNS", builder);
//        elementList = doc.getElementsByTagName("emp:employee");
//        element = (Element) elementList.item(0);
//        assertNotNull("empEmployeeNotNull", element);
//        attribute = element.getAttributeNodeNS(nullNS, "defaultAttr");
//
//        {
//            boolean success = false;
//            try {
//                attribute.setPrefix("test");
//            } catch (DOMException ex) {
//                success = (ex.code == DOMException.NAMESPACE_ERR);
//            }
//            assertTrue("nodesetprefix04", success);
//        }
//    }
public void testSetPrefix5() throws Throwable {
    Document doc;
    Element element;
    String prefixValue;
    List<String> prefixValues = new ArrayList<String>();
    prefixValues.add("_:");
    prefixValues.add(":0");
    prefixValues.add(":");
    prefixValues.add("_::");
    prefixValues.add("a:0:c");
    doc = (Document) load("staffNS", builder);
    element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem");
    for (int indexN10050 = 0; indexN10050 < prefixValues.size(); indexN10050++) {
        prefixValue = (String) prefixValues.get(indexN10050);
        {
            boolean success = false;
            try {
                element.setPrefix(prefixValue);
            } catch (DOMException ex) {
                success = (ex.code == DOMException.NAMESPACE_ERR);
            }
            assertTrue("throw_NAMESPACE_ERR", success);
        }
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document)

Example 12 with DOMException

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

the class NodeSetPrefix method testSetPrefix7.

public void testSetPrefix7() throws Throwable {
    Document doc;
    Attr attribute;
    doc = (Document) load("staffNS", builder);
    attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test/L2", "abc:elem");
    {
        boolean success = false;
        try {
            attribute.setPrefix("xmlns");
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NAMESPACE_ERR);
        }
        assertTrue("throw_NAMESPACE_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 13 with DOMException

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

the class NodeSetPrefix method _testSetPrefix9.

public void _testSetPrefix9() throws Throwable {
    Document doc;
    String value = "#$%&'()@";
    Element element;
    doc = (Document) load("staffNS", builder);
    element = doc.createElementNS("http://www.w3.org/DOM/Test/L2", "dom:elem");
    {
        boolean success = false;
        try {
            element.setPrefix(value);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
        }
        assertTrue("throw_INVALID_CHARACTER_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 14 with DOMException

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

the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS6.

// Assumes validation.
//    public void testSetNamedItemNS5() throws Throwable {
//        Document doc;
//        DocumentType docType;
//        NamedNodeMap entities;
//        NamedNodeMap notations;
//        Entity entity;
//        Notation notation;
//
//        doc = (Document) load("staffNS", builder);
//        docType = doc.getDoctype();
//        entities = docType.getEntities();
//        assertNotNull("entitiesNotNull", entities);
//        notations = docType.getNotations();
//        assertNotNull("notationsNotNull", notations);
//        entity = (Entity) entities.getNamedItem("ent1");
//        notation = (Notation) notations.getNamedItem("notation1");
//
//        {
//            boolean success = false;
//            try {
//                entities.setNamedItemNS(entity);
//            } catch (DOMException ex) {
//                success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
//            }
//            assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_entities", success);
//        }
//
//        {
//            boolean success = false;
//            try {
//                notations.setNamedItemNS(notation);
//            } catch (DOMException ex) {
//                success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
//            }
//            assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_notations", success);
//        }
//    }
public void testSetNamedItemNS6() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    NodeList elementList;
    Element element;
    Attr attr;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("*", "address");
    element = (Element) elementList.item(0);
    attributes = element.getAttributes();
    attr = (Attr) attributes.getNamedItemNS("http://www.usa.com", "domestic");
    element = (Element) elementList.item(1);
    attributes = element.getAttributes();
    {
        boolean success = false;
        try {
            attributes.setNamedItemNS(attr);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR);
        }
        assertTrue("namednodemapsetnameditemns06", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 15 with DOMException

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

the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS4.

public void testSetNamedItemNS4() throws Throwable {
    Document doc;
    DOMImplementation domImpl;
    Document docAlt;
    DocumentType docType = null;
    NamedNodeMap attributes;
    NodeList elementList;
    Element element;
    Attr attrAlt;
    String nullNS = null;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("*", "address");
    element = (Element) elementList.item(1);
    attributes = element.getAttributes();
    domImpl = doc.getImplementation();
    docAlt = domImpl.createDocument(nullNS, "newDoc", docType);
    attrAlt = docAlt.createAttributeNS(nullNS, "street");
    {
        boolean success = false;
        try {
            attributes.setNamedItemNS(attrAlt);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
        }
        assertTrue("throw_WRONG_DOCUMENT_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) DOMImplementation(org.w3c.dom.DOMImplementation) DocumentType(org.w3c.dom.DocumentType) 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