Class ActiveSAXSource

  • All Implemented Interfaces:
    javax.xml.transform.Source, ActiveSource

    public class ActiveSAXSource
    extends javax.xml.transform.sax.SAXSource
    implements ActiveSource
    This class extends the standard SAXSource class by providing a deliver(Receiver, ParseOptions) method, meaning that Saxon can treat it just like any other ActiveSource implementation.

    This makes it easier to extract code from the product that's specific to the Java platform (in particular, support for SAX APIs).

    • Field Summary

      • Fields inherited from class javax.xml.transform.sax.SAXSource

    • Constructor Summary

      Constructor Description
      ActiveSAXSource​(javax.xml.transform.sax.SAXSource source)
      Construct an ActiveSAXSource from a SAXSource
      ActiveSAXSource​(org.xml.sax.InputSource inputSource, Configuration config)  
      ActiveSAXSource​(org.xml.sax.XMLReader parser, org.xml.sax.InputSource source)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void configureParser​(org.xml.sax.XMLReader parser)
      Configure a SAX parser to ensure it has the correct namespace properties set
      void deliver​(Receiver receiver, ParseOptions options)
      Deliver the content of the source to a supplied Receiver.
      void setParserPool​(java.util.function.Consumer<org.xml.sax.XMLReader> parserPool)
      Supply a mechanism to recycle the XMLReader after use
      • Methods inherited from class javax.xml.transform.sax.SAXSource

        getInputSource, getSystemId, getXMLReader, isEmpty, setInputSource, setSystemId, setXMLReader, sourceToInputSource
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.xml.transform.Source

        getSystemId, isEmpty, setSystemId
    • Constructor Detail

      • ActiveSAXSource

        public ActiveSAXSource​(org.xml.sax.XMLReader parser,
                               org.xml.sax.InputSource source)
      • ActiveSAXSource

        public ActiveSAXSource​(javax.xml.transform.sax.SAXSource source)
                        throws java.lang.IllegalArgumentException,
        Construct an ActiveSAXSource from a SAXSource
        source - the input source object, whose properties are copied. The source must include a non-null XMLReader.
      • ActiveSAXSource

        public ActiveSAXSource​(org.xml.sax.InputSource inputSource,
                               Configuration config)
    • Method Detail

      • setParserPool

        public void setParserPool​(java.util.function.Consumer<org.xml.sax.XMLReader> parserPool)
        Supply a mechanism to recycle the XMLReader after use
        parserPool - a place to return the parser after parsing is complete
      • deliver

        public void deliver​(Receiver receiver,
                            ParseOptions options)
                     throws XPathException
        Description copied from interface: ActiveSource
        Deliver the content of the source to a supplied Receiver.

        For many (but not all) implementations of Source, this method consumes the source and can therefore only be called once.

        Specified by:
        deliver in interface ActiveSource
        receiver - the receiver to which events representing the parsed XML document will be sent
        options - options for parsing the source
        XPathException - if parsing fails for any reason. The detailed diagnostics will have been sent to the error reporter.
      • configureParser

        public static void configureParser​(org.xml.sax.XMLReader parser)
                                    throws XPathException
        Configure a SAX parser to ensure it has the correct namespace properties set
        parser - the parser to be configured
        XPathException - if the parser cannot be configured to the required settings (namespaces=true, namespace-prefixes=false). Note that the SAX specification requires every XMLReader to support these settings, so this error implies that the XMLReader is non-conformant; this is not uncommon in cases where the XMLReader is user-written.