Source
public class SAXSource extends Object implements Source
Acts 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 SAXParserFactory.setNamespaceAware(boolean awareness)
method.
Modifier and Type | Field | Description |
---|---|---|
static final String |
FEATURE |
If TransformerFactory.getFeature(java.lang.String) returns true when passed this value as an argument, the Transformer supports Source input of this type. |
Constructor | Description |
---|---|
SAXSource() |
Zero-argument default constructor. |
SAXSource |
Create a SAXSource , using a SAX InputSource . |
SAXSource |
Create a SAXSource , using an XMLReader and a SAX InputSource. |
Modifier and Type | Method | Description |
---|---|---|
InputSource |
getInputSource() |
Get the SAX InputSource to be used for the Source. |
String |
getSystemId() |
Get the base ID (URI or system ID) from where URIs will be resolved. |
XMLReader |
getXMLReader() |
Get the XMLReader to be used for the Source. |
boolean |
isEmpty() |
Indicates whether the SAXSource object is empty. |
void |
setInputSource |
Set the SAX InputSource to be used for the Source. |
void |
setSystemId |
Set the system identifier for this Source. |
void |
setXMLReader |
Set the XMLReader to be used for the Source. |
static InputSource |
sourceToInputSource |
Attempt to obtain a SAX InputSource object from a Source object. |
public static final String FEATURE
TransformerFactory.getFeature(java.lang.String)
returns true when passed this value as an argument, the Transformer supports Source input of this type.public SAXSource()
Zero-argument default constructor. If this constructor is used, and no SAX source is set using setInputSource(InputSource inputSource)
, then the Transformer
will create an empty source InputSource
using new InputSource()
.
public SAXSource(XMLReader reader, InputSource inputSource)
SAXSource
, using an XMLReader
and a SAX InputSource. The Transformer
or SAXTransformerFactory
will set itself to be the reader's ContentHandler
, and then will call reader.parse(inputSource).reader
- An XMLReader to be used for the parse.inputSource
- A SAX input source reference that must be non-null and that will be passed to the reader parse method.public SAXSource(InputSource inputSource)
SAXSource
, using a SAX InputSource
. The Transformer
or SAXTransformerFactory
creates a reader (if setXMLReader is not used), sets itself as the reader's ContentHandler
, and calls reader.parse(inputSource).inputSource
- An input source reference that must be non-null and that will be passed to the parse method of the reader.public void setXMLReader(XMLReader reader)
reader
- A valid XMLReader or XMLFilter reference.public XMLReader getXMLReader()
public void setInputSource(InputSource inputSource)
inputSource
- A valid InputSource reference.public InputSource getInputSource()
public void setSystemId(String systemId)
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).
setSystemId
in interface Source
systemId
- The system identifier as a URI string.public String getSystemId()
Get the base ID (URI or system ID) from where URIs will be resolved.
getSystemId
in interface Source
Source
, or null
.public static InputSource sourceToInputSource(Source source)
source
- Must be a non-null Source reference.public boolean isEmpty()
SAXSource
object is empty. Empty is defined as follows: InputSource
are null
; null
, and the InputSource
is empty.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.xml/javax/xml/transform/sax/SAXSource.html