public class OfflineSaxHandlerBase extends org.xml.sax.helpers.DefaultHandler
resolveEntity(String, String)
that works around a bug in the Java
SAX parser implementation:
If resolveEntity(String, String)
returns null
for a
given DTD (the default behavior of DefaultHandler
), the Java SAX
parser will try to download that DTD. This will fail on machines that have no
Internet connection or require a proxy to access the Internet or for DTDs
where the URI is not a valid URL. This class' default implementation instead
returns an empty InputSource
, which effectively causes the parser to
skip DTD validation.
Please note that downloading the DTD from the Internet is against the DTD
specification (as the DTD URI is not required to be a valid URL) and is
highly error-prone, resulting in a hard to interpret error message. It is
thus recommended you use this base class and never return null
from resolveEntity(String, String)
.Constructor and Description |
---|
OfflineSaxHandlerBase() |
Modifier and Type | Method and Description |
---|---|
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Default implementation that can be overwritten by subclasses.
|
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
public OfflineSaxHandlerBase()
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws java.io.IOException, org.xml.sax.SAXException
resolveEntity
in interface org.xml.sax.EntityResolver
resolveEntity
in class org.xml.sax.helpers.DefaultHandler
java.io.IOException
- may be thrown by subclasses.org.xml.sax.SAXException
- may be thrown by subclasses.