Pull processing

Saxon has for a number of releases included a sample module StaxBridge that allows Saxon to take input from a StAX parser (JSR 173) (specifically from an XMLStreamReader). This component is now included in the product, as class net.sf.saxon.pull.StaxBridge.

To see how to use Saxon with the StAX parser, see the examples in PullExamples.java in the samples/java directory. A StaxBridge object is like a SAXSource object in that it encapsulates a reference to the parser and a reference to the file being parsed; it implements the JAXP Source interface so it can be used directly as an argument to methods like Transformer.transform().

This code has been tested with the Sun implementation, SJSXP, and with the Woodstox parser. In both cases the parser must be separately installed. Note that if you want to recompile the Saxon source code and you do not have SJSXP installed, you can simply remove the StaxBridge module from the compilation.

Normally the StaxBridge class will pick up whichever StAX parser is present on the Java classpath. To choose a specific parser, set the system property javax.xml.stream.XMLInputFactory to the relevant implementation class. For SJSXP this is com.sun.xml.stream.ZephyrParserFactory. For Woodstox it is com.ctc.wstx.stax.WstxInputFactory.