Search in sources :

Example 16 with DOMException

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

the class SetAttributeNS method testSetAttributeNS6.

public void testSetAttributeNS6() throws Throwable {
    String namespaceURI = "http://www.nist.gov";
    String qualifiedName = "xml:qualifiedName";
    Document doc;
    NodeList elementList;
    Node testAddr;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagName("employee");
    testAddr = elementList.item(0);
    {
        boolean success = false;
        try {
            ((Element) /* Node */
            testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue");
        } 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 17 with DOMException

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

the class SetAttributeNS method testSetAttributeNS1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testSetAttributeNS1() throws Throwable {
    String namespaceURI = "http://www.nist.gov";
    String qualifiedName = "emp:qual?name";
    Document doc;
    NodeList elementList;
    Node testAddr;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagName("employee");
    testAddr = elementList.item(0);
    {
        boolean success = false;
        try {
            ((Element) /* Node */
            testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue");
        } 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 18 with DOMException

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

the class SetAttributeNS method testSetAttributeNS10.

public void testSetAttributeNS10() throws Throwable {
    String namespaceURI = "http://www.example.gov";
    Document doc;
    NodeList elementList;
    Node testAddr;
    doc = (Document) load("hc_staff", builder);
    elementList = doc.getElementsByTagName("em");
    testAddr = elementList.item(0);
    {
        //     Our exception priorities differ from the spec
        try {
            ((Element) /* Node */
            testAddr).setAttributeNS(namespaceURI, "", "newValue");
            fail();
        } catch (DOMException ex) {
        }
    // END android-changed
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document)

Example 19 with DOMException

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

the class SetAttributeNodeNS method testSetAttributeNode5.

public void testSetAttributeNode5() throws Throwable {
    String namespaceURI = "http://www.newattr.com";
    String qualifiedName = "emp:newAttr";
    Document doc1;
    Document doc2;
    Attr newAttr;
    NodeList elementList;
    Node testAddr;
    doc1 = (Document) load("staffNS", builder);
    doc2 = (Document) load("staffNS", builder);
    newAttr = doc2.createAttributeNS(namespaceURI, qualifiedName);
    elementList = doc1.getElementsByTagName("emp:address");
    testAddr = elementList.item(0);
    {
        boolean success = false;
        try {
            ((Element) /* Node */
            testAddr).setAttributeNodeNS(newAttr);
        } catch (DOMException ex) {
            success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
        }
        assertTrue("throw_WRONG_DOCUMENT_ERR", success);
    }
}
Also used : DOMException(org.w3c.dom.DOMException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 20 with DOMException

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

the class SetNamedItemNS method testSetNamedItemNS2.

public void testSetNamedItemNS2() throws Throwable {
    String namespaceURI = "http://www.usa.com";
    String qualifiedName = "dmstc:domestic";
    Document doc;
    Document anotherDoc;
    Node arg;
    NodeList elementList;
    Node testAddress;
    NamedNodeMap attributes;
    doc = (Document) load("staffNS", builder);
    anotherDoc = (Document) load("staffNS", builder);
    arg = anotherDoc.createAttributeNS(namespaceURI, qualifiedName);
    arg.setNodeValue("Maybe");
    elementList = doc.getElementsByTagName("address");
    testAddress = elementList.item(0);
    attributes = testAddress.getAttributes();
    {
        boolean success = false;
        try {
            attributes.setNamedItemNS(arg);
        } 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) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) 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