Search in sources :

Example 71 with NamedNodeMap

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

the class GetNamedItemNS method testGetNamedItemNS2.

public void testGetNamedItemNS2() throws Throwable {
    String namespaceURI = "http://www.usa.com";
    String localName = "domest";
    Document doc;
    NodeList elementList;
    Node testEmployee;
    NamedNodeMap attributes;
    Attr newAttr;
    doc = (Document) load("staffNS", builder);
    elementList = doc.getElementsByTagName("address");
    testEmployee = elementList.item(1);
    attributes = testEmployee.getAttributes();
    newAttr = (Attr) attributes.getNamedItemNS(namespaceURI, localName);
    assertNull("throw_Null", newAttr);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 72 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap 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 73 with NamedNodeMap

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

Example 74 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project hazelcast by hazelcast.

the class XmlConfigBuilder method handleList.

private void handleList(Node node) {
    Node attName = node.getAttributes().getNamedItem("name");
    String name = getTextContent(attName);
    ListConfig lConfig = new ListConfig();
    lConfig.setName(name);
    for (Node n : childElements(node)) {
        String nodeName = cleanNodeName(n);
        String value = getTextContent(n).trim();
        if ("max-size".equals(nodeName)) {
            lConfig.setMaxSize(getIntegerValue("max-size", value));
        } else if ("backup-count".equals(nodeName)) {
            lConfig.setBackupCount(getIntegerValue("backup-count", value));
        } else if ("async-backup-count".equals(nodeName)) {
            lConfig.setAsyncBackupCount(getIntegerValue("async-backup-count", value));
        } else if ("item-listeners".equals(nodeName)) {
            for (Node listenerNode : childElements(n)) {
                if ("item-listener".equals(cleanNodeName(listenerNode))) {
                    NamedNodeMap attrs = listenerNode.getAttributes();
                    boolean incValue = getBooleanValue(getTextContent(attrs.getNamedItem("include-value")));
                    String listenerClass = getTextContent(listenerNode);
                    lConfig.addItemListenerConfig(new ItemListenerConfig(listenerClass, incValue));
                }
            }
        } else if ("statistics-enabled".equals(nodeName)) {
            lConfig.setStatisticsEnabled(getBooleanValue(value));
        }
    }
    this.config.addListConfig(lConfig);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

Example 75 with NamedNodeMap

use of org.w3c.dom.NamedNodeMap in project camel by apache.

the class BeanDefinitionParser method doParse.

protected void doParse(Element element, BeanDefinitionBuilder builder) {
    NamedNodeMap attributes = element.getAttributes();
    for (int x = 0; x < attributes.getLength(); x++) {
        Attr attribute = (Attr) attributes.item(x);
        String name = attribute.getLocalName();
        String fullName = attribute.getName();
        // assign id if we want them
        if (fullName.equals("id") && isAssignId()) {
            if (attribute.getValue() != null) {
                builder.addPropertyValue("id", attribute.getValue());
            }
        // assign other attributes if eligible
        } else if (!fullName.startsWith("xmlns:") && !fullName.equals("xmlns") && isEligibleAttribute(name)) {
            String propertyName = extractPropertyName(name);
            Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty.");
            builder.addPropertyValue(propertyName, attribute.getValue());
        }
    }
    postProcess(builder, element);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Attr(org.w3c.dom.Attr)

Aggregations

NamedNodeMap (org.w3c.dom.NamedNodeMap)993 Node (org.w3c.dom.Node)690 NodeList (org.w3c.dom.NodeList)339 Attr (org.w3c.dom.Attr)295 Element (org.w3c.dom.Element)238 Document (org.w3c.dom.Document)154 ArrayList (java.util.ArrayList)92 HashMap (java.util.HashMap)91 DocumentBuilder (javax.xml.parsers.DocumentBuilder)59 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)58 IOException (java.io.IOException)53 SAXException (org.xml.sax.SAXException)41 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)40 List (java.util.List)36 Map (java.util.Map)33 File (java.io.File)27 InputStream (java.io.InputStream)26 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)25 DOMException (org.w3c.dom.DOMException)25 ByteArrayInputStream (java.io.ByteArrayInputStream)19