java.lang.Object | +--org.xml.sax.helpers.XMLReaderAdapter
Adapt a SAX2 XMLReader as a SAX1 Parser.
This module, both source code and documentation, is in the Public Domain, and comes withNO WARRANTY.
This class wraps a SAX2XMLReader
and makes it act as a SAX1Parser
. The XMLReader must support a true value for the http://xml.org/sax/features/namespace-prefixes property or parsing will fail with aSAXException
; if the XMLReader supports a false value for the http://xml.org/sax/features/namespaces property, that will also be used to improve efficiency.
Parser
,XMLReader
XMLReaderAdapter() Create a new adapter. | |
XMLReaderAdapter(XMLReader xmlReader) Create a new adapter. |
characters(char[] ch, int start, int length) Adapt a SAX2 characters event. | |
endDocument() End document event. | |
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) Adapt a SAX2 end element event. | |
endPrefixMapping(java.lang.String prefix) Adapt a SAX2 end prefix mapping event. | |
ignorableWhitespace(char[] ch, int start, int length) Adapt a SAX2 ignorable whitespace event. | |
parse(InputSource input) Parse the document. | |
parse(java.lang.String systemId) Parse the document. | |
processingInstruction(java.lang.String target, java.lang.String data) Adapt a SAX2 processing instruction event. | |
setDocumentHandler(DocumentHandler handler) Register the SAX1 document event handler. | |
setDocumentLocator(Locator locator) Set a document locator. | |
setDTDHandler(DTDHandler handler) Register the DTD event handler. | |
setEntityResolver(EntityResolver resolver) Register the entity resolver. | |
setErrorHandler(ErrorHandler handler) Register the error event handler. | |
setLocale(java.util.Locale locale) Set the locale for error reporting. | |
skippedEntity(java.lang.String name) Adapt a SAX2 skipped entity event. | |
startDocument() Start document event. | |
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName,Attributes atts) Adapt a SAX2 start element event. | |
startPrefixMapping(java.lang.String prefix, java.lang.String uri) Adapt a SAX2 start prefix mapping event. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
publicXMLReaderAdapter() throwsSAXException
Use the "org.xml.sax.driver" property to locate the SAX2 driver to embed.
SAXException
- If the embedded driver cannot be instantiated or if the org.xml.sax.driver property is not specified.publicXMLReaderAdapter(XMLReader xmlReader)
Create a new adapter, wrapped around a SAX2 XMLReader. The adapter will make the XMLReader act like a SAX1 Parser.
xmlReader
- The SAX2 XMLReader to wrap.java.lang.NullPointerException
- If the argument is null.public voidsetLocale(java.util.Locale locale) throwsSAXException
This is not supported in SAX2, and will always throw an exception.
setLocale
in interfaceParser
The
- locale for error reporting.Parser.setLocale(java.util.Locale)
public voidsetEntityResolver(EntityResolver resolver)
setEntityResolver
in interfaceParser
resolver
- The new resolver.Parser.setEntityResolver(org.xml.sax.EntityResolver)
public voidsetDTDHandler(DTDHandler handler)
setDTDHandler
in interfaceParser
handler
- The new DTD event handler.Parser.setDTDHandler(org.xml.sax.DTDHandler)
public voidsetDocumentHandler(DocumentHandler handler)
Note that the SAX1 document handler has no Namespace support.
setDocumentHandler
in interfaceParser
handler
- The new SAX1 document event handler.Parser.setDocumentHandler(org.xml.sax.DocumentHandler)
public voidsetErrorHandler(ErrorHandler handler)
setErrorHandler
in interfaceParser
handler
- The new error event handler.Parser.setErrorHandler(org.xml.sax.ErrorHandler)
public voidparse(java.lang.String systemId) throws java.io.IOException,SAXException
This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property.
parse
in interfaceParser
systemId
- The absolute URL of the document.java.io.IOException
- If there is a problem reading the raw content of the document.SAXException
- If there is a problem processing the document.parse(org.xml.sax.InputSource)
,Parser.parse(java.lang.String)
public voidparse(InputSource input) throws java.io.IOException,SAXException
This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property.
parse
in interfaceParser
input
- An input source for the document.java.io.IOException
- If there is a problem reading the raw content of the document.SAXException
- If there is a problem processing the document.parse(java.lang.String)
,Parser.parse(org.xml.sax.InputSource)
public voidsetDocumentLocator(Locator locator)
setDocumentLocator
in interfaceContentHandler
locator
- The document locator.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public voidstartDocument() throwsSAXException
startDocument
in interfaceContentHandler
SAXException
- The client may raise a processing exception.ContentHandler.startDocument()
public voidendDocument() throwsSAXException
endDocument
in interfaceContentHandler
SAXException
- The client may raise a processing exception.ContentHandler.endDocument()
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)
startPrefixMapping
in interfaceContentHandler
prefix
- The prefix being mapped.uri
- The Namespace URI being mapped to.ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
public voidendPrefixMapping(java.lang.String prefix)
endPrefixMapping
in interfaceContentHandler
prefix
- The prefix being mapped.ContentHandler.endPrefixMapping(java.lang.String)
public voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName,Attributes atts) throwsSAXException
startElement
in interfaceContentHandler
uri
- The Namespace URI.localName
- The Namespace local name.qName
- The qualified (prefixed) name.atts
- The SAX2 attributes.SAXException
- The client may raise a processing exception.ContentHandler.endDocument()
public voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throwsSAXException
endElement
in interfaceContentHandler
uri
- The Namespace URI.localName
- The Namespace local name.qName
- The qualified (prefixed) name.SAXException
- The client may raise a processing exception.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public voidcharacters(char[] ch, int start, int length) throwsSAXException
characters
in interfaceContentHandler
ch
- An array of characters.start
- The starting position in the array.length
- The number of characters to use.SAXException
- The client may raise a processing exception.ContentHandler.characters(char[], int, int)
public voidignorableWhitespace(char[] ch, int start, int length) throwsSAXException
ignorableWhitespace
in interfaceContentHandler
ch
- An array of characters.start
- The starting position in the array.length
- The number of characters to use.SAXException
- The client may raise a processing exception.ContentHandler.ignorableWhitespace(char[], int, int)
public voidprocessingInstruction(java.lang.String target, java.lang.String data) throwsSAXException
processingInstruction
in interfaceContentHandler
target
- The processing instruction target.data
- The remainder of the processing instructionSAXException
- The client may raise a processing exception.ContentHandler.processingInstruction(java.lang.String, java.lang.String)
public voidskippedEntity(java.lang.String name) throwsSAXException
skippedEntity
in interfaceContentHandler
name
- The name of the skipped entity.ContentHandler.skippedEntity(java.lang.String)