Feeding the report data to a SAX content handler

You can use a SAX content handler to directly create the XML. This method does not use the data model approach.

The Genero Report Engine expects the data to be shipped to its content handler which is an implementation of an org.xml.sax.ContentHandler which is part of the standard J2SE offering.

The interface allows to ship arbitrarily sized XML documents with a very low memory consumption to the engine. This is achieved via a call interface providing the three basic methods “startElement”, “characters” and “endElement”.

As an example consider the following XML document:
<?xml version ="1.0" encoding="UTF-8"?>
  <Item>Item 1</Item>
  <Item>Item 2</Item>
This document is send to the content handler in a simplified manner as follows:
ContentHandler handler=processor.createContentHandler();
handler.characters("Item 1");
handler.characters("Item 2");

This low level Interface is universally usable to serialize data to the engine but typically it is more practical to use a more high level interface such as JAXB.

If you use this method, you cannot use schemagen to create the data schema file, a necessary input for the report design tools. In this situation, you must create the data schema by hand.