org::xmlBlaster::util::parser::Sax2Parser Class Reference

Default xmlBlaster handling of Sax callbacks and errors. More...

Inheritance diagram for org::xmlBlaster::util::parser::Sax2Parser:

Inheritance graph
[legend]
Collaboration diagram for org::xmlBlaster::util::parser::Sax2Parser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Sax2Parser (org::xmlBlaster::util::Global &global, XmlHandlerBase *handler)
 Constructs an new object.
 ~Sax2Parser ()
void init (std::string &xmlLiteral)
void parse (std::string &xmlData)
 Does the actual parsing.
void characters (XMLCh *chars, unsigned int length)
 Receive notification of character data inside an element.
void endDocument ()
 Receive notification of the end of the document.
void endElement (XMLCh *uri, XMLCh *localname, XMLCh *qname)
 Receive notification of the end of an element.
void startDocument ()
 Receive notification of the beginning of the document.
void startElement (XMLCh *uri, XMLCh *localname, XMLCh *qname, Attributes &attrs)
 Receive notification of the start of an element.
void error (SAXParseException &exc)
 Error.
void fatalError (SAXParseException &exc)
 Fatal error.
void warning (SAXParseException &exc)
 Warning.
void endCDATA ()
 Receive notification of the end of a CDATA section.
void startCDATA ()
 Receive notification of the start of a CDATA section.
std::string getType ()
 Get the name of the plugin.
std::string getVersion ()
 Get the version of the plugin.

Static Public Member Functions

static void releaseXMLCh (XMLCh **data)
 Helper method which encapsulates either the delete[] operator for Xerces-c versions older than ver.
static void releaseXMLCh (char **data)
 Helper method which encapsulates either the delete[] operator for Xerces-c versions older than ver.
static std::string usage ()
 Command line usage.

Protected Member Functions

std::string getLocationString (SAXParseException &ex)
 Returns a string of the location.
AttributeMapgetAttributeMap (AttributeMap &attrMap, Attributes &attrs)
bool caseCompare (XMLCh *name1, char *name2)
 Compares two strings (where name1 is a Unicode3.0 string!!) for unsensitive case compare.
std::string getStringValue (XMLCh *value, bool doTrim=true)
 returns a trimmed value (usually from an attribute) as a string
bool getStringAttr (Attributes &attrs, XMLCh *name, std::string &value, bool doTrim=true)
 gets the attribute specified by 'name' in the attribute list specified by 'list'.

Detailed Description

Default xmlBlaster handling of Sax callbacks and errors.

You may use this as a base class for your SAX handling.

The encoding can be changed with xmlBlaster/encoding=<enc> where this is typically "iso-8859-1" or "UTF-8"

NOTE: Multibyte encoding "UTF-8" is currently not supported for xmlBlaster internal xml key and QoS markup!

Definition at line 42 of file Sax2XercesParser.h.


Constructor & Destructor Documentation

org::xmlBlaster::util::parser::Sax2Parser::Sax2Parser ( org::xmlBlaster::util::Global global,
XmlHandlerBase handler 
)

Constructs an new object.

You need to call the init() method to parse the XML std::string.

Definition at line 37 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::I_Log::call(), org::xmlBlaster::util::I_Log::error(), org::xmlBlaster::util::Global::getProperty(), org::xmlBlaster::util::Property::getStringProperty(), org::xmlBlaster::util::I_Log::trace(), and org::xmlBlaster::util::USER_CONFIGURATION.

org::xmlBlaster::util::parser::Sax2Parser::~Sax2Parser (  ) 

Definition at line 58 of file Sax2XercesParser.cpp.


Member Function Documentation

void org::xmlBlaster::util::parser::Sax2Parser::init ( std::string &  xmlLiteral  ) 

void org::xmlBlaster::util::parser::Sax2Parser::parse ( std::string &  xmlData  )  [virtual]

Does the actual parsing.

Parameters:
xmlData Quality of service in XML notation

Implements org::xmlBlaster::util::parser::I_Parser.

string org::xmlBlaster::util::parser::Sax2Parser::getLocationString ( SAXParseException &  ex  )  [protected]

Returns a string of the location.

Definition at line 260 of file Sax2XercesParser.cpp.

References getStringValue(), and org::xmlBlaster::util::lexical_cast().

Referenced by error(), fatalError(), and warning().

AttributeMap & org::xmlBlaster::util::parser::Sax2Parser::getAttributeMap ( AttributeMap attrMap,
Attributes attrs 
) [protected]

Definition at line 392 of file Sax2XercesParser.cpp.

References getStringValue().

Referenced by startElement().

bool org::xmlBlaster::util::parser::Sax2Parser::caseCompare ( XMLCh *  name1,
char *  name2 
) [protected]

Compares two strings (where name1 is a Unicode3.0 string!!) for unsensitive case compare.

It returns true if the content of the std::strings is equal (no matter what the case is). Using this method to compare the std::strings should be portable to all platforms supported by xerces.

Definition at line 282 of file Sax2XercesParser.cpp.

References releaseXMLCh().

string org::xmlBlaster::util::parser::Sax2Parser::getStringValue ( XMLCh *  value,
bool  doTrim = true 
) [protected]

returns a trimmed value (usually from an attribute) as a string

Definition at line 298 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::StringTrim::trim().

Referenced by characters(), endElement(), getAttributeMap(), getLocationString(), and startElement().

bool org::xmlBlaster::util::parser::Sax2Parser::getStringAttr ( Attributes attrs,
XMLCh *  name,
std::string &  value,
bool  doTrim = true 
) [protected]

