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 TIntError()
IMPORT_C TXMLErrorCodeSeverityErrorSeverity()
IMPORT_C CMDXMLParser *NewL(MMDXMLParserObserver *)
IMPORT_C CMDXMLParser *NewL(MMDXMLParserObserver *, MXMLDtd *)
IMPORT_C CMDXMLParser *NewLC(MMDXMLParserObserver *)
IMPORT_C CMDXMLParser *NewLC(MMDXMLParserObserver *, MXMLDtd *)
IMPORT_C TIntParseFile(RFs, const TDesC &)
IMPORT_C TIntParseFile(RFile &)
voidParseSource(MMDXMLParserDataProvider *)
IMPORT_C voidParseSourceL(MMDXMLParserDataProvider *)
IMPORT_C voidSetEntityConverter(CMDXMLEntityConverter *)
IMPORT_C voidSetSourceCharacterWidth(TMDXMLParserInputCharWidth)
IMPORT_C voidSetStoreInvalid(TBool)
IMPORT_C voidSetWhiteSpaceHandlingMode(TBool)
Private Member Functions
CMDXMLParser(MMDXMLParserObserver *)
CMDXMLParser(MMDXMLParserObserver *, MXMLDtd *)
voidAddTextL(CMDXMLElement *)
TBool CDataSectionL(CMDXMLElement *)
voidCheckForErrors()
TInt CheckForStartCData(const TDesC &)
TBool CommentL(CMDXMLElement *)
voidConstructL(MXMLDtd *)
voidCreateDocumentL()
TBool DetectFileType()
IMPORT_C voidDoCancel()
TBool DoParseLoopL()
TBool DocTypeL()
TBool EndOfCDataSection()
TInt FindDelimiter(TDesC &, TDesC &)
TGetCharReturn GetChar(TDes &)
TGetCharReturn GetDoubleByteChar(TDes &)
voidGetMoreData()
TGetCharReturn GetSingleByteChar(TDes &)
voidHandleTextL(TDes &)
TBool InCDataSection(TDesC &)
TInt LocateNextAttribute(const TDesC &)
voidPanic(TPanicCode)
TInt ParseElementAttributesL(CMDXMLElement &, TDes &)
TInt ParseElementEndTag(CMDXMLElement &, const TDesC &)
TInt ParseSingleAttributeL(TDes &)
CMDXMLElement *ParseStartTagL()
IMPORT_C voidPlaceholderForRemovedExport1(MMDXMLParserObserver *)
IMPORT_C voidPlaceholderForRemovedExport2(MMDXMLParserObserver *, MXMLDtd *)
IMPORT_C voidPlaceholderForRemovedExport3()
voidPrepareForReuseL()
TBool ProcessingInstructionL(CMDXMLElement *)
IMPORT_C TIntRunError(TInt)
voidRunL()
IMPORT_C voidSetError(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
enumTMDXMLParserInputCharWidth { EAscii = 0x01, EUnicode = 0x02 }
Private Member Enumerations
enumEParserStates {
KInitFromFile, KDetermineCharset, KWaitingForData, KParseData, KSpanDataGap, KFinished
}
enumTGetCharReturn { KError = 0x00, KCharReturned, KWaitForChar }
enumTPanicCode { 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 *)

voidAddTextL(CMDXMLElement *aParentElement)[private]

Parameters

CMDXMLElement * aParentElement

CDataSectionL(CMDXMLElement *)

TBool CDataSectionL(CMDXMLElement *aParentElement)[private]

Parameters

CMDXMLElement * aParentElement

CheckForErrors()

voidCheckForErrors()[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 *)

voidConstructL(MXMLDtd *aDtdRepresentation)[private]

Parameters

MXMLDtd * aDtdRepresentation

CreateDocumentL()

voidCreateDocumentL()[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 voidDoCancel()[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 TIntError()const

Gets the last error found by the parser.

ErrorSeverity()

IMPORT_C TXMLErrorCodeSeverityErrorSeverity()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()

voidGetMoreData()[private]

GetSingleByteChar(TDes &)

TGetCharReturn GetSingleByteChar(TDes &aChar)[private]

Parameters

TDes & aChar

HandleTextL(TDes &)

voidHandleTextL(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 & aTagToParsethe 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 * aParserObserverXML 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 * aParserObserverXML parser observer
MXMLDtd * aDtdRepresentationDTD 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 * aParserObserverXML 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 * aParserObserverXML parser observer
MXMLDtd * aDtdRepresentationDTD validator

Panic(TPanicCode)

voidPanic(TPanicCodeaReason)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 TIntParseFile(RFsaRFs,
const TDesC &aFileToParse
)

Parses a specified XML file into a DOM object tree.

Parameters

RFs aRFsFile server session
const TDesC & aFileToParseThe file name to parse

ParseFile(RFile &)

IMPORT_C TIntParseFile(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 & aFileHandleToParseAn 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 *)

voidParseSource(MMDXMLParserDataProvider *aSource)[inline]

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

Parameters

MMDXMLParserDataProvider * aSourceMMDXMLParserDataProvider pointer

ParseSourceL(MMDXMLParserDataProvider *)

IMPORT_C voidParseSourceL(MMDXMLParserDataProvider *aSource)

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

Parameters

MMDXMLParserDataProvider * aSourceMMDXMLParserDataProvider pointer

ParseStartTagL()

CMDXMLElement *ParseStartTagL()[private, virtual]

PlaceholderForRemovedExport1(MMDXMLParserObserver *)

IMPORT_C voidPlaceholderForRemovedExport1(MMDXMLParserObserver *aParserObserver)[private]

Parameters

MMDXMLParserObserver * aParserObserver

PlaceholderForRemovedExport2(MMDXMLParserObserver *, MXMLDtd *)

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

Parameters

MMDXMLParserObserver * aParserObserver
MXMLDtd * aDtdRepresentation

PlaceholderForRemovedExport3()

IMPORT_C voidPlaceholderForRemovedExport3()[private]

PrepareForReuseL()

voidPrepareForReuseL()[private]

ProcessingInstructionL(CMDXMLElement *)

TBool ProcessingInstructionL(CMDXMLElement *aParentElement)[private]

Parameters

CMDXMLElement * aParentElement

RunError(TInt)

IMPORT_C TIntRunError(TIntaError)[private, virtual]

Parameters

TInt aError

RunL()

voidRunL()[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 voidSetEntityConverter(CMDXMLEntityConverter *aEntityConverter)

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

Parameters

CMDXMLEntityConverter * aEntityConverterthe entity converter to be used.

SetError(const TInt, const TXMLErrorCodeSeverity)

IMPORT_C voidSetError(const TIntaErrorCode,
const TXMLErrorCodeSeverityaSeverity
)[private]

Parameters

const TInt aErrorCode
const TXMLErrorCodeSeverity aSeverity

SetSourceCharacterWidth(TMDXMLParserInputCharWidth)

IMPORT_C voidSetSourceCharacterWidth(TMDXMLParserInputCharWidthaWidth)

Sets the input stream character width.

Parameters

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

SetStoreInvalid(TBool)

IMPORT_C voidSetStoreInvalid(TBoolaStoreInvalid)

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

Parameters

TBool aStoreInvalidETrue if invalid content should be stored, EFalse otherwise.

SetWhiteSpaceHandlingMode(TBool)

IMPORT_C voidSetWhiteSpaceHandlingMode(TBoolaPreserve)

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

Parameters

TBool aPreserveETrue 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]