class XmlSaxParser

# class XmlSaxParser | Serial Access XML Parser. More...
Full name | `TelEngine::XmlSaxParser`
Definition | `#include <yatexml.h>`
Inherits | TelEngine::DebugEnabler [public ]
Inherited by | XmlDomParser
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Error { NoError = 0, NotWellFormed, Unknown, IOError, ElementParse, ReadElementName, InvalidElementName, ReadingAttributes, CommentParse, DeclarationParse, DefinitionParse, CDataParse, ReadingEndTag, Incomplete, InvalidEncoding, UnsupportedEncoding, UnsupportedVersion, }
- enum Type { None = 0, Text = 1, CData = 2, Element = 3, Doctype = 4, Comment = 5, Declaration = 6, Instruction = 7, EndTag = 8, Special = 9 }

#### Public Methods

- virtual ~XmlSaxParser ()
- inline unsigned int offset () const
- inline unsigned int row () const
- inline unsigned int column () const
- inline const String& buffer () const
- bool parse (const char* data)
- bool completeText ()
- inline Error error ()
- bool setError (Error error, XmlChild* child = 0)
- inline const char* getError (const char* defVal = "Xml error")
- inline Type unparsed ()
- inline void setUnparsed (Type id)
- virtual void reset ()
- const String& getBuffer () const

#### Public Static Methods

- static inline const char* getError (int code, const char* defVal = "Xml error")
- static inline bool blank (char c)
- static bool checkFirstNameCharacter (unsigned char ch)
- static bool checkDataChar (unsigned char c)
- static bool checkNameCharacter (unsigned char ch)
- static bool validTag (const String& buf)
- static void escape (String& buf, const String& text)

#### Public Members

- static const TokenDict s_errorString[]
- static const XmlEscape s_escape[]

#### Protected Methods

- XmlSaxParser (const char* name = "XmlSaxParser")
- bool parseInstruction ()
- bool parseCData ()
- bool parseComment ()
- bool parseElement ()
- bool parseDeclaration ()
- bool parseSpecial ()
- bool parseEndTag ()
- bool parseDoctype ()
- bool auxParse ()
- void unEscape (String& text)
- void skipBlanks ()
- inline bool badCharacter (char c)
- inline void resetError ()
- inline void resetParsed ()
- String* extractName (bool& empty)
- NamedString* getAttribute ()
- virtual void gotComment (const String& text)
- virtual void gotProcessing (const NamedString& instr)
- virtual void gotDeclaration (const NamedList& decl)
- virtual void gotText (const String& text)
- virtual void gotCdata (const String& data)
- virtual void gotElement (const NamedList& element, bool empty)
- virtual void endElement (const String& name)
- virtual void gotDoctype (const String& doc)
- virtual bool completed ()
- bool processElement (NamedList& list, bool empty)
- bool processText (String& text)

#### Protected Members

- unsigned int m_offset
- unsigned int m_row
- unsigned int m_column
- Error m_error
- String m_buf
- NamedList m_parsed
- Type m_unparsed

## Detailed Description

A Serial Access Parser (SAX) for arbitrary XML data

enum Error { NoError = 0, NotWellFormed, Unknown, IOError, ElementParse, ReadElementName, InvalidElementName, ReadingAttributes, CommentParse, DeclarationParse, DefinitionParse, CDataParse, ReadingEndTag, Incomplete, InvalidEncoding, UnsupportedEncoding, UnsupportedVersion, } | ### Error

enum Type { None = 0, Text = 1, CData = 2, Element = 3, Doctype = 4, Comment = 5, Declaration = 6, Instruction = 7, EndTag = 8, Special = 9 } | ### Type

~XmlSaxParser () | ### ~XmlSaxParser

[virtual]

Destructor

inline unsigned int offset () | ### offset

[const]

Get the number of bytes successfully parsed

Returns: The number of bytes successfully parsed

inline unsigned int row () | ### row

[const]

Get the row where the parser has found an error

Returns: The row number

inline unsigned int column () | ### column

