|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsamples.transform.XMLToFastInfosetStAXSerializer
public class XMLToFastInfosetStAXSerializer
Serializes an XML input stream into FI document using StAX document serializer defined in the fastinfoset.stax package.
The sample demonstrates how to use StAXDocumentSerializer as a SAX handler and JAXP transformer to convert an XML file into a FI document. As shown in the sample, transforming a DOM source to SAX Result involves very little coding. However, the process may not be efficient due to the construction of DOM source. In the sample, a DOMSource is constructed out of an XML file input (see method getDOMSource) and a SAXResult is instantiated using an instance of SAX2StAXWriter as handlers (see method getSAXResult). Utility class SAX2StAXWriter extends DefaultHandler and implements LexicalHandler, which allows it to be used to handle SAX events. The source and result are then used by the JAXP transformer to transform the XML file to FI document which was passed in as OutputStream for the StAX serializer object. The XML inputstream is first transformed into a ByteArrayOutputStream that may be used for other processing. In this sample, we simply write it out into a file.
| Constructor Summary | |
|---|---|
XMLToFastInfosetStAXSerializer()
Creates a new instance of DocumentSerializer |
|
| Method Summary | |
|---|---|
static void |
main(String[] args)
Starts the sample. |
void |
write(File input,
File output)
Transform an XML file into a FI document. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLToFastInfosetStAXSerializer()
| Method Detail |
|---|
public void write(File input,
File output)
input - an XML file inputoutput - the FI document outputpublic static void main(String[] args)
args - XML input file name and FI output file name
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||