Class StaxSource

java.lang.Object
javax.xml.transform.sax.SAXSource
org.xbib.content.xml.stream.StaxSource
All Implemented Interfaces:
Source

public class StaxSource extends SAXSource
A JAXP Source implementation that wraps the specified XMLStreamReader or XMLEventReader for use by applications that expext a Source. The fact that StAXSource derives from SAXSource is an implementation detail. Thus in general applications are strongly discouraged from accessing methods defined on SAXSource. In particular:
  • The setXMLReader and setInputSource methods shall never be called.
  • The XMLReader object obtained by the getXMLReader method shall be used only for parsing the InputSource object returned by the getInputSource method.
  • The InputSource object obtained by the getInputSource method shall be used only for being parsed by the XMLReader object returned by the getXMLReader method.
Example:
 // create a StAXSource
 XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(args[0]));
 Source staxSource = new StAXSource(reader);

 // createa StreamResult
 Result streamResult = new StreamResult(System.out);

 // run the transform
 TransformerFactory.newInstance().newTransformer().transform(staxSource, streamResult);