[const]

Get the column where the parser has found an error

Returns: The column number

inline const String& buffer () | ### buffer

[const]

Retrieve the parser's buffer

Returns: The parser's buffer

bool parse (const char* data) | ### parse

Parse a given string

Parameters:

data | The data to parse

Returns: True if all data was successfully parsed

bool completeText () | ### completeText

Process incomplete text if the parser is completed. This method should be called to complete text after all data was pushed into the parser

Returns: True if all data was successfully parsed

inline Error error () | ### error

Get the error code found while parsing

Returns: Error code

bool setError (Error error, XmlChild* child = 0) | ### setError

Set the error code and destroys a child if error code is not NoError

Parameters:

error | The error found
child | Child to destroy

Returns: False on error

inline const char* getError (const char* defVal = "Xml error") | ### getError

Retrieve the error string associated with current error status

Parameters:

defVal | Value to return if not found

Returns: The error string

inline Type unparsed () | ### unparsed

Returns: The last xml type that we were parsing, but we have not finished

inline void setUnparsed (Type id) | ### setUnparsed

Set the last xml type that we were parsing, but we have not finished

Parameters:

id | The xml type that we haven't finish to parse

void reset () | ### reset

[virtual]

Reset error flag

const String& getBuffer () | ### getBuffer

[const]

Returns: The internal buffer

inline const char* getError (int code, const char* defVal = "Xml error") | ### getError

[static]

Retrieve the error string associated with a given error code

Parameters:

code | Code of the error to look up
defVal | Value to return if not found

Returns: The error string

inline bool blank (char c) | ### blank

[static]

Check if the given character is blank

Parameters:

c | The character to verify

Returns: True if c is blank

bool checkFirstNameCharacter (unsigned char ch) | ### checkFirstNameCharacter

[static]

Verify if the given character is in the range allowed to be first character from a xml tag

Parameters:

ch | The character to check

Returns: True if the character is in range

bool checkDataChar (unsigned char c) | ### checkDataChar

[static]

Check if the given character is in the range allowed for an xml char

Parameters:

c | The character to check

Returns: True if the character is in range

bool checkNameCharacter (unsigned char ch) | ### checkNameCharacter

[static]

Verify if the given character is in the range allowed for a xml name

Parameters:

ch | The character to check

Returns: True if the character is in range

bool validTag (const String& buf) | ### validTag

[static]

Check if a given string is a valid xml tag name

Parameters:

buf | The string to check

Returns: True if the string is a valid xml tag name

void escape (String& buf, const String& text) | ### escape

[static]

XmlEscape the given text

Parameters:

buf | Destination buffer
text | The text to escape

static const TokenDict s_errorString[] | ### s_errorString[]

static const XmlEscape s_escape[] | ### s_escape[]

XmlSaxParser (const char* name = "XmlSaxParser") | ### XmlSaxParser

[protected]

Constructor

Parameters:

name | Debug name

bool parseInstruction () | ### parseInstruction

[protected]

Parse an instruction form the main buffer. Extracts the parsed string from buffer if returns true

Returns: True if the instruction was parsed successfully

bool parseCData () | ### parseCData

[protected]

Parse a CData section form the main buffer. Extracts the parsed string from buffer if returns true

Returns: True if the CData section was parsed successfully

bool parseComment () | ### parseComment

[protected]

Parse a comment form the main buffer. Extracts the parsed string from buffer if returns true

Returns: True if the comment was parsed successfully

bool parseElement () | ### parseElement

[protected]

Parse an element form the main buffer. Extracts the parsed string from buffer if returns true

Returns: True if the element was parsed successfully

bool parseDeclaration () | ### parseDeclaration

[protected]

Parse a declaration form the main buffer. Extracts the parsed string from buffer if returns true

Returns: True if the declaration was parsed successfully

bool parseSpecial () | ### parseSpecial

[protected]

Helper method to classify the Xml objects starting with "

Returns: True if a corresponding xml object was found and parsed successfully

