CMDXMLParser Class Reference

class CMDXMLParser : public CActive

Creates a DOM structure from a given XML file.

The parsing operation is asynchronous and is initiated by a call to ParseFile() . On completion, the created DOM document can be retrieved through DetachXMLDoc() .

Note the following ownership rules for the DOM document:

1. calling DetachXMLDoc() transfers ownership of the document to the client

2. if the parser is asked to parse a new file while it still owns an existing DOM document, it will delete the old document.

Inherits from

Public Member Functions
~CMDXMLParser ()
IMPORT_C CMDXMLDocument * DetachXMLDoc ()
CMDXMLEntityConverter * EntityConverter ()
IMPORT_C TInt Error ()
IMPORT_C TXMLErrorCodeSeverity ErrorSeverity ()
IMPORT_C CMDXMLParser * NewL ( MMDXMLParserObserver *)
IMPORT_C CMDXMLParser * NewL ( MMDXMLParserObserver *, MXMLDtd *)
IMPORT_C CMDXMLParser * NewLC ( MMDXMLParserObserver *)
IMPORT_C CMDXMLParser * NewLC ( MMDXMLParserObserver *, MXMLDtd *)
IMPORT_C TInt ParseFile ( RFs , const TDesC &)
IMPORT_C TInt ParseFile ( RFile &)
void ParseSource ( MMDXMLParserDataProvider *)
IMPORT_C void ParseSourceL ( MMDXMLParserDataProvider *)
IMPORT_C void SetEntityConverter ( CMDXMLEntityConverter *)
IMPORT_C void SetSourceCharacterWidth ( TMDXMLParserInputCharWidth )
IMPORT_C void SetStoreInvalid ( TBool )
IMPORT_C void SetWhiteSpaceHandlingMode ( TBool )
Private Member Functions
CMDXMLParser ( MMDXMLParserObserver *)
CMDXMLParser ( MMDXMLParserObserver *, MXMLDtd *)
void AddTextL (CMDXMLElement *)
TBool CDataSectionL (CMDXMLElement *)
void CheckForErrors ()
TInt CheckForStartCData (const TDesC &)
TBool CommentL (CMDXMLElement *)
void ConstructL (MXMLDtd *)
void CreateDocumentL ()
TBool DetectFileType ()
IMPORT_C void DoCancel ()
TBool DoParseLoopL ()
TBool DocTypeL ()
TBool EndOfCDataSection ()
TInt FindDelimiter ( TDesC &, TDesC &)
TGetCharReturn GetChar ( TDes &)
TGetCharReturn GetDoubleByteChar ( TDes &)
void GetMoreData ()
TGetCharReturn GetSingleByteChar ( TDes &)
void HandleTextL ( TDes &)
TBool InCDataSection ( TDesC &)
TInt LocateNextAttribute (const TDesC &)
void Panic ( TPanicCode )
TInt ParseElementAttributesL (CMDXMLElement &, TDes &)
TInt ParseElementEndTag (CMDXMLElement &, const TDesC &)
TInt ParseSingleAttributeL ( TDes &)
CMDXMLElement * ParseStartTagL ()
IMPORT_C void PlaceholderForRemovedExport1 ( MMDXMLParserObserver *)
IMPORT_C void PlaceholderForRemovedExport2 ( MMDXMLParserObserver *, MXMLDtd *)
IMPORT_C void PlaceholderForRemovedExport3 ()
void PrepareForReuseL ()
TBool ProcessingInstructionL (CMDXMLElement *)
IMPORT_C TInt RunError ( TInt )
void RunL ()
IMPORT_C void SetError (const TInt , const TXMLErrorCodeSeverity )
TBool VersionIDL ()
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::Extension_(TUint,TAny *&,TAny *)
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enum TMDXMLParserInputCharWidth { EAscii  = 0x01, EUnicode  = 0x02 }
Private Member Enumerations
enum EParserStates {
KInitFromFile , KDetermineCharset , KWaitingForData , KParseData , KSpanDataGap , KFinished
}
enum TGetCharReturn { KError  = 0x00, KCharReturned , KWaitForChar }
enum TPanicCode { ENullMemVarDataSource , ENullMemVarParserObserver , ENullMemVarXMLDoc , ENullMemVarElementTag , ENullParameterParentElement }
Inherited Enumerations
CActive:TPriority
Private Attributes
HBufC8 * iBomBuffer
TInt iBytesPerChar
TBool iClosed
TInt iCurrentInputBufferLen
MMDXMLParserDataProvider * iDataSource
TBool iDocTypeSet
MXMLDtd * iDtdRepresentation
HBufC * iElementTag
TBool iEndOfTag
CMDXMLEntityConverter * iEntityConverter
TInt iError
RFile iFileHandleToParse
CMDXMLParserFileDataSource * iFileSource
TDesC * iFileToParse
TPtrC8 iInputBufferPtr
TInt iInputBytesRemaining
CMDXMLElement * iNewElement
TInt iNextChar
TBool iOpened
CMDXMLElement * iParentElement
MMDXMLParserObserver * iParserObserver
TBool iPreserve
EParserStates iPreviousState
RFs iRFs
TInt iRequiredUTF8Bytes
TXMLErrorCodeSeverity iSeverity
TBuf < 1 > iSpareChar
EParserStates iState
TBool iStoreInvalid
TInt iSuspiciousCharacter
HBufC * iText
HBufC8 * iUTF8EdgeBuffer
TBuf < 32 > iUnicodeConversion
TInt iUnicodeConversionLen
TBool iUnicodeInputMisaligned
TInt iUnicodeReadPos
TBool iVersionSet
CMDXMLDocument * iXMLDoc
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

