Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

XmlParser Class Reference

SAX parser. More...

#include <xmlparser.h>

Inheritance diagram for XmlParser:

XmlParserBase SAXBase UserOfTextCodec List of all members.

Public Methods

 XmlParser (void)
 A constructor. More...

 XmlParser (const XmlChar *encoding)
 A constructor. More...

virtual ~XmlParser (void)
 A destructor. More...

virtual long parse (void) throw (ExaltParserException, ExaltEncodingException, ExaltIOException)
 Parse XML stream. More...

virtual long parsePush (const char *data, int length, bool isFinal) throw (ExaltParserException, ExaltEncodingException, ExaltIOException)
 Parse XML data in PUSH mode. More...

virtual void reportError (void)
 Report parser error messages. More...

virtual void startElement (void *userData, const XmlChar *name, const XmlChar **atts)
 Start element handler. More...

virtual void endElement (void *userData, const XmlChar *name)
 End element handler. More...

virtual void characterData (void *userData, const XmlChar *data, int length)
 Character data handler. More...

virtual void processingInstruction (void *userData, const XmlChar *target, const XmlChar *data)
 Processing instruction handler. More...

virtual void comment (void *userData, const XmlChar *data)
 Comment handler. More...

virtual void startCDATASection (void *userData)
 Start CDATA section handler. More...

virtual void endCDATASection (void *userData)
 End CDATA section handler. More...

virtual void defaultHandler (void *userData, const XmlChar *data, int length)
 Default handler. More...

virtual int unknownEncoding (void *unknownEncodingData, const XmlChar *name, XML_Encoding *info)
 Unknown encoding handler. More...

virtual void xmlDecl (void *userData, const XmlChar *version, const XmlChar *encoding, int standalone)
 XML declaration handler. More...

virtual void startDoctypeDecl (void *userData, const XmlChar *doctypeName, const XmlChar *systemId, const XmlChar *publicId, int hasInternalSubset)
 Start doctype handler. More...

virtual void endDoctypeDecl (void *userData)
 End doctype handler. More...

virtual void entityDecl (void *userData, const XmlChar *entityName, int isParameterEntity, const XmlChar *value, int valueLength, const XmlChar *base, const XmlChar *systemId, const XmlChar *publicId, const XmlChar *notationName)
 Entity declaration handler. More...

virtual void notationDecl (void *userData, const XmlChar *notationName, const XmlChar *base, const XmlChar *systemId, const XmlChar *publicId)
 Notation declaration handler. More...


Protected Methods

virtual void initParser (const XmlChar *encoding)
 Initialization of the parser with given encoding. More...

void exposeEvent (XmlModelEvent *ev)
 Expose the XML event to XML model. More...


Protected Attributes

XmlInnerParser innerParser
 Expat parser structure. More...

char xmlDataBuff [XML_BUFFER_SIZE]
unsigned long charactersTotal
 Total amount of the character data.


Detailed Description

SAX parser.

This class is a C++ wrapper around the Expat XML parser. The main task of the parser is (surprisingly) to parse given XML stream and manage all important SAX events. These SAX events are transformed into XML model events (XmlModelEvent) and sent to given XmlModel.

Definition at line 52 of file xmlparser.h.


Constructor & Destructor Documentation

XmlParser::XmlParser void   
 

A constructor.

Calls initParser().

Definition at line 199 of file xmlparser.cpp.

References initParser.

XmlParser::XmlParser const XmlChar *    encoding
 

A constructor.

Calls initParser().

Parameters:
encoding  The encoding of the XML data.

Definition at line 211 of file xmlparser.cpp.

References initParser, and XmlChar.

XmlParser::~XmlParser void    [virtual]
 

A destructor.

Frees the resources consumed by the parser.

Definition at line 271 of file xmlparser.cpp.

References charactersTotal, UserOfTextCodec::deleteDefaultTextCodec, ExaltOptions::getOption, innerParser, OUTPUTENL, ExaltOptions::Verbose, and ExaltOptions::Yes.


Member Function Documentation

void XmlParser::characterData void *    userData,
const XmlChar *    data,
int    length
[virtual]
 

