javanet.staxutils
Class StAXSource
java.lang.Object
javax.xml.transform.sax.SAXSource
javanet.staxutils.StAXSource
- All Implemented Interfaces:
- javax.xml.transform.Source
public class StAXSource
- extends javax.xml.transform.sax.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);
- Version:
- 1.0
- Author:
- Ryan.Shoemaker@Sun.COM
| Fields inherited from class javax.xml.transform.sax.SAXSource |
FEATURE |
|
Constructor Summary |
StAXSource(javax.xml.stream.XMLEventReader reader)
Creates a new Source for the given
XMLEventReader. |
StAXSource(javax.xml.stream.XMLStreamReader reader)
Creates a new Source for the given
XMLStreamReader. |
| Methods inherited from class javax.xml.transform.sax.SAXSource |
getInputSource, getSystemId, getXMLReader, setInputSource, setSystemId, setXMLReader, sourceToInputSource |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StAXSource
public StAXSource(javax.xml.stream.XMLStreamReader reader)
- Creates a new
Source for the given
XMLStreamReader.
The XMLStreamReader must be pointing at either a
XMLStreamConstants.START_DOCUMENT or
XMLStreamConstants.START_ELEMENT event.
- Parameters:
reader - XMLStreamReader that will be exposed as a Source
- Throws:
java.lang.IllegalArgumentException - iff the reader is null
java.lang.IllegalStateException - iff the reader is not pointing at either a
START_DOCUMENT or START_ELEMENT event
StAXSource
public StAXSource(javax.xml.stream.XMLEventReader reader)
- Creates a new
Source for the given
XMLEventReader.
The XMLEventReader must be pointing at either a
XMLStreamConstants.START_DOCUMENT or
XMLStreamConstants.START_ELEMENT event.
- Parameters:
reader - XMLEventReader that will be exposed as a Source
- Throws:
java.lang.IllegalArgumentException - iff the reader is null
java.lang.IllegalStateException - iff the reader is not pointing at either a
START_DOCUEMENT or START_ELEMENT event
Copyright © 2013. All Rights Reserved.