CMDXMLParser(MMDXMLParserObserver *)

CMDXMLParser ( MMDXMLParserObserver * aParserObserver ) [private]

Parameters

MMDXMLParserObserver * aParserObserver

CMDXMLParser(MMDXMLParserObserver *, MXMLDtd *)

CMDXMLParser ( MMDXMLParserObserver * aParserObserver,
MXMLDtd * aDtdRepresentation
) [private]

Parameters

MMDXMLParserObserver * aParserObserver
MXMLDtd * aDtdRepresentation

~CMDXMLParser()

IMPORT_C ~CMDXMLParser ( )

Destructor.

Member Functions Documentation

AddTextL(CMDXMLElement *)

void AddTextL ( CMDXMLElement * aParentElement ) [private]

Parameters

CMDXMLElement * aParentElement

CDataSectionL(CMDXMLElement *)

TBool CDataSectionL ( CMDXMLElement * aParentElement ) [private]

Parameters

CMDXMLElement * aParentElement

CheckForErrors()

void CheckForErrors ( ) [private]

This should be called when parsing has been completed, before calling ParseFileCompleteL(). It checks for errors that can only be determined at the end of parsing, eg missing doctype or incomplete content.

CheckForStartCData(const TDesC &)

TInt CheckForStartCData ( const TDesC & aTextToCheck ) [private]

Parameters

const TDesC & aTextToCheck

CommentL(CMDXMLElement *)

TBool CommentL ( CMDXMLElement * aParentElement ) [private]

Parameters

CMDXMLElement * aParentElement

ConstructL(MXMLDtd *)

void ConstructL ( MXMLDtd * aDtdRepresentation ) [private]

Parameters

MXMLDtd * aDtdRepresentation

CreateDocumentL()

void CreateDocumentL ( ) [private, virtual]

DetachXMLDoc()

IMPORT_C CMDXMLDocument * DetachXMLDoc ( )

Gets the created DOM.

This should be called after the conclusion of the parser process.

Note that the function sets the internal variable pointing to the document to NULL, so this function can only be called once per file parse. The caller takes ownership of the document, and must delete it when its use is complete.

DetectFileType()

TBool DetectFileType ( ) [private]

DoCancel()

IMPORT_C void DoCancel ( ) [private, virtual]

Implements cancellation of an outstanding request.

This function is called as part of the active object's Cancel() .

It must call the appropriate cancel function offered by the active object's asynchronous service provider. The asynchronous service provider's cancel is expected to act immediately.

DoCancel() must not wait for event completion; this is handled by Cancel() .

CActive::Cancel

DoParseLoopL()

TBool DoParseLoopL ( ) [private]

DocTypeL()

TBool DocTypeL ( ) [private]

EndOfCDataSection()

TBool EndOfCDataSection ( ) [private]

