Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

XMLSupport.h File Reference

Helper classes, functions and macros used when parsing / creating XML documents using Xerces XML parser. More...

#include "XMLStrings.h"
#include "messagePrinting.h"
#include <ostream>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/validators/DTD/DTDGrammar.hpp>
#include <xercesc/framework/LocalFileFormatTarget.hpp>

Include dependency graph for XMLSupport.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Classes

class  TranscodedString
 Simple class used to transcode given const XMLCh * to const char *. More...

class  UnicodeString
 Simple class used to transcode given const char * to const XMLCh *. More...

class  XMLSupportErrorHandler
 Simple error handler used when parsing XML documents. More...


Defines

#define TAGNAME_BUFFER_SIZE   128
#define ToString(x)   (const char *)TranscodedString(x)
#define ToXML(x)   (const XMLCh *)UnicodeString(x)

Functions

std::ostream & operator<< (std::ostream &target, const TranscodedString &toDump)
int checkTagName (DOMElement *element, const char *expectedName, CStdString &errorString)
bool isTag (DOMElement *element, const char *nameToTest)
int getRequiredAttribute (DOMElement *element, const char *attributeName, CStdString &attributeValue, CStdString &errorString)
int getOptionalAttribute (DOMElement *element, const char *attributeName, CStdString &attributeValue)
int getTextElementContent (DOMElement *element, CStdString &content, CStdString &errorString)

Detailed Description

Helper classes, functions and macros used when parsing / creating XML documents using Xerces XML parser.

Author:
Josef Troch (josef.troch@email.cz)
Date:
2003 - 2004

Define Documentation

#define TAGNAME_BUFFER_SIZE   128
 

Maximal size of buffer used when getting value of an attribute in getRequiredAttribute() or getOptionalAttribute().

#define ToString  )     (const char *)TranscodedString(x)
 

Macro to make using of TranscodedString easier (in Visual C++ useless).

#define ToXML  )     (const XMLCh *)UnicodeString(x)
 

Macro to make using of UnicodeString easier (in Visual C++ useless).


Function Documentation

std::ostream& operator<< std::ostream &  target,
const TranscodedString toDump
[inline]
 

Operator needed to make it possible to send TranscodedString to ostream - without this operator TranscodedString would be converted to const char *, then to void * and printed as pointer.

int checkTagName DOMElement *  element,
const char *  expectedName,
CStdString &  errorString
[inline, static]
 

Checks whether element's name is expectedName.

Parameters:
element The element.
expectedName Name to be tested.
errorString If element's name differ from expectedName, an error message is returned using this parameter.
Returns:
0 if OK, non-zero in case of error.

bool isTag DOMElement *  element,
const char *  nameToTest
[inline, static]
 

Tests whether element's name is nameToTest.

Returns:
true if the names are the same, false if they differ.

int getRequiredAttribute DOMElement *  element,
const char *  attributeName,
CStdString &  attributeValue,
CStdString &  errorString
[inline, static]
 

Gets value of attribute specified by attributeName.

If element doesn't have an attribute with specified name, returns appropriate error message in errorString. If the attribute value is successfully received, function returns it in attributeValue.

Returns:
0 if OK, 1 if the attribute hasn't been found.

int getOptionalAttribute DOMElement *  element,
const char *  attributeName,
CStdString &  attributeValue
 

Gets value of attribute specified by attributeName if it is present.

If element has an attribute with specified name, function returns its value in attributeValue.

Returns:
0 if the attribute value have been successfully received, 1 otherwise.

int getTextElementContent DOMElement *  element,
CStdString &  content,
CStdString &  errorString
[inline, static]
 

Checks whether given element has only text children (and possibly some comment nodes). If so, returns concatenated content of the text nodes.

If the content would be empty, 1 is returned (error).

Parameters:
element Element to be processed.
content Content of the text elements.
errorString String used to return error message if some error occurs.
Returns:
0 if OK, non-zero otherwise.


Generated on Wed Aug 11 22:35:04 2004 for IOPC by Doxygen 1.3.6