- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Io::Xml::Sax::ContentHandler Class Reference

`#include <ContentHandler.h>`

Inheritance diagram for Mers::Utils::Io::Xml::Sax::ContentHandler:

[legend]
Collaboration diagram for Mers::Utils::Io::Xml::Sax::ContentHandler:

[legend]
List of all members.

## Public Member Functions
| ContentHandler (XERCES_CPP_NAMESPACE::SAX2XMLReader *reader,::Mers::Utils::Io::Xml::Sax::ContentHandler *parent=NULL)
virtual | ~ContentHandler ()
## Protected Member Functions
const XERCES_CPP_NAMESPACE::Locator * | getDocumentLocator () const
::Mers::Utils::Lang::String | getLineNumberString () const
## Protected Attributes
XERCES_CPP_NAMESPACE::SAX2XMLReader * | m_Reader
| The reader that is being used to parse the data.
::Mers::Utils::Io::Xml::Sax::ContentHandler * | m_Parent
## Static Protected Attributes
static log4cplus::Logger | m_Logger
| The logger for this class.

## Detailed Description

This class is able to load xml content in a stack-based manner. This class provides a default implementation for basic XML parsing.

Definition at line 34 of file ContentHandler.h.

## Constructor & Destructor Documentation

Mers::Utils::Io::Xml::Sax::ContentHandler::ContentHandler | ( | XERCES_CPP_NAMESPACE::SAX2XMLReader * | reader,
|  | ::Mers::Utils::Io::Xml::Sax::ContentHandler * | parent = `NULL` |
| ) |  |  |

Constructs a new child that will parse based on the specified content type.

Parameters:

  | reader | The reader that is reading the data. This is used to change the content handler on the fly.
  | parent | The parent of this object.

ContentHandler::~ContentHandler | ( |  | ) | `[virtual]`

Destroys this object.

Definition at line 44 of file ContentHandler.cpp.

## Member Function Documentation

void ContentHandler::characters | ( | const XMLCh *const | chars,
|  | const unsigned int | length |
| ) |  |  | `[virtual]`

Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data 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 application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Parameters:

  | chars | The characters from the XML document.
  | length | The number of characters to read from the array.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

See also:
  ignorableWhitespace

  Locator::Locator

Reimplemented in Mers::Utils::Io::Xml::Sax::DoubleCH, and Mers::Utils::Io::Xml::Sax::StringCH.

Definition at line 50 of file ContentHandler.cpp.

References m_Logger.

void ContentHandler::endDocument | ( |  | ) | `[virtual]`

Receive notification of the end of a document.

The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 64 of file ContentHandler.cpp.

References m_Logger.

void ContentHandler::endElement | ( | const XMLCh *const | uri,
|  | const XMLCh *const | localname,
|  | const XMLCh *const | qname |
| ) |  |  | `[virtual]`

Receive notification of the end of an element.

The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement() event for every endElement() event (even when the element is empty).

Parameters:

  | uri | The URI of the asscioated namespace for this element
  | localname | The local part of the element name
  | qname | The QName of this element

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Reimplemented in Mers::Estimation::Discrete::Io::Xml::Sax::EstCH, Mers::Estimation::Discrete::Io::Xml::Sax::TrajCH, Mers::Models::Base::Io::Xml::Sax::BMAssignmentCH, Mers::Utils::Io::Xml::Sax::ContentLauncher< Content, Callback, Data >, Mers::Utils::Io::Xml::Sax::DoubleCH, and Mers::Utils::Io::Xml::Sax::StringCH.

Definition at line 71 of file ContentHandler.cpp.

References m_Logger, m_Parent, and m_Reader.

Referenced by Mers::Utils::Io::Xml::Sax::StringCH::endElement(), and Mers::Utils::Io::Xml::Sax::DoubleCH::endElement().

void ContentHandler::ignorableWhitespace | ( | const XMLCh *const | chars,
|  | const unsigned int | length |
| ) |  |  | `[virtual]`

Receive notification of ignorable whitespace in element content.

Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.

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 application must not attempt to read from the array outside of the specified range.

Parameters:

  | chars | The characters from the XML document.
  | length | The number of characters to read from the array.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

See also:
  characters

Definition at line 91 of file ContentHandler.cpp.

void ContentHandler::processingInstruction | ( | const XMLCh *const | target,
|  | const XMLCh *const | data |
| ) |  |  | `[virtual]`

Receive notification of a processing instruction.

The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

Parameters:

  | target | The processing instruction target.
  | data | The processing instruction data, or null if none was supplied.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 100 of file ContentHandler.cpp.

References m_Logger.

virtual void Mers::Utils::Io::Xml::Sax::ContentHandler::setDocumentLocator | ( | const XERCES_CPP_NAMESPACE::Locator *const | locator | ) | `[virtual]`

Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

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). 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.

