Class JAXPParser.XMLReaderEx
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,XMLFilter
,XMLReader
- Enclosing class:
JAXPParser
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionresolveEntity
(String publicId, String systemId) Resolves entities and reports user-friendly error messages.void
setDocumentLocator
(Locator locator) Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
-
Field Details
-
locator
-
-
Constructor Details
-
XMLReaderEx
XMLReaderEx(XMLReader parent)
-
-
Method Details
-
resolveEntity
Resolves entities and reports user-friendly error messages.Some XML parser (at least Xerces) does not report much information when it fails to resolve an entity, which is often quite frustrating. For example, if you are behind a firewall and the schema contains a reference to www.w3.org, and there is no entity resolver, the parser will just throw an IOException that doesn't contain any information about where that reference occurs nor what it is accessing.
By implementing an EntityResolver and resolving the reference by ourselves, we can report an error message with all the necessary information to fix the problem.
Note that we still need to the client-specified entity resolver to let the application handle entity resolution. Here we just catch an IOException and add more information.
- Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classXMLFilterImpl
- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classXMLFilterImpl
-