Class ResolvingXMLFilter
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,XMLFilter
,XMLReader
- Direct Known Subclasses:
ResolvingXMLReader
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.
- Author:
- ndw
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ResolverLogger
protected Resolver
protected static Resolver
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a filter with the default resolver.ResolvingXMLFilter
(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
Modifier and TypeMethodDescriptionProvide access to the underlying Catalog.void
notationDecl
(String name, String publicId, String systemId) SAX DTDHandler API.void
SAX XMLReader API.void
parse
(InputSource input) Parse a document.void
processingInstruction
(String target, String pidata) SAX ContentHandler API.resolveEntity
(String publicId, String systemId) Implements theresolveEntity
method for the SAX interface, using an underlying CatalogResolver to do the real work.resolveEntity
(String name, String publicId, String baseURI, String systemId) Implements theEntityResolver2
interface.void
startElement
(String uri, String localName, String qName, Attributes atts) SAX ContentHandler API.void
unparsedEntityDecl
(String name, String publicId, String systemId, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
logger
-
staticResolver
-
resolver
-
-
Constructor Details
-
ResolvingXMLFilter
public ResolvingXMLFilter()Construct a filter with the default resolver. -
ResolvingXMLFilter
Construct an XML filter with the specified resolver.- Parameters:
resolver
- The resolver
-
ResolvingXMLFilter
Construct an XML filter with the specified parent and resolver.- Parameters:
parent
- The parent readerresolver
- The resolver
-
-
Method Details
-
getResolver
Provide access to the underlying Catalog.- Returns:
- The underlying resolver
-
parse
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 interfaceXMLReader
- Overrides:
parse
in classXMLFilterImpl
- Throws:
IOException
SAXException
-
parse
SAX XMLReader API.- Specified by:
parse
in interfaceXMLReader
- Overrides:
parse
in classXMLFilterImpl
- Throws:
IOException
SAXException
- See Also:
-
resolveEntity
Implements theresolveEntity
method for the SAX interface, using an underlying CatalogResolver to do the real work.- Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classXMLFilterImpl
- Throws:
SAXException
IOException
-
resolveEntity
public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException Implements theEntityResolver2
interface.- Parameters:
name
- The entity namepublicId
- The entity public identifierbaseURI
- The base URIsystemId
- The entity system identifier- Returns:
- The resolved entity
- Throws:
SAXException
- If a SAX error occursIOException
- If an I/O error occurs
-
notationDecl
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 interfaceDTDHandler
- Overrides:
notationDecl
in classXMLFilterImpl
- Throws:
SAXException
-
unparsedEntityDecl
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws 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 interfaceDTDHandler
- Overrides:
unparsedEntityDecl
in classXMLFilterImpl
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws 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 interfaceContentHandler
- Overrides:
startElement
in classXMLFilterImpl
- Throws:
SAXException
-
processingInstruction
SAX ContentHandler API.Detect and use the oasis-xml-catalog PI if it occurs.
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classXMLFilterImpl
- Throws:
SAXException
-