EntityConverter()

CMDXMLEntityConverter * EntityConverter ( )

Gets the entity converter.

Error()

IMPORT_C TInt Error ( ) const

Gets the last error found by the parser.

ErrorSeverity()

IMPORT_C TXMLErrorCodeSeverity ErrorSeverity ( ) const

Get the severity of the most severe error found.

FindDelimiter(TDesC &, TDesC &)

TInt FindDelimiter ( TDesC & aDataToSearch,
TDesC & aDelimiterToFind
) [private]

Parameters

TDesC & aDataToSearch
TDesC & aDelimiterToFind

GetChar(TDes &)

TGetCharReturn GetChar ( TDes & aChar ) [private]

Parameters

TDes & aChar

GetDoubleByteChar(TDes &)

TGetCharReturn GetDoubleByteChar ( TDes & aChar ) [private]

Parameters

TDes & aChar

GetMoreData()

void GetMoreData ( ) [private]

GetSingleByteChar(TDes &)

TGetCharReturn GetSingleByteChar ( TDes & aChar ) [private]

Parameters

TDes & aChar

HandleTextL(TDes &)

void HandleTextL ( TDes & aChar ) [private, virtual]

Parameters

TDes & aChar

InCDataSection(TDesC &)

TBool InCDataSection ( TDesC & aDataToSearch ) [private]

Parameters

TDesC & aDataToSearch

LocateNextAttribute(const TDesC &)

TInt LocateNextAttribute ( const TDesC & aTagToParse ) [private]

This function locates the next attribute in the tag.

Parameters

const TDesC & aTagToParse the tag to find the attribute in

NewL(MMDXMLParserObserver *)

IMPORT_C CMDXMLParser * NewL ( MMDXMLParserObserver * aParserObserver ) [static]

Allocates and constructs a new XML parser, specifying a DTD.

leave
KErrNoMemory Out of memory

Parameters

MMDXMLParserObserver * aParserObserver XML parser observer

NewL(MMDXMLParserObserver *, MXMLDtd *)

IMPORT_C CMDXMLParser * NewL ( MMDXMLParserObserver * aParserObserver,
MXMLDtd * aDtdRepresentation
) [static]

Allocates and constructs a new XML parser, specifying a DTD.

leave
KErrNoMemory Out of memory

Parameters

MMDXMLParserObserver * aParserObserver XML parser observer
MXMLDtd * aDtdRepresentation DTD validator

NewLC(MMDXMLParserObserver *)

IMPORT_C CMDXMLParser * NewLC ( MMDXMLParserObserver * aParserObserver ) [static]

Allocates and constructs a new XML parser, leaving the object on the cleanup stack.

leave
KErrNoMemory Out of memory

Parameters

MMDXMLParserObserver * aParserObserver XML parser observer

NewLC(MMDXMLParserObserver *, MXMLDtd *)

IMPORT_C CMDXMLParser * NewLC ( MMDXMLParserObserver * aParserObserver,
MXMLDtd * aDtdRepresentation
) [static]

Allocates and constructs a new XML parser, leaving the object on the cleanup stack.

leave
KErrNoMemory Out of memory

Parameters

MMDXMLParserObserver * aParserObserver XML parser observer
MXMLDtd * aDtdRepresentation DTD validator

Panic(TPanicCode)

void Panic ( TPanicCode aReason ) const [private]

Parameters

TPanicCode aReason

ParseElementAttributesL(CMDXMLElement &, TDes &)

TInt ParseElementAttributesL ( CMDXMLElement & aElement,
TDes & aTagToParse
) [private]

Parameters

CMDXMLElement & aElement
TDes & aTagToParse

ParseElementEndTag(CMDXMLElement &, const TDesC &)

TInt ParseElementEndTag ( CMDXMLElement & aElement,
const TDesC & aTagToParse
) [private]

Parameters

CMDXMLElement & aElement
const TDesC & aTagToParse

ParseFile(RFs, const TDesC &)

IMPORT_C TInt ParseFile ( RFs aRFs,
const TDesC & aFileToParse
)

Parses a specified XML file into a DOM object tree.

Parameters

RFs aRFs File server session
const TDesC & aFileToParse The file name to parse

ParseFile(RFile &)

