Search in sources :

Example 46 with DOMException

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

the class ElementSetAttributeNodeNS method testSetAttributeNodeNS4.

public void testSetAttributeNodeNS4() throws Throwable {
    Document doc;
    Element element1;
    Element element2;
    Attr attribute;
    doc = (Document) load("staffNS", builder);
    element1 = doc.createElementNS("http://www.w3.org/DOM/Test", "elem1");
    element2 = doc.createElementNS("http://www.w3.org/DOM/Test", "elem2");
    attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test", "attr");
    element1.setAttributeNodeNS(attribute);
    {
        boolean success = false;
        try {
            element2.setAttributeNodeNS(attribute);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR);
        }
        assertTrue("elementsetattributenodens04", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 47 with DOMException

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

the class ImportNode method testImportNode16.

public void testImportNode16() throws Throwable {
    Document doc;
    Document anotherDoc;
    DocumentType docType;
    doc = (Document) load("staffNS", builder);
    anotherDoc = (Document) load("staffNS", builder);
    docType = anotherDoc.getDoctype();
    {
        boolean success = false;
        try {
            doc.importNode(docType, false);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
        }
        assertTrue("throw_NOT_SUPPORTED_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

Example 48 with DOMException

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

the class ImportNode method testImportNode17.

public void testImportNode17() throws Throwable {
    Document doc;
    Document anotherDoc;
    doc = (Document) load("staffNS", builder);
    anotherDoc = (Document) load("staffNS", builder);
    {
        boolean success = false;
        try {
            doc.importNode(anotherDoc, false);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
        }
        assertTrue("throw_NOT_SUPPORTED_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Document(org.w3c.dom.Document)

Example 49 with DOMException

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

the class HCNamedNodeMapInvalidType method testNamedNodeMapInvalidType.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testNamedNodeMapInvalidType() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Element docElem;
    Element newElem;
    doc = (Document) load("hc_staff", builder);
    docElem = doc.getDocumentElement();
    attributes = docElem.getAttributes();
    newElem = doc.createElement("html");
    {
        boolean success = false;
        try {
            attributes.setNamedItem(newElem);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.HIERARCHY_REQUEST_ERR);
        }
        assertTrue("throw_HIERARCHY_REQUEST_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 50 with DOMException

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

the class HCNotationsRemoveNamedItemNS method testRemoveNamedItemNS.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testRemoveNamedItemNS() throws Throwable {
    Document doc;
    NamedNodeMap notations;
    DocumentType docType;
    doc = (Document) load("hc_staff", builder);
    docType = doc.getDoctype();
    if (!(("text/html".equals(getContentType())))) {
        assertNotNull("docTypeNotNull", docType);
        notations = docType.getNotations();
        assertNotNull("notationsNotNull", notations);
        try {
            notations.removeNamedItemNS("http://www.w3.org/1999/xhtml", "alpha");
            fail("throw_NO_MOD_OR_NOT_FOUND_ERR");
        } catch (DOMException ex) {
            switch(ex.code) {
                case 7:
                    break;
                case 8:
                    break;
                default:
                    throw ex;
            }
        }
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NamedNodeMap(org.w3c.dom.NamedNodeMap) DocumentType(org.w3c.dom.DocumentType) Document(org.w3c.dom.Document)

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