gets the attribute specified by 'name' in the attribute list specified by 'list'.

The result is put in the 'value' argument which is passed by reference. It returns 'true' if the attribute was found in the specified attribute list or 'false' if it was not. In the later case, the value is untouched by this method. If the 'doTrim' argument is set to true, the std::string is trimmed before it is given back.

void org::xmlBlaster::util::parser::Sax2Parser::releaseXMLCh ( XMLCh **  data  )  [static]

Helper method which encapsulates either the delete[] operator for Xerces-c versions older than ver.

2.2.0 or which invokes Sax2Parser::releaseXMLCh(XMLCh**) for versions from 2.2.0 and higher. Per default it assumes you have 2.2.0 or higher. If you have an older version please set in your build.properties or in your system environment the variable OLDXERCES.

Definition at line 427 of file Sax2XercesParser.cpp.

Referenced by caseCompare(), org::xmlBlaster::util::parser::ParserFactory::createParser(), and org::xmlBlaster::util::parser::ParserFactory::initialize().

void org::xmlBlaster::util::parser::Sax2Parser::releaseXMLCh ( char **  data  )  [static]

Helper method which encapsulates either the delete[] operator for Xerces-c versions older than ver.

2.2.0 or which invokes Sax2Parser::releaseXMLCh(XMLCh**) for versions from 2.2.0 and higher. Per default it assumes you have 2.2.0 or higher. If you have an older version please set in your build.properties or in your system environment the variable OLDXERCES.

Definition at line 437 of file Sax2XercesParser.cpp.

void org::xmlBlaster::util::parser::Sax2Parser::characters ( XMLCh *  chars,
unsigned int  length 
)

Receive notification of character data inside an element.

Definition at line 219 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::XmlHandlerBase::characters(), getStringValue(), and org::xmlBlaster::util::parser::I_Parser::handler_.

void org::xmlBlaster::util::parser::Sax2Parser::endDocument (  ) 

Receive notification of the end of the document.

Definition at line 176 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::I_Log::call(), org::xmlBlaster::util::XmlHandlerBase::endDocument(), and org::xmlBlaster::util::parser::I_Parser::handler_.

void org::xmlBlaster::util::parser::Sax2Parser::endElement ( XMLCh *  uri,
XMLCh *  localname,
XMLCh *  qname 
)

Receive notification of the end of an element.

Definition at line 183 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::XmlHandlerBase::endElement(), getStringValue(), and org::xmlBlaster::util::parser::I_Parser::handler_.

void org::xmlBlaster::util::parser::Sax2Parser::startDocument (  ) 

Receive notification of the beginning of the document.

Definition at line 190 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::parser::I_Parser::handler_, and org::xmlBlaster::util::XmlHandlerBase::startDocument().

void org::xmlBlaster::util::parser::Sax2Parser::startElement ( XMLCh *  uri,
XMLCh *  localname,
XMLCh *  qname,
Attributes attrs 
)

Receive notification of the start of an element.

Definition at line 197 of file Sax2XercesParser.cpp.

References getAttributeMap(), getStringValue(), org::xmlBlaster::util::parser::I_Parser::handler_, and org::xmlBlaster::util::XmlHandlerBase::startElement().

void org::xmlBlaster::util::parser::Sax2Parser::error ( SAXParseException &  exc  ) 

Error.

Definition at line 242 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::I_Log::call(), org::xmlBlaster::util::XmlHandlerBase::error(), getLocationString(), and org::xmlBlaster::util::parser::I_Parser::handler_.

void org::xmlBlaster::util::parser::Sax2Parser::fatalError ( SAXParseException &  exc  ) 

Fatal error.

Definition at line 251 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::I_Log::call(), org::xmlBlaster::util::XmlHandlerBase::fatalError(), getLocationString(), and org::xmlBlaster::util::parser::I_Parser::handler_.

void org::xmlBlaster::util::parser::Sax2Parser::warning ( SAXParseException &  exc  ) 

Warning.

Definition at line 233 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::I_Log::call(), getLocationString(), org::xmlBlaster::util::parser::I_Parser::handler_, and org::xmlBlaster::util::XmlHandlerBase::warning().

void org::xmlBlaster::util::parser::Sax2Parser::endCDATA (  ) 

Receive notification of the end of a CDATA section.

Definition at line 205 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::XmlHandlerBase::endCDATA(), and org::xmlBlaster::util::parser::I_Parser::handler_.

void org::xmlBlaster::util::parser::Sax2Parser::startCDATA (  ) 

Receive notification of the start of a CDATA section.

Definition at line 212 of file Sax2XercesParser.cpp.

References org::xmlBlaster::util::parser::I_Parser::handler_, and org::xmlBlaster::util::XmlHandlerBase::startCDATA().

std::string org::xmlBlaster::util::parser::Sax2Parser::getType (  )  [virtual]

Get the name of the plugin.

Returns:
"XERCES" I_Plugin

Implements org::xmlBlaster::util::plugin::I_Plugin.

Definition at line 228 of file Sax2XercesParser.h.

std::string org::xmlBlaster::util::parser::Sax2Parser::getVersion (  )  [virtual]

Get the version of the plugin.

Returns:
"1.0" I_Plugin

Implements org::xmlBlaster::util::plugin::I_Plugin.

Definition at line 235 of file Sax2XercesParser.h.

std::string org::xmlBlaster::util::parser::Sax2Parser::usage (  )  [static]

Command line usage.

These variables may be set in xmlBlaster.properties as well. Don't use the "-" prefix there.

Definition at line 63 of file Sax2XercesParser.cpp.

Referenced by org::xmlBlaster::util::Global::usage().


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