IMPORT_C TInt ParseFile ( RFile & aFileHandleToParse )

Parses a specified XML file into a DOM object tree.

Parses a specified XML file into a DOM object tree using an open file handle. The parser takes ownership of the open file handle and will close handle when completed.

Parameters

RFile & aFileHandleToParse An open file handle for the file to parse. Ownership of the file handle is passed.

ParseSingleAttributeL(TDes &)

TInt ParseSingleAttributeL ( TDes & aAttributeValue ) [private]

Parameters

TDes & aAttributeValue

ParseSource(MMDXMLParserDataProvider *)

void ParseSource ( MMDXMLParserDataProvider * aSource ) [inline]

Parses a specified XML Data Source into a DOM object tree. Use ParseSourceL() function in preference to ParseSource()

Parameters

MMDXMLParserDataProvider * aSource MMDXMLParserDataProvider pointer

ParseSourceL(MMDXMLParserDataProvider *)

IMPORT_C void ParseSourceL ( MMDXMLParserDataProvider * aSource )

Parses a specified XML Data Source into a DOM object tree.

Parameters

MMDXMLParserDataProvider * aSource MMDXMLParserDataProvider pointer

ParseStartTagL()

CMDXMLElement * ParseStartTagL ( ) [private, virtual]

PlaceholderForRemovedExport1(MMDXMLParserObserver *)

IMPORT_C void PlaceholderForRemovedExport1 ( MMDXMLParserObserver * aParserObserver ) [private]

Parameters

MMDXMLParserObserver * aParserObserver

PlaceholderForRemovedExport2(MMDXMLParserObserver *, MXMLDtd *)

IMPORT_C void PlaceholderForRemovedExport2 ( MMDXMLParserObserver * aParserObserver,
MXMLDtd * aDtdRepresentation
) [private]

Parameters

MMDXMLParserObserver * aParserObserver
MXMLDtd * aDtdRepresentation

PlaceholderForRemovedExport3()

IMPORT_C void PlaceholderForRemovedExport3 ( ) [private]

PrepareForReuseL()

void PrepareForReuseL ( ) [private]

ProcessingInstructionL(CMDXMLElement *)

TBool ProcessingInstructionL ( CMDXMLElement * aParentElement ) [private]

Parameters

CMDXMLElement * aParentElement

RunError(TInt)

IMPORT_C TInt RunError ( TInt aError ) [private, virtual]

Parameters

TInt aError

RunL()

void RunL ( ) [private, virtual]

Handles an active object's request completion event.

A derived class must provide an implementation to handle the completed request. If appropriate, it may issue another request.

The function is called by the active scheduler when a request completion event occurs, i.e. after the active scheduler's WaitForAnyRequest() function completes.

Before calling this active object's RunL() function, the active scheduler has:

1. decided that this is the highest priority active object with a completed request

2. marked this active object's request as complete (i.e. the request is no longer outstanding)

RunL() runs under a trap harness in the active scheduler. If it leaves, then the active scheduler calls RunError() to handle the leave.

Note that once the active scheduler's Start() function has been called, all user code is run under one of the program's active object's RunL() or RunError() functions.

CActiveScheduler::Start CActiveScheduler::Error CActiveScheduler::WaitForAnyRequest TRAPD

SetEntityConverter(CMDXMLEntityConverter *)

IMPORT_C void SetEntityConverter ( CMDXMLEntityConverter * aEntityConverter )

Sets the entity converter to be used for parsing. and take ownership of the passed entity converter

Parameters

CMDXMLEntityConverter * aEntityConverter the entity converter to be used.

SetError(const TInt, const TXMLErrorCodeSeverity)

IMPORT_C void SetError ( const TInt aErrorCode,
const TXMLErrorCodeSeverity aSeverity
) [private]

Parameters

const TInt aErrorCode
const TXMLErrorCodeSeverity aSeverity

SetSourceCharacterWidth(TMDXMLParserInputCharWidth)

IMPORT_C void SetSourceCharacterWidth ( TMDXMLParserInputCharWidth aWidth )

Sets the input stream character width.

Parameters

TMDXMLParserInputCharWidth aWidth Character width for incoming stream. Possible values are EAscii and EUnicode (representing Ascii/UTF8 and Unicode respectively).

SetStoreInvalid(TBool)

