1 46 47 package groovy.xml; 48 49 import org.apache.xml.serialize.XMLSerializer; 50 51 import org.codehaus.groovy.classgen.TestSupport; 52 53 import org.w3c.dom.Document ; 54 import org.w3c.dom.Element ; 55 import org.w3c.dom.Node ; 56 57 import java.io.IOException ; 58 59 64 public abstract class TestXmlSupport extends TestSupport { 65 66 protected void dump(Node node) throws IOException { 67 XMLSerializer printer = createSerializer(); 68 if (node instanceof Document ) { 69 printer.serialize((Document ) node); 70 } 71 else { 72 printer.serialize((Element ) node); 73 } 74 System.out.println(); 75 } 76 77 protected XMLSerializer createSerializer() { 78 return new XMLSerializer(System.out, null); 79 } 80 81 protected SAXBuilder createSAXBuilder() throws IOException { 82 return new SAXBuilder(createSerializer().asContentHandler()); 83 } 84 } 85 | Popular Tags |