APIdia Launch Partner
Top Description Fields Constructors Methods
javax.xml.transform.sax

public Class SAXSource

extends Object
implements Source
Class Inheritance
All Implemented Interfaces
javax.xml.transform.Source
Imports
javax.xml.transform.Source, javax.xml.transform.stream.StreamSource, org.xml.sax.InputSource, .XMLReader

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 javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness) method.

Author
Jeff Suttor
Since
1.4

Field Summary

Modifier and TypeField and Description
public static final String
FEATURE

If javax.xml.transform.TransformerFactory#getFeature returns true when passed this value as an argument, the Transformer supports Source input of this type.

private InputSource
inputSource

The SAX InputSource to be used for the source tree input.

private XMLReader
reader

The XMLReader to be used for the source tree input.

Constructor Summary

AccessConstructor and Description
public
SAXSource()

Zero-argument default constructor.

public
SAXSource(XMLReader
An XMLReader to be used for the parse.
reader
,
InputSource
A SAX input source reference that must be non-null and that will be passed to the reader parse method.
inputSource
)

Create a SAXSource, using an org.xml.sax.XMLReader and a SAX InputSource.

public
SAXSource(InputSource
An input source reference that must be non-null and that will be passed to the parse method of the reader.
inputSource
)

Create a SAXSource, using a SAX InputSource.

Method Summary

Modifier and TypeMethod and Description
public InputSource

Returns:

A valid InputSource reference, or null.
getInputSource
()

Get the SAX InputSource to be used for the Source.

public String

Returns:

Base URL for the Source, or null.
getSystemId
()

Implements javax.xml.transform.Source.getSystemId.

Get the base ID (URI or system ID) from where URIs will be resolved.

public XMLReader

Returns:

A valid XMLReader or XMLFilter reference, or null.
getXMLReader
()

Get the XMLReader to be used for the Source.

public boolean

Returns:

true if the SAXSource object is empty, false otherwise
isEmpty
()

Overrides default javax.xml.transform.Source.isEmpty.

Indicates whether the SAXSource object is empty.

public void
setInputSource(InputSource
A valid InputSource reference.
inputSource
)

Set the SAX InputSource to be used for the Source.

public void
setSystemId(String
The system identifier as a URI string.
systemId
)

Implements javax.xml.transform.Source.setSystemId.

Set the system identifier for this Source.

public void
setXMLReader(XMLReader
A valid XMLReader or XMLFilter reference.
reader
)

Set the XMLReader to be used for the Source.

public static InputSource

Returns:

An InputSource, or null if Source can not be converted.
sourceToInputSource
(Source
Must be a non-null Source reference.
source
)

Attempt to obtain a SAX InputSource object from a Source object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FEATUREback to summary
public static final String FEATURE

If javax.xml.transform.TransformerFactory#getFeature returns true when passed this value as an argument, the Transformer supports Source input of this type.

inputSourceback to summary
private InputSource inputSource

The SAX InputSource to be used for the source tree input. Should not be null.

readerback to summary
private XMLReader reader

The XMLReader to be used for the source tree input. May be null.

Constructor Detail

SAXSourceback to summary
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 org.xml.sax.InputSource using new InputSource().

See Also
javax.xml.transform.Transformer#transform(Source xmlSource, Result outputTarget)
SAXSourceback to summary
public SAXSource(XMLReader reader, InputSource inputSource)

Create a SAXSource, using an org.xml.sax.XMLReader and a SAX InputSource. The javax.xml.transform.Transformer or javax.xml.transform.sax.SAXTransformerFactory will set itself to be the reader's org.xml.sax.ContentHandler, and then will call reader.parse(inputSource).

Parameters
reader:XMLReader

An XMLReader to be used for the parse.

inputSource:InputSource

A SAX input source reference that must be non-null and that will be passed to the reader parse method.

SAXSourceback to summary
public SAXSource(InputSource inputSource)

Create a SAXSource, using a SAX InputSource. The javax.xml.transform.Transformer or javax.xml.transform.sax.SAXTransformerFactory creates a reader (if setXMLReader is not used), sets itself as the reader's org.xml.sax.ContentHandler, and calls reader.parse(inputSource).

Parameters
inputSource:InputSource

An input source reference that must be non-null and that will be passed to the parse method of the reader.

Method Detail

getInputSourceback to summary
public InputSource getInputSource()

Get the SAX InputSource to be used for the Source.

Returns:InputSource

A valid InputSource reference, or null.

getSystemIdback to summary
public String getSystemId()

Implements javax.xml.transform.Source.getSystemId.

Get the base ID (URI or system ID) from where URIs will be resolved.

Returns:String

Base URL for the Source, or null.

Annotations
@Override
getXMLReaderback to summary
public XMLReader getXMLReader()

Get the XMLReader to be used for the Source.

Returns:XMLReader

A valid XMLReader or XMLFilter reference, or null.

isEmptyback to summary
public boolean isEmpty()

Overrides default javax.xml.transform.Source.isEmpty.

Indicates whether the SAXSource object is empty. Empty is defined as follows:

  • if the system identifier and InputSource are null;
  • if the system identifier is null, and the InputSource is empty.
Returns:boolean

true if the SAXSource object is empty, false otherwise

Annotations
@Override
setInputSourceback to summary
public void setInputSource(InputSource inputSource)

Set the SAX InputSource to be used for the Source.

Parameters
inputSource:InputSource

A valid InputSource reference.

setSystemIdback to summary
public void setSystemId(String systemId)

Implements javax.xml.transform.Source.setSystemId.

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).

Parameters
systemId:String

The system identifier as a URI string.

Annotations
@Override
setXMLReaderback to summary
public void setXMLReader(XMLReader reader)

Set the XMLReader to be used for the Source.

Parameters
reader:XMLReader

A valid XMLReader or XMLFilter reference.

sourceToInputSourceback to summary
public static InputSource sourceToInputSource(Source source)

Attempt to obtain a SAX InputSource object from a Source object.

Parameters
source:Source

Must be a non-null Source reference.

Returns:InputSource

An InputSource, or null if Source can not be converted.