Character data handler.

Examines the character data and emits an event to the XML model. If the data contain characters &, ', ", < or >, these are substituted by corresponding entities (&amp;, &apos;, &quot;, &lt; or &gt;).

Parameters:
userData  Pointer to the user data structure.
data  Character data.
length  Length of the data.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 479 of file xmlparser.cpp.

References charactersTotal, exposeEvent, NEW, OUTPUT, and XmlChar.

void XmlParser::comment void *    userData,
const XmlChar *    data
[virtual]
 

Comment handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
data  The comment data.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 531 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.

void XmlParser::defaultHandler void *    userData,
const XmlChar *    data,
int    length
[virtual]
 

Default handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
data  The default data.
length  The length of the default data.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 597 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.

void XmlParser::endCDATASection void *    userData [virtual]
 

End CDATA section handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 574 of file xmlparser.cpp.

References exposeEvent, NEW, and OUTPUT.

void XmlParser::endDoctypeDecl void *    userData [virtual]
 

End doctype handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 751 of file xmlparser.cpp.

References exposeEvent, NEW, and OUTPUTNL.

void XmlParser::endElement void *    userData,
const XmlChar *    name
[virtual]
 

End element handler.

Examines the name of the element and emits corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
name  Name of the element.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 440 of file xmlparser.cpp.

References DELETE_ARRAY, ParseInfo::depth, exposeEvent, NEW, OUTPUT, XmlChar, xmlchar_strcat, xmlchar_strcpy, and xmlchar_strlen.

void XmlParser::entityDecl void *    userData,
const XmlChar *    entityName,
int    isParameterEntity,
const XmlChar *    value,
int    valueLength,
const XmlChar *    base,
const XmlChar *    systemId,
const XmlChar *    publicId,
const XmlChar *    notationName
[virtual]
 

Entity declaration handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
entityName  The name of the entity.
isParameterEntity  Is the entity a parametric entity?
value  The value of the entity.
valueLength  The length of the value.
base  The base.
systemId  The system id.
publicId  The public id.
notationName  The name of the notation.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 780 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.

void XmlParser::exposeEvent XmlModelEvent   ev [protected]
 

Expose the XML event to XML model.

Sends a XML event to the XML model.

Parameters:
ev  The XML event.

Definition at line 836 of file xmlparser.cpp.

References XmlModelBase::manageEvent, WRN, and XmlParserBase::xmlModel.

Referenced by characterData, comment, defaultHandler, endCDATASection, endDoctypeDecl, endElement, entityDecl, notationDecl, processingInstruction, startCDATASection, startDoctypeDecl, startElement, and xmlDecl.

void XmlParser::initParser const XmlChar *    encoding [protected, virtual]
 

Initialization of the parser with given encoding.

Initializes the parser (sets the SAX handlers, etc.)

Parameters:
encoding  The encoding of the XML data.

Definition at line 223 of file xmlparser.cpp.

References charactersTotal, CHECK_POINTER, innerParser, NEW, ParseInfo::parser, and XmlChar.

Referenced by XmlParser.

void XmlParser::notationDecl void *    userData,
const XmlChar *    notationName,
const XmlChar *    base,
const XmlChar *    systemId,
const XmlChar *    publicId
[virtual]
 

Notation declaration handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
notationName  The name of the notation.
base  The base.
systemId  The system id.
publicId  The public id.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 812 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.

long XmlParser::parse void    throw (ExaltParserException, ExaltEncodingException, ExaltIOException) [virtual]
 

Parse XML stream.

Reads the data from the input device and parses it.

Returns:
The number of characters parsed so far.

Reimplemented from XmlParserBase.

Definition at line 291 of file xmlparser.cpp.

References FATAL, ReadOk, and XML_BUFFER_SIZE.

Referenced by XmlCodec::encode.

long XmlParser::parsePush const char *    data,
int    length,
bool    isFinal
throw (ExaltParserException, ExaltEncodingException, ExaltIOException) [virtual]
 

Parse XML data in PUSH mode.

Parses given data in the PUSH mode.

