added Debug class

This commit is contained in:
Georgy Litvinov 2017-06-16 19:34:23 +03:00 committed by Georgy Litvinov
parent 681d64375f
commit a3c3aa095d

View file

@ -0,0 +1,35 @@
package writer2latex.xhtml;
import java.io.StringWriter;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Node;
public class Debug {
public static void printNode(Node node){
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer transformer;
try {
transformer = transFactory.newTransformer();
StringWriter buffer = new StringWriter();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.transform(new DOMSource(node), new StreamResult(buffer));
String str = buffer.toString();
System.out.println(str);
} catch (TransformerConfigurationException e1) {
e1.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
}
}
}