1 38 39 40 package com.sun.xml.fastinfoset.tools; 41 42 import org.jvnet.fastinfoset.FastInfosetResult; 43 import java.io.InputStream ; 44 import java.io.OutputStream ; 45 46 import javax.xml.parsers.DocumentBuilderFactory ; 47 import javax.xml.parsers.DocumentBuilder ; 48 import javax.xml.transform.Transformer ; 49 import javax.xml.transform.TransformerFactory ; 50 import javax.xml.transform.dom.DOMSource ; 51 52 import org.w3c.dom.Document ; 53 54 public class XML_DOM_SAX_FI extends TransformInputOutput { 55 56 public XML_DOM_SAX_FI() { 57 } 58 59 public void parse(InputStream document, OutputStream finf) throws Exception { 60 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 61 dbf.setNamespaceAware(true); 62 DocumentBuilder db = dbf.newDocumentBuilder(); 63 Document d = db.parse(document); 64 65 TransformerFactory tf = TransformerFactory.newInstance(); 66 Transformer t = tf.newTransformer(); 67 t.transform(new DOMSource (d), new FastInfosetResult(finf)); 68 } 69 70 public static void main(String [] args) throws Exception { 71 XML_DOM_SAX_FI p = new XML_DOM_SAX_FI(); 72 p.parse(args); 73 } 74 75 } 76 | Popular Tags |