Class XMLParserHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.eclipse.birt.core.framework.parser.XMLParserHandler
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
Framework for parsing an XML file using a SAX parser. This framework provides
a separate class for each element. These classes are called "state" classes
because they represent the state of the parser. Generally, a state represents
some object being created. This handler manages the stack of active states,
and routes the SAX callbacks to the current state.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassParses any valid XML; handles unimplemented tags.classBase class provides the parse state framework. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) abstract AbstractParseStateParser handlers must implement this method to return the "start state": the state that will recognize the top-level element(s) in the XML file.voidvoidendElement(String namespaceURI, String localName, String qName) Ends the parse state for an element.voidvoidReturns the error list when parsing xml file.protected voidpushState(AbstractParseState state) Private method to add a parse state to the state stack.voidAdd a recoverable semantic error to the error list.abstract voidAdd a recoverable semantic error to the error list.voidsetDocumentLocator(Locator theLocator) voidvoidstartElement(String namespaceURI, String localName, String qName, Attributes atts) Starts an XML element.protected AbstractParseStatetopState()Private method to return the top of the state stack.voidMethods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDeclMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
currentElement
The current element being parsed. -
stateStack
Stack of active parse states. Corresponds to the stack of currently active elements. -
locator
SAXLocatorfor reporting errors. -
errors
The list contains errors encountered when parsing a XML file.
-
-
Constructor Details
-
XMLParserHandler
public XMLParserHandler()Constructor
-
-
Method Details
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException
-
semanticError
Add a recoverable semantic error to the error list.- Parameters:
e- The exception to log.
-
semanticError
Add a recoverable semantic error to the error list.- Parameters:
e- The exception to log.
-
pushState
Private method to add a parse state to the state stack.- Parameters:
state- the state to push
-
topState
Private method to return the top of the state stack.- Returns:
- the state at the top of the state stack
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException Starts an XML element. Delegates to the current state the task of creating a new parse state for the new element.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException- See Also:
-
endElement
Ends the parse state for an element.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException- See Also:
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException- See Also:
-
createStartState
Parser handlers must implement this method to return the "start state": the state that will recognize the top-level element(s) in the XML file.- Returns:
- the start state specific to the derived parser
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Throws:
SAXException
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
getErrors
Returns the error list when parsing xml file.- Returns:
- the errors
-