Parameters:
data  Buffer of XMl data.
length  The length of the buffer.
isFinal  Indication if the buffer contains the last portion of XML data.

Reimplemented from XmlParserBase.

Definition at line 345 of file xmlparser.cpp.

Referenced by XmlCodec::encodePush.

void XmlParser::processingInstruction void *    userData,
const XmlChar *    target,
const XmlChar *    data
[virtual]
 

Processing instruction handler.

Examines the description of the processing instruction and emits an event to the XML model.

Parameters:
userData  Pointer to the user data structure.
target  Target of the instruction.
data  Data of the instruction.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 507 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.

void XmlParser::reportError void    [virtual]
 

Report parser error messages.

Used for reporting error messages generated by Expat.

Reimplemented from SAXBase.

Definition at line 375 of file xmlparser.cpp.

References innerParser, and PARSERERR.

void XmlParser::startCDATASection void *    userData [virtual]
 

Start CDATA section handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 553 of file xmlparser.cpp.

References exposeEvent, NEW, and OUTPUT.

void XmlParser::startDoctypeDecl void *    userData,
const XmlChar *    doctypeName,
const XmlChar *    systemId,
const XmlChar *    publicId,
int    hasInternalSubset
[virtual]
 

Start doctype handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
doctypeName  The name of the doctype.
systemId  The system id.
publicId  The public id.
hasInternalSubset  Has the DTD an internal subset?
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 726 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.

void XmlParser::startElement void *    userData,
const XmlChar *    name,
const XmlChar **    attr
[virtual]
 

Start element handler.

Examines the name of the element and the values of its attributes and emits corresponding events to the XML model.

Parameters:
userData  Pointer to the user data structure.
name  Name of the element.
attr  An array of attributes.
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 395 of file xmlparser.cpp.

References DELETE_ARRAY, ParseInfo::depth, exposeEvent, NEW, OUTPUT, XmlChar, xmlchar_strcat, xmlchar_strcpy, and xmlchar_strlen.

int XmlParser::unknownEncoding void *    unknownEncodingData,
const XmlChar *    name,
XML_Encoding *    info
[virtual]
 

Unknown encoding handler.

If there is no text codec specified, the parser creates a default one. The it registers the conversion functions.

Parameters:
unknownEncodingData  The description of the encoding.
name  The name of the encoding
info  The Expat's info structure.
See also:
XmlParser::exposeEvent() , TextCodec

Reimplemented from SAXBase.

Definition at line 626 of file xmlparser.cpp.

References UserOfTextCodec::createDefaultTextCodec, TextCodec::fillInMapArray, TextCodec::getMIB, TextCodec::isAbleToConvert, EncodingInfo::mib, NEW, OUTPUT, EncodingInfo::textCodec, UserOfTextCodec::textCodec, and XmlChar.

void XmlParser::xmlDecl void *    userData,
const XmlChar *    version,
const XmlChar *    encoding,
int    standalone
[virtual]
 

XML declaration handler.

Sends a corresponding event to the XML model.

Parameters:
userData  Pointer to the user data structure.
version  The XML version.
encoding  The encoding of the document.
standalone  Is the document standalone?
See also:
XmlParser::exposeEvent()

Reimplemented from SAXBase.

Definition at line 697 of file xmlparser.cpp.

References exposeEvent, NEW, OUTPUT, and XmlChar.


Member Data Documentation

XmlInnerParser XmlParser::innerParser [protected]
 

Expat parser structure.

This is the "heart" of the class, which realizes the main part of the SAX parsing. All SAX events emitted by innerParser are redirected to handlers of the class.

Definition at line 154 of file xmlparser.h.

Referenced by initParser, reportError, and ~XmlParser.

char XmlParser::xmlDataBuff[XML_BUFFER_SIZE] [protected]
 

Buffer for XML data.

Data coming from the XML stream are stored in this buffer. If the size of the data is larger than XML_BUFFER_SIZE, the parsing is done in more blocks.

Definition at line 161 of file xmlparser.h.


The documentation for this class was generated from the following files:
Generated on Wed Feb 5 10:43:07 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002