Class ResolvingXMLFilter

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader
    Direct Known Subclasses:
    ResolvingXMLReader

    public class ResolvingXMLFilter
    extends org.xml.sax.helpers.XMLFilterImpl
    An implementation of XMLFilter that performs catalog resolution.

    This class implements the oasis-xml-catalog processing instruction if the underlying resolver allows it.

    Each instance constructed with the zero-argument constructor uses a shared, static resolver. This avoids paying the instantiation cost each time a parse is created.

    • Constructor Summary

      Constructors 
      Constructor Description
      ResolvingXMLFilter()
      Construct a filter with the default resolver.
      ResolvingXMLFilter​(org.xml.sax.XMLReader parent, Resolver resolver)
      Construct an XML filter with the specified parent and resolver.
      ResolvingXMLFilter​(Resolver resolver)
      Construct an XML filter with the specified resolver.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Resolver getResolver()
      Provide access to the underlying Catalog.
      void notationDecl​(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
      SAX DTDHandler API.
      void parse​(java.lang.String systemId)
      SAX XMLReader API.
      void parse​(org.xml.sax.InputSource input)
      Parse a document.
      void processingInstruction​(java.lang.String target, java.lang.String pidata)
      SAX ContentHandler API.
      org.xml.sax.InputSource resolveEntity​(java.lang.String publicId, java.lang.String systemId)
      Implements the resolveEntity method for the SAX interface, using an underlying CatalogResolver to do the real work.
      org.xml.sax.InputSource resolveEntity​(java.lang.String name, java.lang.String publicId, java.lang.String baseURI, java.lang.String systemId)
      Implements the EntityResolver2 interface.
      void startElement​(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
      SAX ContentHandler API.
      void unparsedEntityDecl​(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
      SAX DTDHandler API.
      • Methods inherited from class org.xml.sax.helpers.XMLFilterImpl

        characters, endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, warning
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResolvingXMLFilter

        public ResolvingXMLFilter()
        Construct a filter with the default resolver.
      • ResolvingXMLFilter

        public ResolvingXMLFilter​(Resolver resolver)
        Construct an XML filter with the specified resolver.
        Parameters:
        resolver - The resolver
      • ResolvingXMLFilter

        public ResolvingXMLFilter​(org.xml.sax.XMLReader parent,
                                  Resolver resolver)
        Construct an XML filter with the specified parent and resolver.
        Parameters:
        parent - The parent reader
        resolver - The resolver
    • Method Detail

      • getResolver

        public Resolver getResolver()
        Provide access to the underlying Catalog.
        Returns:
        The underlying resolver
      • parse

        public void parse​(org.xml.sax.InputSource input)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
        Parse a document.

        If the input doesn't have an associated open stream, this class will attempt to find the URI of the input in the catalog.

        Specified by:
        parse in interface org.xml.sax.XMLReader
        Overrides:
        parse in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
      • parse

        public void parse​(java.lang.String systemId)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
        SAX XMLReader API.
        Specified by:
        parse in interface org.xml.sax.XMLReader
        Overrides:
        parse in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        java.io.IOException
        org.xml.sax.SAXException
        See Also:
        parse(InputSource)
      • resolveEntity

        public org.xml.sax.InputSource resolveEntity​(java.lang.String publicId,
                                                     java.lang.String systemId)
                                              throws org.xml.sax.SAXException,
                                                     java.io.IOException
        Implements the resolveEntity method for the SAX interface, using an underlying CatalogResolver to do the real work.
        Specified by:
        resolveEntity in interface org.xml.sax.EntityResolver
        Overrides:
        resolveEntity in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • resolveEntity

        public org.xml.sax.InputSource resolveEntity​(java.lang.String name,
                                                     java.lang.String publicId,
                                                     java.lang.String baseURI,
                                                     java.lang.String systemId)
                                              throws org.xml.sax.SAXException,
                                                     java.io.IOException
        Implements the EntityResolver2 interface.
        Parameters:
        name - The entity name
        publicId - The entity public identifier
        baseURI - The base URI
        systemId - The entity system identifier
        Returns:
        The resolved entity
        Throws:
        org.xml.sax.SAXException - If a SAX error occurs
        java.io.IOException - If an I/O error occurs
      • notationDecl

        public void notationDecl​(java.lang.String name,
                                 java.lang.String publicId,
                                 java.lang.String systemId)
                          throws org.xml.sax.SAXException
        SAX DTDHandler API.

        Captured here only to detect the end of the prolog so that we can ignore subsequent oasis-xml-catalog PIs. Otherwise the events are just passed through.

        Specified by:
        notationDecl in interface org.xml.sax.DTDHandler
        Overrides:
        notationDecl in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • unparsedEntityDecl

        public void unparsedEntityDecl​(java.lang.String name,
                                       java.lang.String publicId,
                                       java.lang.String systemId,
                                       java.lang.String notationName)
                                throws org.xml.sax.SAXException
        SAX DTDHandler API.

        Captured here only to detect the end of the prolog so that we can ignore subsequent oasis-xml-catalog PIs. Otherwise the events are just passed through.

        Specified by:
        unparsedEntityDecl in interface org.xml.sax.DTDHandler
        Overrides:
        unparsedEntityDecl in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • startElement

        public void startElement​(java.lang.String uri,
                                 java.lang.String localName,
                                 java.lang.String qName,
                                 org.xml.sax.Attributes atts)
                          throws org.xml.sax.SAXException
        SAX ContentHandler API.

        Captured here only to detect the end of the prolog so that we can ignore subsequent oasis-xml-catalog PIs. Otherwise the events are just passed through.

        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException
      • processingInstruction

        public void processingInstruction​(java.lang.String target,
                                          java.lang.String pidata)
                                   throws org.xml.sax.SAXException
        SAX ContentHandler API.

        Detect and use the oasis-xml-catalog PI if it occurs.

        Specified by:
        processingInstruction in interface org.xml.sax.ContentHandler
        Overrides:
        processingInstruction in class org.xml.sax.helpers.XMLFilterImpl
        Throws:
        org.xml.sax.SAXException