FastInfoset (FI) Samples


Listed here are a few samples demonstrating the FastInfoset implementation of SAX and StAX. To try out the samples, please follow the following steps:
  1. Get FastInfoset source and build the package. A FastInfoset.jar will be generated under <FastInfoset home>/dist. The Ant tasks for the samples have dependency on the jar file.
  2. Get the source and data files for the samples. Make sure to check out the whole samples package. All sources are under /src directory and XML files used in the samples are under /data directory.
  3. To run a sample, go to the samples directory and type ant <target>


CategorySamples (and Ant target)Description
SAX SAXParsingSample The sample parses data/inv1a.finf as specified in the build.xml and handle SAX events to display corresponding XML content.
SAXSerializingSample Directly using the FastInfoset SAX Serializer, the sample writes a small piece of XML infoset taken from inv1a.xml into a FastInfoset file called data/inv1c.finf. For details of the XML infoset, please refer to samples JavaDoc.
StAX StAXEventReadingSample Demonstrate the use of FI StAX EventReader to read FI and XML files. The sample reads data/inv1a.xml and data/inv1a.finf and displays event types as it goes through the documents.
To try the sample with other xml files, edit the build.xml and change the "simple-xml-file" and "simple-finf-file" properties to point to the files you may want to test.
StAXParsingSample Demonstrate the use of FI StAX StreamReader to read FI files. The sample reads data/inv1.finf and displays contents as it goes through the document.
Similar to the above EventReader, if you want to run the sample on other files, you would need to change the "simple-xml-file" and "simple-finf-file" properties to point to the files you may want to test. The finf file specified will be generated automatically.
StAXSerializingSample Directly using the FastInfoset StAX Serializer, the sample writes a small piece of XML infoset taken from inv1a.xml into a FastInfoset file called data/inv1c.finf. For details of the XML infoset, please refer to samples JavaDoc.
Transform XMLToFastInfosetSAXSerializer 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.
XMLToFastInfosetStAXSerializer 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.
Encoding/Decoding typed data PrimitiveTypesWithElementContentSample The sample demonstrates how to use the SAX serializers/parsers to encode and decode type primitive data that is element content. The typed data, represented as Java primitive types, is encoded into the FI document in efficient binary form and may be decoded into the same Java primitive types, or into lexical values (which depending on the handlers that are registered with the SAX parser.