Search in sources :

Example 36 with Element

use of org.w3c.dom.Element in project qksms by moezbhatti.

the class SmilContentHandler method startElement.

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
    if (LOCAL_LOGV)
        Log.v(TAG, "SmilContentHandler.startElement. Creating element " + localName);
    Element element = mSmilDocument.createElement(localName);
    if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); i++) {
            if (LOCAL_LOGV)
                Log.v(TAG, "Attribute " + i + " lname = " + attributes.getLocalName(i) + " value = " + attributes.getValue(i));
            element.setAttribute(attributes.getLocalName(i), attributes.getValue(i));
        }
    }
    if (LOCAL_LOGV)
        Log.v(TAG, "Appending " + localName + " to " + mCurrentNode.getNodeName());
    mCurrentNode.appendChild(element);
    mCurrentNode = element;
}
Also used : Element(org.w3c.dom.Element)

Example 37 with Element

use of org.w3c.dom.Element in project OpenAttestation by OpenAttestation.

the class ReadXmlTest method getTagSelectionFromXml.

public TagSelection getTagSelectionFromXml(String xml) throws ParserConfigurationException, SAXException, IOException {
    TagSelection ret = new TagSelection();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource is = new InputSource(new StringReader(xml));
    Document doc = builder.parse(is);
    ArrayList<tag> tagList = new ArrayList<tag>();
    int cnt = 0;
    NodeList nodeList = doc.getElementsByTagName("attribute");
    for (int s = 0; s < nodeList.getLength(); s++) {
        Node fstNode = nodeList.item(s);
        if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
            Element fstElmnt = (Element) fstNode;
            String idValue = fstElmnt.getAttribute("oid");
            Element lstNmElmnt = (Element) nodeList.item(cnt++);
            NodeList lstNm = lstNmElmnt.getChildNodes();
            String currentAction = ((Node) lstNm.item(0)).getNodeValue();
            if (currentAction != null) {
                tagList.add(new tag("", idValue, currentAction));
            }
        }
    }
    nodeList = doc.getElementsByTagName("selection");
    Node fstNode = nodeList.item(0);
    Element e = (Element) fstNode;
    ret.id = e.getAttribute("id");
    ret.name = e.getAttribute("name");
    ret.tagList = tagList;
    return ret;
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) DocumentBuilder(javax.xml.parsers.DocumentBuilder) StringReader(java.io.StringReader)

Example 38 with Element

use of org.w3c.dom.Element in project OpenAttestation by OpenAttestation.

the class TrustAssertion method readXml.

/**
     * See also {@code XML.parseDocumentElement} in mtwilson-util-xml
     */
private Element readXml(String xmlDocument) throws ParserConfigurationException, SAXException, IOException {
    XML xml = new XML();
    xml.setSchemaPackageName("xsd");
    xml.addSchemaLocation("http://docs.oasis-open.org/security/saml/v2.0/saml-schema-protocol-2.0.xsd");
    xml.addSchemaLocation("http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd");
    xml.addSchemaLocation("http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd");
    xml.addSchemaLocation("http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd");
    Element myXml = xml.parseDocumentElement(xmlDocument);
    return myXml;
}
Also used : XML(com.intel.mtwilson.xml.XML) Element(org.w3c.dom.Element)

Example 39 with Element

use of org.w3c.dom.Element in project Openfire by igniterealtime.

the class MonitoringDWR method buildCreator.

/**
     * Builds a create element within the DWR servlet.
     * @param javascriptID the javascript variable name to use.
     * @param qualifiedClassName the fully qualified class name.
     * @return the Element.
     */
private Element buildCreator(String javascriptID, String qualifiedClassName) {
    Element element = document.createElement("create");
    element.setAttribute("creator", "new");
    element.setAttribute("javascript", javascriptID);
    Element parameter = document.createElement("param");
    parameter.setAttribute("name", "class");
    parameter.setAttribute("value", qualifiedClassName);
    element.appendChild(parameter);
    return element;
}
Also used : Element(org.w3c.dom.Element)

Example 40 with Element

use of org.w3c.dom.Element in project Openfire by igniterealtime.

the class GatewayDWR method configure.

@Override
public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException {
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dbf.newDocumentBuilder();
        document = builder.newDocument();
        Element root = document.createElement("dwr");
        document.appendChild(root);
        Element allowElement = document.createElement("allow");
        allowElement.appendChild(buildCreator("ConfigManager", "net.sf.kraken.web.ConfigManager"));
        allowElement.appendChild(buildCreator("ConnectionTester", "net.sf.kraken.web.ConnectionTester"));
        root.appendChild(allowElement);
    } catch (ParserConfigurationException e) {
        Log.error("Error configuring DWR for gateway plugin: ", e);
    }
    configuration.addConfig(document);
    // Specify the path for the js files 
    Object bean = container.getBean("interface");
    if (bean instanceof DefaultInterfaceProcessor) {
        DefaultInterfaceProcessor processor = (DefaultInterfaceProcessor) bean;
        processor.setOverridePath("/plugins/kraken/dwr");
    }
}
Also used : DefaultInterfaceProcessor(uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

Element (org.w3c.dom.Element)9072 Document (org.w3c.dom.Document)2651 NodeList (org.w3c.dom.NodeList)2103 Node (org.w3c.dom.Node)1855 ArrayList (java.util.ArrayList)957 DocumentBuilder (javax.xml.parsers.DocumentBuilder)793 IOException (java.io.IOException)732 Test (org.junit.Test)693 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)591 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)489 HashMap (java.util.HashMap)434 SAXException (org.xml.sax.SAXException)406 File (java.io.File)358 Attr (org.w3c.dom.Attr)333 InputStream (java.io.InputStream)309 QName (javax.xml.namespace.QName)292 Map (java.util.Map)285 JAXBElement (javax.xml.bind.JAXBElement)285 NamedNodeMap (org.w3c.dom.NamedNodeMap)266 List (java.util.List)264