IMPORT_C void SetStoreInvalid ( TBool aStoreInvalid )

Controls whether invalid elements and attributes are added to the DOM.

Parameters

TBool aStoreInvalid ETrue if invalid content should be stored, EFalse otherwise.

SetWhiteSpaceHandlingMode(TBool)

IMPORT_C void SetWhiteSpaceHandlingMode ( TBool aPreserve )

Controls whether whitespaces are handled by XML parser or by client.

Parameters

TBool aPreserve ETrue if all whitespaces should be preserved (handled by client), EFalse otherwise.

VersionIDL()

TBool VersionIDL ( ) [private]

Member Enumerations Documentation

Enum EParserStates

Enumerators

KInitFromFile
KDetermineCharset
KWaitingForData
KParseData
KSpanDataGap
KFinished

Enum TGetCharReturn

Enumerators

KError = 0x00
KCharReturned
KWaitForChar

Enum TMDXMLParserInputCharWidth

Defines input stream character widths.

Enumerators

EAscii = 0x01
EUnicode = 0x02

Enum TPanicCode

Enumerators

ENullMemVarDataSource
ENullMemVarParserObserver
ENullMemVarXMLDoc
ENullMemVarElementTag
ENullParameterParentElement

Member Data Documentation

HBufC8 * iBomBuffer

HBufC8 * iBomBuffer [private]

TInt iBytesPerChar

TInt iBytesPerChar [private]

TBool iClosed

TBool iClosed [private]

TInt iCurrentInputBufferLen

TInt iCurrentInputBufferLen [private]

MMDXMLParserDataProvider * iDataSource

MMDXMLParserDataProvider * iDataSource [private]

TBool iDocTypeSet

TBool iDocTypeSet [private]

MXMLDtd * iDtdRepresentation

MXMLDtd * iDtdRepresentation [private]

HBufC * iElementTag

HBufC * iElementTag [private]

TBool iEndOfTag

TBool iEndOfTag [private]

CMDXMLEntityConverter * iEntityConverter

CMDXMLEntityConverter * iEntityConverter [private]

TInt iError

TInt iError [private]

RFile iFileHandleToParse

RFile iFileHandleToParse [private]

CMDXMLParserFileDataSource * iFileSource

CMDXMLParserFileDataSource * iFileSource [private]

TDesC * iFileToParse

TDesC * iFileToParse [private]

TPtrC8 iInputBufferPtr

TPtrC8 iInputBufferPtr [private]

TInt iInputBytesRemaining

TInt iInputBytesRemaining [private]

CMDXMLElement * iNewElement

CMDXMLElement * iNewElement [private]

TInt iNextChar

TInt iNextChar [private]

TBool iOpened

TBool iOpened [private]

CMDXMLElement * iParentElement

CMDXMLElement * iParentElement [private]

MMDXMLParserObserver * iParserObserver

MMDXMLParserObserver * iParserObserver [private]

TBool iPreserve

TBool iPreserve [private]

EParserStates iPreviousState

EParserStates iPreviousState [private]

RFs iRFs

RFs iRFs [private]

TInt iRequiredUTF8Bytes

TInt iRequiredUTF8Bytes [private]

TXMLErrorCodeSeverity iSeverity

TXMLErrorCodeSeverity iSeverity [private]

TBuf< 1 > iSpareChar

TBuf < 1 > iSpareChar [private]

EParserStates iState

EParserStates iState [private]

TBool iStoreInvalid

TBool iStoreInvalid [private]

TInt iSuspiciousCharacter

TInt iSuspiciousCharacter [private]

HBufC * iText

HBufC * iText [private]

HBufC8 * iUTF8EdgeBuffer

HBufC8 * iUTF8EdgeBuffer [private]

TBuf< 32 > iUnicodeConversion

TBuf < 32 > iUnicodeConversion [private]

TInt iUnicodeConversionLen

TInt iUnicodeConversionLen [private]

TBool iUnicodeInputMisaligned

TBool iUnicodeInputMisaligned [private]

TInt iUnicodeReadPos

TInt iUnicodeReadPos [private]

TBool iVersionSet

TBool iVersionSet [private]

CMDXMLDocument * iXMLDoc

CMDXMLDocument * iXMLDoc [private]