Class SAXSource

java.lang.Object
javax.xml.transform.sax.SAXSource
All Implemented Interfaces:
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.

Since:
1.4
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    If TransformerFactory.getFeature(String) returns true when passed this value as an argument, the Transformer supports Source input of this type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Zero-argument default constructor.
    SAXSource(InputSource inputSource)
    Create a SAXSource, using a SAX InputSource.
    SAXSource(XMLReader reader, InputSource inputSource)
    Create a SAXSource, using an XMLReader and a SAX InputSource.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the SAX InputSource to be used for the Source.
    Get the base ID (URI or system ID) from where URIs will be resolved.
    Get the XMLReader to be used for the Source.
    boolean
    Indicates whether the SAXSource object is empty.
    void
    Set the SAX InputSource to be used for the Source.
    void
    setSystemId(String systemId)
    Set the system identifier for this Source.
    void
    Set the XMLReader to be used for the Source.
    Attempt to obtain a SAX InputSource object from a Source object.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Creates and returns a copy of this object.
    boolean
    Indicates whether some other object is "equal to" this one.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Finalization is deprecated and subject to removal in a future release.
    final Class<?>
    Returns the runtime class of this Object.
    int
    Returns a hash code value for this object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
    final void
    wait(long timeoutMillis)
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
    final void
    wait(long timeoutMillis, int nanos)
    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  • Field Details

  • Constructor Details

  • Method Details

    • setXMLReader

      public void setXMLReader(XMLReader reader)
      Set the XMLReader to be used for the Source.
      Parameters:
      reader - A valid XMLReader or XMLFilter reference.
    • getXMLReader

      public XMLReader getXMLReader()
      Get the XMLReader to be used for the Source.
      Returns:
      A valid XMLReader or XMLFilter reference, or null.
    • setInputSource

      public void setInputSource(InputSource inputSource)
      Set the SAX InputSource to be used for the Source.
      Parameters:
      inputSource - A valid InputSource reference.
    • getInputSource

      public InputSource getInputSource()
      Get the SAX InputSource to be used for the Source.
      Returns:
      A valid InputSource reference, or null.
    • setSystemId

      public void setSystemId(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).

      Specified by:
      setSystemId in interface Source
      Parameters:
      systemId - The system identifier as a URI string.
    • getSystemId

      public String getSystemId()

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

      Specified by:
      getSystemId in interface Source
      Returns:
      Base URL for the Source, or null.
    • sourceToInputSource

      public static InputSource sourceToInputSource(Source source)
      Attempt to obtain a SAX InputSource object from a Source object.
      Parameters:
      source - Must be a non-null Source reference.
      Returns:
      An InputSource, or null if Source can not be converted.
    • isEmpty

      public boolean 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.
      Specified by:
      isEmpty in interface Source
      Returns:
      true if the SAXSource object is empty, false otherwise