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());
}
}
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;
}
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());
}
}
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);
}
}
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 "";
}
}
Aggregations