Search in sources :

Example 6 with DOMImplementationLS

use of org.w3c.dom.ls.DOMImplementationLS in project CloudStack-archive by CloudStack-extras.

the class VsmResponse method printResponse.

// Helper routine to check for the response received.
protected void printResponse() {
    try {
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        DOMImplementationLS ls = (DOMImplementationLS) docBuilder.getDOMImplementation();
        LSSerializer lss = ls.createLSSerializer();
        System.out.println(lss.writeToString(_docResponse));
    } catch (ParserConfigurationException e) {
        s_logger.error("Error parsing the repsonse : " + e.toString());
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) LSSerializer(org.w3c.dom.ls.LSSerializer) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 7 with DOMImplementationLS

use of org.w3c.dom.ls.DOMImplementationLS in project tdme by andreasdr.

the class GUIParser method getInnerXml.

/**
	 * Get inner XML
	 * 	see: http://stackoverflow.com/questions/3300839/get-a-nodes-inner-xml-as-string-in-java-dom
	 * @param node
	 * @return string
	 */
private static String getInnerXml(Node node) {
    DOMImplementationLS lsImpl = (DOMImplementationLS) node.getOwnerDocument().getImplementation().getFeature("LS", "3.0");
    LSSerializer lsSerializer = lsImpl.createLSSerializer();
    NodeList childNodes = node.getChildNodes();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < childNodes.getLength(); i++) {
        sb.append(lsSerializer.writeToString(childNodes.item(i)));
    }
    String result = sb.toString();
    result = result.replace("<?xml version=\"1.0\" encoding=\"UTF-16\"?>", "");
    return result;
}
Also used : DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) NodeList(org.w3c.dom.NodeList) LSSerializer(org.w3c.dom.ls.LSSerializer) MutableString(net.drewke.tdme.utils.MutableString)

Example 8 with DOMImplementationLS

use of org.w3c.dom.ls.DOMImplementationLS in project cloudstack by apache.

the class VsmResponse method printResponse.

// Helper routine to check for the response received.
protected void printResponse() {
    try {
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        DOMImplementationLS ls = (DOMImplementationLS) docBuilder.getDOMImplementation();
        LSSerializer lss = ls.createLSSerializer();
        System.out.println(lss.writeToString(_docResponse));
    } catch (ParserConfigurationException e) {
        s_logger.error("Error parsing the repsonse : " + e.toString());
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) LSSerializer(org.w3c.dom.ls.LSSerializer) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 9 with DOMImplementationLS

use of org.w3c.dom.ls.DOMImplementationLS in project android by JetBrains.

the class ThemePreviewBuilder method printDebug.

private static void printDebug(@NotNull PrintStream out, @NotNull Document document) {
    try {
        DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) reg.getDOMImplementation("LS");
        LSSerializer serializer = impl.createLSSerializer();
        LSOutput lsOutput = impl.createLSOutput();
        lsOutput.setEncoding("UTF-8");
        lsOutput.setByteStream(out);
        serializer.write(document, lsOutput);
    } catch (ClassNotFoundException e) {
        e.printStackTrace(out);
    } catch (InstantiationException e) {
        e.printStackTrace(out);
    } catch (IllegalAccessException e) {
        e.printStackTrace(out);
    }
}
Also used : DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) DOMImplementationRegistry(org.w3c.dom.bootstrap.DOMImplementationRegistry) LSSerializer(org.w3c.dom.ls.LSSerializer) LSOutput(org.w3c.dom.ls.LSOutput)

Example 10 with DOMImplementationLS

use of org.w3c.dom.ls.DOMImplementationLS in project ddf by codice.

the class AbstractStsRealm method getFormattedXml.

/**
     * Transform into formatted XML.
     */
private String getFormattedXml(Node node) {
    Document document = node.getOwnerDocument().getImplementation().createDocument("", "fake", null);
    Element copy = (Element) document.importNode(node, true);
    document.importNode(node, false);
    document.removeChild(document.getDocumentElement());
    document.appendChild(copy);
    DOMImplementation domImpl = document.getImplementation();
    DOMImplementationLS domImplLs = (DOMImplementationLS) domImpl.getFeature("LS", "3.0");
    if (null != domImplLs) {
        LSSerializer serializer = domImplLs.createLSSerializer();
        serializer.getDomConfig().setParameter("format-pretty-print", true);
        return serializer.writeToString(document);
    } else {
        return "";
    }
}
Also used : Element(org.w3c.dom.Element) DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) DOMImplementation(org.w3c.dom.DOMImplementation) LSSerializer(org.w3c.dom.ls.LSSerializer) Document(org.w3c.dom.Document)

Aggregations

DOMImplementationLS (org.w3c.dom.ls.DOMImplementationLS)21 LSSerializer (org.w3c.dom.ls.LSSerializer)18 DocumentBuilder (javax.xml.parsers.DocumentBuilder)8 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)8 Document (org.w3c.dom.Document)8 DOMImplementationRegistry (org.w3c.dom.bootstrap.DOMImplementationRegistry)6 IOException (java.io.IOException)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 LSOutput (org.w3c.dom.ls.LSOutput)5 Element (org.w3c.dom.Element)4 StringWriter (java.io.StringWriter)3 DOMImplementation (org.w3c.dom.DOMImplementation)3 Node (org.w3c.dom.Node)3 TransformerException (javax.xml.transform.TransformerException)2 DOMException (org.w3c.dom.DOMException)2 NodeList (org.w3c.dom.NodeList)2 BinaryContent (ddf.catalog.data.BinaryContent)1 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1