Search in sources :

Example 76 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestSetAttributeNodeNSForeignImplementation method runTest.

@Override
protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = document.createElementNS(null, "test");
    Attr attr = mock(Attr.class);
    try {
        element.setAttributeNodeNS(attr);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertThat(ex.code).isEqualTo(DOMException.WRONG_DOCUMENT_ERR);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 77 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestSetAttributeNodeNSWrongDocument method runTest.

protected void runTest() throws Throwable {
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document document1 = db.newDocument();
    Document document2 = db.newDocument();
    Element element = document1.createElementNS(null, "test");
    Attr attr = document2.createAttributeNS(null, "test");
    try {
        element.setAttributeNodeNS(attr);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.WRONG_DOCUMENT_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 78 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestSetPrefixNotNullWithoutNamespace method runTest.

protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = document.createElementNS(null, "test");
    try {
        element.setPrefix("p");
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.NAMESPACE_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 79 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestSetNamedItemNSWrongDocument method runTest.

protected void runTest() throws Throwable {
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document document1 = db.newDocument();
    Document document2 = db.newDocument();
    Element element = document1.createElementNS(null, "test");
    Attr attr = document2.createAttributeNS(null, "test");
    try {
        element.getAttributes().setNamedItemNS(attr);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertEquals(DOMException.WRONG_DOCUMENT_ERR, ex.code);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 80 with DOMException

use of org.w3c.dom.DOMException in project webservices-axiom by apache.

the class TestRemoveAttributeNodeForeignImplementation method runTest.

@Override
protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = document.createElementNS(null, "test");
    Attr attr = mock(Attr.class);
    try {
        element.removeAttributeNode(attr);
        fail("Expected DOMException");
    } catch (DOMException ex) {
        assertThat(ex.code).isEqualTo(DOMException.NOT_FOUND_ERR);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) 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