1--- org/jivesoftware/smackx/pubsub/util/XmlUtils.java 2012-06-05 14:35:54.518687907 +0200 2+++ org/jivesoftware/smackx/pubsub/util/XmlUtils.java 2012-06-05 21:07:13.038946699 +0200 3@@ -14,47 +14,15 @@ 4 package org.jivesoftware.smackx.pubsub.util; 5 6 import java.io.StringReader; 7 8-import javax.xml.transform.OutputKeys; 9-import javax.xml.transform.Transformer; 10-import javax.xml.transform.TransformerFactory; 11-import javax.xml.transform.stream.StreamResult; 12-import javax.xml.transform.stream.StreamSource; 13- 14 /** 15 * Simple utility for pretty printing xml. 16 * 17 * @author Robin Collier 18 */ 19 public class XmlUtils 20 { 21- /** 22- * 23- * @param header Just a title for the stanza for readability. Single word no spaces since 24- * it is inserted as the root element in the output. 25- * @param xml The string to pretty print 26- */ 27- static public void prettyPrint(String header, String xml) 28- { 29- try 30- { 31- Transformer transformer = TransformerFactory.newInstance().newTransformer(); 32- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 33- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3"); 34- 35- if (header != null) 36- { 37- xml = "\n<" + header + ">" + xml + "</" + header + '>'; 38- } 39- transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(System.out)); 40- } 41- catch (Exception e) 42- { 43- System.out.println("Something wrong with xml in \n---------------\n" + xml + "\n---------------"); 44- e.printStackTrace(); 45- } 46- } 47 48 static public void appendAttribute(StringBuilder builder, String att, String value) 49 { 50 builder.append(" "); 51