Search in sources :

Example 51 with Attr

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

the class NamedNodeMapGetNamedItemNS method testGetNamedItemNS2.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
// Assumes validation.
//    public void testGetNamedItemNS1() throws Throwable {
//        Document doc;
//        DocumentType docType;
//        NamedNodeMap entities;
//        NamedNodeMap notations;
//        Entity entity;
//        Notation notation;
//
//        String nullNS = null;
//
//        doc = (Document) load("staffNS", builder);
//        docType = doc.getDoctype();
//        entities = docType.getEntities();
//        assertNotNull("entitiesNotNull", entities);
//        notations = docType.getNotations();
//        assertNotNull("notationsNotNull", notations);
//        entity = (Entity) entities.getNamedItemNS(nullNS, "ent1");
//        assertNotNull("entityNull", entity);
//        notation = (Notation) notations.getNamedItemNS(nullNS, "notation1");
//        assertNotNull("notationNull", notation);
//    }
public void testGetNamedItemNS2() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    Attr attribute;
    NodeList elementList;
    String attrName;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
    element = elementList.item(1);
    attributes = element.getAttributes();
    attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov", "domestic");
    attrName = attribute.getNodeName();
    assertEquals("namednodemapgetnameditemns02", "emp:domestic", attrName);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 52 with Attr

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

the class NamedNodeMapRemoveNamedItemNS method testRemoveNamedItemNS1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testRemoveNamedItemNS1() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    Attr attribute;
    NodeList elementList;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
    element = elementList.item(1);
    attributes = element.getAttributes();
    attribute = (Attr) attributes.removeNamedItemNS("http://www.nist.gov", "domestic");
    attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov", "domestic");
    assertNull("namednodemapremovenameditemns01", attribute);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 53 with Attr

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

the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS2.

public void testSetNamedItemNS2() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Element element;
    Attr attribute;
    Attr attribute1;
    String attrName;
    doc = (Document) load("staffNS", builder);
    element = doc.createElementNS("http://www.w3.org/DOM/Test", "root");
    attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att");
    attributes = element.getAttributes();
    attributes.setNamedItemNS(attribute1);
    attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L1", "att");
    attrName = attribute.getNodeName();
    assertEquals("namednodemapsetnameditemns02", "L1:att", attrName);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 54 with Attr

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

the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS1.

/**
     * Runs the test case.
     *
     * @throws Throwable
     *             Any uncaught exception causes test to fail
     */
public void testSetNamedItemNS1() throws Throwable {
    Document doc;
    NamedNodeMap attributes;
    Node element;
    Attr attribute;
    Attr newAttr1;
    NodeList elementList;
    String attrName;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
    element = elementList.item(0);
    attributes = element.getAttributes();
    newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "streets");
    ((Element) /* Node */
    element).setAttributeNodeNS(newAttr1);
    attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/DOM/L1", "streets");
    attrName = attribute.getNodeName();
    assertEquals("namednodemapsetnameditemns01", "streets", attrName);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 55 with Attr

use of org.w3c.dom.Attr 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

Attr (org.w3c.dom.Attr)385 Element (org.w3c.dom.Element)178 NamedNodeMap (org.w3c.dom.NamedNodeMap)160 Document (org.w3c.dom.Document)134 Node (org.w3c.dom.Node)126 NodeList (org.w3c.dom.NodeList)80 DOMException (org.w3c.dom.DOMException)30 ArrayList (java.util.ArrayList)25 DocumentBuilder (javax.xml.parsers.DocumentBuilder)16 HashMap (java.util.HashMap)12 Text (org.w3c.dom.Text)12 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)11 CanonicalizationException (com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException)10 RubyString (org.jruby.RubyString)10 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)8 File (java.io.File)8 QName (javax.xml.namespace.QName)8 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)7 ParseException (java.text.ParseException)6 NokogiriHelpers.rubyStringToString (nokogiri.internals.NokogiriHelpers.rubyStringToString)6