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 TypeClassDescriptionclass
Parses any valid XML; handles unimplemented tags.class
Base class provides the parse state framework. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) abstract AbstractParseState
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.void
void
endElement
(String namespaceURI, String localName, String qName) Ends the parse state for an element.void
void
Returns the error list when parsing xml file.protected void
pushState
(AbstractParseState state) Private method to add a parse state to the state stack.void
Add a recoverable semantic error to the error list.abstract void
Add a recoverable semantic error to the error list.void
setDocumentLocator
(Locator theLocator) void
void
startElement
(String namespaceURI, String localName, String qName, Attributes atts) Starts an XML element.protected AbstractParseState
topState()
Private method to return the top of the state stack.void
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
SAXLocator
for reporting errors. -
errors
The list contains errors encountered when parsing a XML file.
-
-
Constructor Details
-
XMLParserHandler
public XMLParserHandler()Constructor
-
-
Method Details
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in 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:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
- See Also:
-
endElement
Ends the parse state for an element.- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
- See Also:
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in 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:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Throws:
SAXException
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Throws:
SAXException
-
fatalError
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXException
-
getErrors
Returns the error list when parsing xml file.- Returns:
- the errors
-