Parameters:

  | locator | An object that can return the location of any SAX document event. The object is only 'on loan' to the client code and they are not to attempt to delete or modify it in any way!

See also:
  Locator::Locator

void ContentHandler::startDocument | ( |  | ) | `[virtual]`

Receive notification of the beginning of a document.

The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 119 of file ContentHandler.cpp.

References m_Logger.

virtual void Mers::Utils::Io::Xml::Sax::ContentHandler::startElement | ( | const XMLCh *const | uri,
|  | const XMLCh *const | localname,
|  | const XMLCh *const | qname,
|  | const XERCES_CPP_NAMESPACE::Attributes & | attrs |
| ) |  |  | `[virtual]`

Receive notification of the beginning of an element.

The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement() event for every startElement() event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement() event.

Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): IMPLIED attributes will be omitted.

Parameters:

  | uri | The URI of the asscioated namespace for this element
  | localname | The local part of the element name
  | qname | The QName of this element
  | attrs | The attributes attached to the element, if any.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

See also:
  endElement

  Attributes::Attributes

Reimplemented in Mers::Estimation::Discrete::Io::Xml::Sax::EstCH, Mers::Estimation::Discrete::Io::Xml::Sax::TrajCH, Mers::Models::Base::Io::Xml::Sax::BMAssignmentCH, and Mers::Utils::Io::Xml::Sax::ContentLauncher< Content, Callback, Data >.

void ContentHandler::startPrefixMapping | ( | const XMLCh *const | prefix,
|  | const XMLCh *const | uri |
| ) |  |  | `[virtual]`

Receive notification of the start of an namespace prefix mapping.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each namespace prefix mapping.

Parameters:

  | prefix | The namespace prefix used
  | uri | The namespace URI used.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 144 of file ContentHandler.cpp.

void ContentHandler::endPrefixMapping | ( | const XMLCh *const | prefix | ) | `[virtual]`

Receive notification of the end of an namespace prefix mapping.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each namespace prefix mapping.

Parameters:

  | prefix | The namespace prefix used

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 153 of file ContentHandler.cpp.

void ContentHandler::skippedEntity | ( | const XMLCh *const | name | ) | `[virtual]`

Receive notification of a skipped entity

The parser will invoke this method once for each entity skipped. All processors may skip external entities, depending on the values of the features:
http://xml.org/sax/features/external-general-entities
http://xml.org/sax/features/external-parameter-entities

Note: Xerces (specifically) never skips any entities, regardless of the above features. This function is never called in the Xerces implementation of SAX2.

Introduced with SAX2

Parameters:

  | name | The name of the skipped entity. If it is a parameter entity, the name will begin with %, and if it is the external DTD subset, it will be the string [dtd].

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 160 of file ContentHandler.cpp.

const XERCES_CPP_NAMESPACE::Locator* Mers::Utils::Io::Xml::Sax::ContentHandler::getDocumentLocator | ( |  | ) | const`[inline, protected]`

Returns the document locator for this content handler. Since the content handler apprach used here is a stack, and Xerces does not set the locator on anything but the root handler, we may need to ask our parent for the Locator.

Definition at line 342 of file ContentHandler.h.

References getDocumentLocator(), and m_Parent.

Referenced by getDocumentLocator(), and getLineNumberString().

Here is the call graph for this function:

String ContentHandler::getLineNumberString | ( |  | ) | const`[protected]`

Returns a string version of the current line number for logging/exceptions.

Definition at line 167 of file ContentHandler.cpp.

References getDocumentLocator().

Referenced by Mers::Models::Base::Io::Xml::Sax::BMAssignmentCH::endElement().

Here is the call graph for this function:

void ContentHandler::characters | ( | const XMLCh *const | chars,
|  | const unsigned int | length |
| ) |  |  | `[virtual]`

Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data 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 application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Parameters:

  | chars | The characters from the XML document.
  | length | The number of characters to read from the array.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

See also:
  ignorableWhitespace

  Locator::Locator

Reimplemented in Mers::Utils::Io::Xml::Sax::DoubleCH, and Mers::Utils::Io::Xml::Sax::StringCH.

Definition at line 50 of file ContentHandler.cpp.

References m_Logger.

void ContentHandler::endDocument | ( |  | ) | `[virtual]`

Receive notification of the end of a document.

The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 64 of file ContentHandler.cpp.

References m_Logger.

void ContentHandler::endElement | ( | const XMLCh *const | uri,
|  | const XMLCh *const | localname,
|  | const XMLCh *const | qname |
| ) |  |  | `[virtual]`

Receive notification of the end of an element.

The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement() event for every endElement() event (even when the element is empty).

Parameters:

  | uri | The URI of the asscioated namespace for this element
  | localname | The local part of the element name
  | qname | The QName of this element

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Reimplemented in Mers::Estimation::Discrete::Io::Xml::Sax::EstCH, Mers::Estimation::Discrete::Io::Xml::Sax::TrajCH, Mers::Models::Base::Io::Xml::Sax::BMAssignmentCH, Mers::Utils::Io::Xml::Sax::ContentLauncher< Content, Callback, Data >, Mers::Utils::Io::Xml::Sax::DoubleCH, and Mers::Utils::Io::Xml::Sax::StringCH.