bool parseEndTag () | ### parseEndTag

[protected]

Parse an endtag form the main buffer. Extracts the parsed string from buffer if returns true

Returns: True if the endtag was parsed successfully

bool parseDoctype () | ### parseDoctype

[protected]

Parse a doctype form the main buffer. Extracts the parsed string from buffer if returns true. Warning: This is a stub implementation

Returns: True if the doctype was parsed successfully

bool auxParse () | ### auxParse

[protected]

Parse an unfinished xml object. Extracts the parsed string from buffer if returns true

Returns: True if the object was parsed successfully

void unEscape (String& text) | ### unEscape

[protected]

Unescape the given text. Handled: &lt; &gt; &apos; &quot; &amp; &\#DecimalNumber; &\#xHexNumber;

Parameters:

text | The requested text to unescape

void skipBlanks () | ### skipBlanks

[protected]

Remove blank characters from the begining of the buffer

inline bool badCharacter (char c) | ### badCharacter

[protected]

Check if a character is an angle bracket

Parameters:

c | The character to verify

Returns: True if c is an angle bracket

inline void resetError () | ### resetError

[protected]

Reset the error

inline void resetParsed () | ### resetParsed

[protected]

Reset parsed value and parameters

String* extractName (bool& empty) | ### extractName

[protected]

Extract the name of an element or instruction

Returns: The extracted string or 0

NamedString* getAttribute () | ### getAttribute

[protected]

Extract an attribute

Returns: The attribute value or 0

void gotComment (const String& text) | ### gotComment

[protected virtual]

Callback method. Is called when a comment was successfully parsed. Default implementation does nothing

Parameters:

text | The comment content

void gotProcessing (const NamedString& instr) | ### gotProcessing

[protected virtual]

Callback method. Is called when an instruction was successfully parsed. Default implementation does nothing

Parameters:

instr | The instruction content

void gotDeclaration (const NamedList& decl) | ### gotDeclaration

[protected virtual]

Callback method. Is called when a declaration was successfully parsed. Default implementation does nothing

Parameters:

decl | The declaration content

void gotText (const String& text) | ### gotText

[protected virtual]

Callback method. Is called when a text was successfully parsed. Default implementation does nothing

Parameters:

text | The text content

void gotCdata (const String& data) | ### gotCdata

[protected virtual]

Callback method. Is called when a CData section was successfully parsed. Default implementation does nothing

Parameters:

data | The CData content

void gotElement (const NamedList& element, bool empty) | ### gotElement

[protected virtual]

Callback method. Is called when an element was successfully parsed. Default implementation does nothing

Parameters:

element | The element content
empty | True if the element does not have attributes

void endElement (const String& name) | ### endElement

[protected virtual]

Callback method. Is called when a end tag was successfully parsed. Default implementation does nothing

Parameters:

name | The end tag name

void gotDoctype (const String& doc) | ### gotDoctype

[protected virtual]

Callback method. Is called when a doctype was successfully parsed. Default implementation does nothing

Parameters:

doc | The doctype content

bool completed () | ### completed

[protected virtual]

Callback method. Is called to check if we have an incomplete element. Default implementation returns always true

Returns: True

bool processElement (NamedList& list, bool empty) | ### processElement

[protected]

Calls gotElement() and eset parsed on success

Parameters:

list | The list element and its attributes
empty | True if the element does not have attributes

Returns: True if there is no error

bool processText (String& text) | ### processText

[protected]

Unescape text, call gotText() and reset parsed on success

Parameters:

text | The text to process

Returns: True if there is no error

unsigned int m_offset | ### m_offset

[protected]

unsigned int m_row | ### m_row

[protected]

unsigned int m_column | ### m_column

[protected]

Error m_error | ### m_error

[protected]

String m_buf | ### m_buf

[protected]

NamedList m_parsed | ### m_parsed

[protected]

Type m_unparsed | ### m_unparsed

[protected]

Generated by: paulc on bussard on Fri May 8 12:37:22 2015, using kdoc 2.0a54.