KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > xml > fastinfoset > tools > XML_DOM_FI


1
2 package com.sun.xml.fastinfoset.tools;
3
4 import com.sun.xml.fastinfoset.dom.DOMDocumentSerializer;
5 import java.io.InputStream JavaDoc;
6 import java.io.OutputStream JavaDoc;
7 import javax.xml.parsers.DocumentBuilder JavaDoc;
8 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
9 import org.w3c.dom.Document JavaDoc;
10
11 public class XML_DOM_FI extends TransformInputOutput {
12     
13     public XML_DOM_FI() {
14     }
15
16     public void parse(InputStream JavaDoc document, OutputStream JavaDoc finf) throws Exception JavaDoc {
17         DocumentBuilderFactory JavaDoc dbf = DocumentBuilderFactory.newInstance();
18         dbf.setNamespaceAware(true);
19         DocumentBuilder JavaDoc db = dbf.newDocumentBuilder();
20         Document JavaDoc d = db.parse(document);
21
22         DOMDocumentSerializer s = new DOMDocumentSerializer();
23         s.setOutputStream(finf);
24         s.serialize(d);
25     }
26     
27     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
28         XML_DOM_FI p = new XML_DOM_FI();
29         p.parse(args);
30     }
31     
32 }
Popular Tags