SAXSourcepublic class SAXSource extends Object implements SourceActs as an holder for SAX-style Source.
Note that XSLT requires namespace support. Attempting to transform an
input source that is not
generated with a namespace-aware parser may result in errors.
Parsers can be made namespace aware by calling the
{@link javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness)} method. |
Fields Summary |
---|
public static final String | FEATUREIf {@link javax.xml.transform.TransformerFactory#getFeature}
returns true when passed this value as an argument,
the Transformer supports Source input of this type. | private XMLReader | readerThe XMLReader to be used for the source tree input. May be null. | private InputSource | inputSource The SAX InputSource to be used for the source tree input.
Should not be null. |
Constructors Summary |
---|
public SAXSource()Zero-argument default constructor. If this constructor is used, and
no SAX source is set using
{@link #setInputSource(InputSource inputSource)} , then the
Transformer will
create an empty source {@link org.xml.sax.InputSource} using
{@link org.xml.sax.InputSource#InputSource() new InputSource()}.
| public SAXSource(XMLReader reader, InputSource inputSource)Create a SAXSource , using an {@link org.xml.sax.XMLReader}
and a SAX InputSource. The {@link javax.xml.transform.Transformer}
or {@link javax.xml.transform.sax.SAXTransformerFactory} will set itself
to be the reader's {@link org.xml.sax.ContentHandler}, and then will call
reader.parse(inputSource).
this.reader = reader;
this.inputSource = inputSource;
| public SAXSource(InputSource inputSource)Create a SAXSource , using a SAX InputSource .
The {@link javax.xml.transform.Transformer} or
{@link javax.xml.transform.sax.SAXTransformerFactory} creates a
reader via {@link org.xml.sax.helpers.XMLReaderFactory}
(if setXMLReader is not used), sets itself as
the reader's {@link org.xml.sax.ContentHandler}, and calls
reader.parse(inputSource).
this.inputSource = inputSource;
|
Methods Summary |
---|
public org.xml.sax.InputSource | getInputSource()Get the SAX InputSource to be used for the Source.
return inputSource;
| public java.lang.String | getSystemId()Get the base ID (URI or system ID) from where URIs
will be resolved.
if (inputSource == null) {
return null;
} else {
return inputSource.getSystemId();
}
| public org.xml.sax.XMLReader | getXMLReader()Get the XMLReader to be used for the Source.
return reader;
| public void | setInputSource(org.xml.sax.InputSource inputSource)Set the SAX InputSource to be used for the Source.
this.inputSource = inputSource;
| public void | setSystemId(java.lang.String systemId)Set the system identifier for this Source. If an input source
has already been set, it will set the system ID or that
input source, otherwise it will create a new input source.
The system identifier is optional if there is a byte stream
or a character stream, but it is still useful to provide one,
since the application can use it to resolve relative URIs
and can include it in error messages and warnings (the parser
will attempt to open a connection to the URI only if
no byte stream or character stream is specified).
if (null == inputSource) {
inputSource = new InputSource(systemId);
} else {
inputSource.setSystemId(systemId);
}
| public void | setXMLReader(org.xml.sax.XMLReader reader)Set the XMLReader to be used for the Source.
this.reader = reader;
| public static org.xml.sax.InputSource | sourceToInputSource(javax.xml.transform.Source source)Attempt to obtain a SAX InputSource object from a Source
object.
if (source instanceof SAXSource) {
return ((SAXSource) source).getInputSource();
} else if (source instanceof StreamSource) {
StreamSource ss = (StreamSource) source;
InputSource isource = new InputSource(ss.getSystemId());
isource.setByteStream(ss.getInputStream());
isource.setCharacterStream(ss.getReader());
isource.setPublicId(ss.getPublicId());
return isource;
} else {
return null;
}
|
|