Definition at line 71 of file ContentHandler.cpp.

References m_Logger, m_Parent, and m_Reader.

Referenced by Mers::Utils::Io::Xml::Sax::StringCH::endElement(), and Mers::Utils::Io::Xml::Sax::DoubleCH::endElement().

void ContentHandler::ignorableWhitespace | ( | const XMLCh *const | chars,
|  | const unsigned int | length |
| ) |  |  | `[virtual]`

Receive notification of ignorable whitespace in element content.

Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.

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 application must not attempt to read from the array outside of the specified range.

Parameters:

  | chars | The characters from the XML document.
  | length | The number of characters to read from the array.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

See also:
  characters

Definition at line 91 of file ContentHandler.cpp.

void ContentHandler::processingInstruction | ( | const XMLCh *const | target,
|  | const XMLCh *const | data |
| ) |  |  | `[virtual]`

Receive notification of a processing instruction.

The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

Parameters:

  | target | The processing instruction target.
  | data | The processing instruction data, or null if none was supplied.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 100 of file ContentHandler.cpp.

References m_Logger.

virtual void Mers::Utils::Io::Xml::Sax::ContentHandler::setDocumentLocator | ( | const XERCES_CPP_NAMESPACE::Locator *const | locator | ) | `[virtual]`

Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

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). 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.

Parameters:

  | locator | An object that can return the location of any SAX document event. The object is only 'on loan' to the client code and they are not to attempt to delete or modify it in any way!

See also:
  Locator::Locator

void ContentHandler::startDocument | ( |  | ) | `[virtual]`

Receive notification of the beginning of a document.

The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 119 of file ContentHandler.cpp.

References m_Logger.

virtual void Mers::Utils::Io::Xml::Sax::ContentHandler::startElement | ( | const XMLCh *const | uri,
|  | const XMLCh *const | localname,
|  | const XMLCh *const | qname,
|  | const XERCES_CPP_NAMESPACE::Attributes & | attrs |
| ) |  |  | `[virtual]`

Receive notification of the beginning of an element.

The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement() event for every startElement() event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement() event.

Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): IMPLIED attributes will be omitted.

Parameters:

  | uri | The URI of the asscioated namespace for this element
  | localname | The local part of the element name
  | qname | The QName of this element
  | attrs | The attributes attached to the element, if any.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

See also:
  endElement

  Attributes::Attributes

Reimplemented in Mers::Estimation::Discrete::Io::Xml::Sax::EstCH, Mers::Estimation::Discrete::Io::Xml::Sax::TrajCH, Mers::Models::Base::Io::Xml::Sax::BMAssignmentCH, and Mers::Utils::Io::Xml::Sax::ContentLauncher< Content, Callback, Data >.

void ContentHandler::startPrefixMapping | ( | const XMLCh *const | prefix,
|  | const XMLCh *const | uri |
| ) |  |  | `[virtual]`

Receive notification of the start of an namespace prefix mapping.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each namespace prefix mapping.

Parameters:

  | prefix | The namespace prefix used
  | uri | The namespace URI used.

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 144 of file ContentHandler.cpp.

void ContentHandler::endPrefixMapping | ( | const XMLCh *const | prefix | ) | `[virtual]`

Receive notification of the end of an namespace prefix mapping.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each namespace prefix mapping.

Parameters:

  | prefix | The namespace prefix used

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 153 of file ContentHandler.cpp.

void ContentHandler::skippedEntity | ( | const XMLCh *const | name | ) | `[virtual]`

Receive notification of a skipped entity

The parser will invoke this method once for each entity skipped. All processors may skip external entities, depending on the values of the features:
http://xml.org/sax/features/external-general-entities
http://xml.org/sax/features/external-parameter-entities

Note: Xerces (specifically) never skips any entities, regardless of the above features. This function is never called in the Xerces implementation of SAX2.

Introduced with SAX2

Parameters:

  | name | The name of the skipped entity. If it is a parameter entity, the name will begin with %, and if it is the external DTD subset, it will be the string [dtd].

Exceptions:

  | SAXException | Any SAX exception, possibly wrapping another exception.

Definition at line 160 of file ContentHandler.cpp.

## Member Data Documentation

::Mers::Utils::Io::Xml::Sax::ContentHandler* Mers::Utils::Io::Xml::Sax::ContentHandler::m_Parent`[protected]`

A handle to our parent. We return control to our parent when we end.

Definition at line 361 of file ContentHandler.h.

Referenced by endElement(), and getDocumentLocator().

The documentation for this class was generated from the following files:

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Sax/ContentHandler.h
- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/Sax/ContentHandler.cpp