Class XMLSAXHandler
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
This class contains one stack used to store part of the parse tree. The ElementHandlers found on the stack have direct next handlers placed on the stack. So here's the warning, be careful to read how you may be affecting (or forgetting to affect) the stack.
If a FlowHandler implementation is available in the hints, the handler will periodically check it to see if it should stop parsing. See the FlowHandler interface.
This is an XML Schema driven parser and resolveEntity(String, String) will ignore all dtd references. If
an EntityResolver is provided it will be used.
- Author:
- dzwiers, Refractions Research, Inc. http://www.refractions.net
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXMLSAXHandler(URI intendedDocument, Map<String, Object> hints) This contructor is intended to create an XMLSAXHandler to be used when parsing an XML instance document.XMLSAXHandler(Map<String, Object> hints) This contructor is intended to create an XMLSAXHandler to be used when parsing an XML instance document. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) Implementation of characters.voidImplementation of endDocument.voidendElement(String namespaceURI, String localName, String qName) Implementation of endElement.voidendPrefixMapping(String prefix) voiderror(SAXParseException exception) Implementation of error.voidfatalError(SAXParseException exception) Implementation of fatalError.getDocument purpose.protected voidresolveEntity(String publicId, String systemId) Delegate toentityResolverif available.voidsetDocumentLocator(Locator locator) Stores the locator for future error reportingvoidsetEntityResolver(EntityResolver entityResolver) static voidsetLogLevel(Level l) Used to set the logger level for all XMLSAXHandlersvoidImplementation of startDocument.voidstartElement(String namespaceURI, String localName, String qName, Attributes atts) Implementation of startElement.voidstartPrefixMapping(String prefix, String uri) voidwarning(SAXParseException exception) Implementation of warning.Methods inherited from class DefaultHandler
ignorableWhitespace, notationDecl, processingInstruction, skippedEntity, unparsedEntityDeclMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Field Details
-
logger
the logger -- should be used for debugging (assuming there are bugs LOL) -
level
-
-
Constructor Details
-
XMLSAXHandler
This contructor is intended to create an XMLSAXHandler to be used when parsing an XML instance document. The instance document's uri is also be provided, as this will allow the parser to resolve relative uri's. -
XMLSAXHandler
This contructor is intended to create an XMLSAXHandler to be used when parsing an XML instance document. The instance document's uri is also be provided, as this will allow the parser to resolve relative uri's.
- Parameters:
hints- Hints as per {@link {@link XMLHandlerHints}
-
-
Method Details
-
setEntityResolver
-
getEntityResolver
-
resolveEntity
Delegate toentityResolverif available.Note this is an XMLSchema based parser, all attempts to resolved DTDs are rejected.
- Specified by:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Parameters:
publicId- The public identifier, or null if none is available.systemId- The system identifier provided in the XML document.- Returns:
- The new input source, or null to require the default behavior.
- Throws:
IOException- If there is an error setting up the new input source.SAXException- Any SAX exception, possibly wrapping another exception.
-
init
-
endDocument
public void endDocument()Implementation of endDocument.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- See Also:
-
startDocument
public void startDocument()Implementation of startDocument.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- See Also:
-
characters
Implementation of characters.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException- See Also:
-
endElement
Implementation of endElement.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException- See Also:
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException Implementation of startElement.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException- See Also:
-
setLogLevel
Used to set the logger level for all XMLSAXHandlers -
getDocument
getDocument purpose.Completes the post-processing phase, and returns the value from the parse ...
- Returns:
- Object parsed
- Throws:
SAXException- See Also:
-
error
Implementation of error.- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- See Also:
-
fatalError
Implementation of fatalError.- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException- See Also:
-
warning
Implementation of warning.- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- See Also:
-
setDocumentLocator
Stores the locator for future error reporting- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler- See Also:
-
endPrefixMapping
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- See Also:
-
startPrefixMapping
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- See Also:
-