|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |
#include "ot/sax/DefaultHandler.h"
This class is available as a convenience base class for SAX2 applications: it provides default implementations for all of the callbacks in the four core SAX2 handler classes:
Application writers can extend this class when they need to implement only part of an interface; parser writers can instantiate this class to provide default handlers when the application has not supplied its own.
Method Summary | |
virtual void |
characters(const CharType* pStart, size_t length) Receive notification of character data. |
virtual void |
endDocument() Receive notification of the end of a document. |
virtual void |
endElement(const String& namespaceURI, const String& localName, const String& qName) Receive notification of the end of an element. |
virtual void |
endPrefixMapping(const String& prefix) End the scope of a prefix-URI mapping. |
virtual void |
error(const SAXParseException& exception) Receive notification of a recoverable error. |
virtual void |
fatalError(const SAXParseException& exception) Receive notification of a non-recoverable error. |
virtual void |
ignorableWhitespace(const CharType* pStart, size_t length) Receive notification of ignorable whitespace in element content. |
virtual void |
notationDecl(const String& name, const String& publicId, const String& systemId) Receive notification of a notation declaration event. |
virtual void |
processingInstruction(const String& target, const String& data) Receive notification of a processing instruction. |
virtual RefPtr< InputSource > |
resolveEntity(const String& publicId, const String& systemId) Allow the application to resolve external entities. |
virtual void |
setDocumentLocator(Locator* pLocator) Receive an object for locating the origin of SAX document events. |
virtual void |
skippedEntity(const String& name) Receive notification of a skipped entity. |
virtual void |
startDocument() Receive notification of the beginning of a document. |
virtual void |
startElement(const String& namespaceURI, const String& localName, const String& qName, const Attributes& atts) Receive notification of the beginning of an element. |
virtual void |
startPrefixMapping(const String& prefix, const String& uri) Begin the scope of a prefix-URI Namespace mapping. |
virtual void |
unparsedEntityDecl(const String& name, const String& publicId, const String& systemId, const String& notationName) Receive notification of an unparsed entity declaration event. |
virtual void |
warning(const SAXParseException& exception) Receive notification of a warning. |
Methods inherited from class ot::ManagedObject |
addRef, getRefCount, onFinalRelease, operator=, release |
Method Detail |
virtual void characters(const CharType* pStart, size_t length)
The array of characters will form an integral number of Unicode characters in the internal OpenTop encoding.
The memory for the character array is managed by the SAX parser and the pStart pointer is only valid for the scope of this function. The application must not attempt to read from the array beyond the specified length.
Note that when the SAX parser has an element content model available (i.e. it has read a declaration for the current element from a DTD) it will report whitespace in element content using the ignorableWhitespace() event.
pStart
- length
- SAXException
- virtual void endDocument()
SAXException
- virtual void endElement(const String& namespaceURI, const String& localName, const String& qName)
For information on the names, see startElement().
namespaceURI
- localName
- qName
- SAXException
- virtual void endPrefixMapping(const String& prefix)
prefix
- SAXException
- virtual void error(const SAXParseException& exception)
This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.
Filters may use this method to report other, non-XML errors as well.
exception
- SAXException
- virtual void fatalError(const SAXParseException& exception)
This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.
The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting additional error messages.
The default implementation throws the exception parameter as an exception.
exception
- SAXException
- virtual void ignorableWhitespace(const CharType* pStart, size_t length)
SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The array of characters will form an integral number of Unicode characters in the internal OpenTop encoding.
The memory for the character array is managed by the SAX parser and the pStart pointer is only valid for the scope of this function. The application must not attempt to read from the array beyond the specified length.
Note that, when validating, the SAX parser will report whitespace in element content using the ignorableWhitespace().
pStart
- length
- SAXException
- virtual void notationDecl(const String& name, const String& publicId, const String& systemId)
It is up to the application to record the notation for later reference, if necessary.
At least one of publicId and systemId must be present. If a system identifier is present, and it is a URL, it will be fully resolved if the http://elcel.com/opentop/sax/features/resolve-entity-uris feature is set to true (the default).
There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.
name
- publicId
- systemId
- SAXException
- virtual void processingInstruction(const String& target, const String& data)
The SAX parser will not report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.
target
- data
- SAXException
- virtual RefPtr< InputSource > resolveEntity(const String& publicId, const String& systemId)
The Parser will call this method before opening any external entity except the top-level document entity (including the external DTD subset, external entities referenced within the DTD, and external entities referenced within the document element): the application may request that the parser resolve the entity itself, that it use an alternative URI, or that it use an entirely different input source.
Application writers can use this method to redirect external system identifiers to secure and/or local URIs, to look up public identifiers in a catalogue, or to read an entity from a database or other input source (including, for example, a dialog box).
If the system identifier is a URL, it will be fully resolved if the http://elcel.com/opentop/sax/features/resolve-entity-uris feature is set to true (the default).
publicId
- systemId
- SAXException
- virtual void setDocumentLocator(Locator* pLocator)
void myHandler::setDocumentLocator(Locator* pLocator) { m_rpLocator = pLocator; }
The Locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules).
void myHandler::ignorableWhitespace(const String& string) { Console::cout() << OT_T("received ignorable whitespace at [") << m_rpLocator->getLineNumber() << OT_T(",") << m_rpLocator->getColumnNumber() << OT_T("]") << endl; }
The information returned by the Locator is probably not sufficient for use with a search engine.
Note that the Locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.
pLocator
- virtual void skippedEntity(const String& name)
name
- SAXException
- virtual void startDocument()
The SAX parser will invoke this method only once, before any other event callbacks (except for setDocumentLocator).
SAXException
- virtual void startElement(const String& namespaceURI, const String& localName, const String& qName, const Attributes& atts)
This event allows up to three name components for each element:
Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes features:
Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes feature is true (it is false by default).
namespaceURI
- localName
- qName
- atts
- SAXException
- virtual void startPrefixMapping(const String& prefix, const String& uri)
There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.
Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement() event, and all endPrefixMapping() events will occur after the corresponding endElement() event, but their order is not otherwise guaranteed.
There will never be start/endPrefixMapping events for the 'xml' prefix, since it is predeclared and immutable.
prefix
- uri
- SAXException
- virtual void unparsedEntityDecl(const String& name, const String& publicId, const String& systemId, const String& notationName)
Note that the notation name corresponds to a notation reported by the notationDecl() event. It is up to the application to record the entity for later reference, if necessary.
If the system identifier is a URL, it will be fully resolved if the http://elcel.com/opentop/sax/features/resolve-entity-uris feature is set to true (the default).
name
- publicId
- systemId
- notationName
- SAXException
- virtual void warning(const SAXParseException& exception)
SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.
Filters may use this method to report other, non-XML warnings as well.
exception
- SAXException
-
|
OpenTop 1.3 | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD |