samples.transform
Class XMLToFastInfosetSAXSerializer

java.lang.Object
  extended by samples.transform.XMLToFastInfosetSAXSerializer

public class XMLToFastInfosetSAXSerializer
extends Object

Serializes an XML input stream into FI document using SAXDocumentSerializer defined in the fastinfoset.sax package.

The sample demonstrates how to use SAXDocumentSerializer 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 instantiated using an instance of SAXDocumentSerializer as the handler which takes a FI document as OutputStream (see method getSAXResult). The sample then calls transformer's tranform method to convert the XML file into the FI document.


Constructor Summary
XMLToFastInfosetSAXSerializer()
          Creates a new instance of FISerializer
 
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

XMLToFastInfosetSAXSerializer

public XMLToFastInfosetSAXSerializer()
Creates a new instance of FISerializer

Method Detail

write

public void write(File input,
                  File output)
Transform an XML file into a FI document.

Parameters:
input - an XML file input
output - the FI document output

main

public static void main(String[] args)
Starts the sample

Parameters:
args - XML input file name and FI output document name


Copyright © 2012 Oracle Corpration. All Rights Reserved.