diff -r 48780e181b38 -r 578be2adaf3e Symbian3/PDK/Source/GUID-23014C8A-2A0B-5F6A-9BB2-6642E1EC0462.dita --- a/Symbian3/PDK/Source/GUID-23014C8A-2A0B-5F6A-9BB2-6642E1EC0462.dita Tue Jul 20 12:00:49 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-23014C8A-2A0B-5F6A-9BB2-6642E1EC0462.dita Fri Aug 13 16:47:46 2010 +0100 @@ -1,61 +1,61 @@ - - - - - -Using -Content Processor -

This section explains how to implement the MContentProcessor interface -to parse, validate and autocorrect an XML document.

-
Introduction

The parsed document can also be validated -against a specification and auto-corrected for spelling errors in the validated -text. This can be done by writing three applications - a parser, a validator -and an autocorrector. These applications must implement the MContentProcessor interface.

Writing -a content processor is similar to writing a content handler as explained in Parsing an XML Document. MContentProcessor is -an extension of MContentHandler. Each application is writen -by implementing the callback functions of MContentHandler. -The only difference is that MContentProcessor has a mechanism -for directing output, so that the output of the parser is the input to the -validator, and the output of the validator is the input to the autocorrector.

Direct -output of a content processor by implementing the SetContentSink() function, -so that the parser outputs to the validator and the validator outputs to the -autocorrector. A sequence of several applications linked in this way is called -a Plug-in Chain.

-
Procedure
    -
  1. Implement the MContentProcessor interface.

  2. -
  3. Implement the MContentProcessor::SetContentSink() function.

  4. -
  5. Perform the actual parsing.

    Use -a CParser object as explained in Choosing -a Parser Plug-in. To ensure that parsing is followed by validation -and autocorrection, associate the CParser object with the -plug-in chain. This can be done by calling SetProcessorChainL() function -of the CParser object with a list of the items in the plugin -chain as a parameter.

    The following code illustrates how to validate -and autocorrect the parsed document:

    RFs fs; -User::LeaveIfError( fs.Connect() ); -CleanupClosePushL( fs ); - -_LIT8( KXmlMimeType, "text/xml" ); -TSimpleContentHandler sax; // You’ll have to implement this class… - -CParser* parser = CParser::NewLC( KXmlMimeType, sax ); - -RContentProcessorUids uids; -uids.Append( KValidatorUid ); // The ECOM implementation UID of a validator plug-in -CleanupClosePushL( uids ); - -// Sets up the chain of call-back events from the parser through to the -// validating plug-in and then the client. -parser->SetProcessorChainL( uids ); - -parser->ParseFileL( fs, KMyFile ); - -CleanupStack::PopAndDestroy( 3 );
  6. -
+ + + + + +Using +Content Processor +

This section explains how to implement the MContentProcessor interface +to parse, validate and autocorrect an XML document.

+
Introduction

The parsed document can also be validated +against a specification and auto-corrected for spelling errors in the validated +text. This can be done by writing three applications - a parser, a validator +and an autocorrector. These applications must implement the MContentProcessor interface.

Writing +a content processor is similar to writing a content handler as explained in Parsing an XML Document. MContentProcessor is +an extension of MContentHandler. Each application is writen +by implementing the callback functions of MContentHandler. +The only difference is that MContentProcessor has a mechanism +for directing output, so that the output of the parser is the input to the +validator, and the output of the validator is the input to the autocorrector.

Direct +output of a content processor by implementing the SetContentSink() function, +so that the parser outputs to the validator and the validator outputs to the +autocorrector. A sequence of several applications linked in this way is called +a Plug-in Chain.

+
Procedure
    +
  1. Implement the MContentProcessor interface.

  2. +
  3. Implement the MContentProcessor::SetContentSink() function.

  4. +
  5. Perform the actual parsing.

    Use +a CParser object as explained in Choosing +a Parser Plug-in. To ensure that parsing is followed by validation +and autocorrection, associate the CParser object with the +plug-in chain. This can be done by calling SetProcessorChainL() function +of the CParser object with a list of the items in the plugin +chain as a parameter.

    The following code illustrates how to validate +and autocorrect the parsed document:

    RFs fs; +User::LeaveIfError( fs.Connect() ); +CleanupClosePushL( fs ); + +_LIT8( KXmlMimeType, "text/xml" ); +TSimpleContentHandler sax; // You’ll have to implement this class… + +CParser* parser = CParser::NewLC( KXmlMimeType, sax ); + +RContentProcessorUids uids; +uids.Append( KValidatorUid ); // The ECOM implementation UID of a validator plug-in +CleanupClosePushL( uids ); + +// Sets up the chain of call-back events from the parser through to the +// validating plug-in and then the client. +parser->SetProcessorChainL( uids ); + +parser->ParseFileL( fs, KMyFile ); + +CleanupStack::PopAndDestroy( 3 );
  6. +
\ No newline at end of file