class XmlSaxParser

Serial Access XML Parser. More...

Full nameTelEngine::XmlSaxParser
Definition#include <yatexml.h>
InheritsTelEngine::DebugEnabler [public ]
Inherited byXmlDomParser
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Public Members

Protected Methods

Protected Members


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:
dataThe 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:
errorThe error found
childChild 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:
defValValue 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:
idThe 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:
codeCode of the error to look up
defValValue to return if not found

Returns: The error string

inline bool  blank (char c)

blank

[static]

Check if the given character is blank

Parameters:
cThe 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:
chThe 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:
cThe 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:
chThe 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:
bufThe 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:
bufDestination buffer
textThe 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:
nameDebug 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:
textThe 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:
cThe 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:
textThe 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:
instrThe 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:
declThe 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:
textThe 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:
dataThe 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:
elementThe element content
emptyTrue 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:
nameThe 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:
docThe 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:
listThe list element and its attributes
emptyTrue 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:
textThe 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.