xdmprotocols/XdmXmlParser/inc/XdmXmlContentHandler.h
branchRCL_3
changeset 35 fbd2e7cec7ef
parent 0 c8caa15ef882
equal deleted inserted replaced
34:2669f8761a99 35:fbd2e7cec7ef
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   CXdmXmlContentHandler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __XDMXMLCONTENTHANDLER__
       
    22 #define __XDMXMLCONTENTHANDLER__
       
    23 
       
    24 //INCLUDES
       
    25 #include <contenthandler.h>
       
    26 #include "XmlNodePathInterface.h"
       
    27 
       
    28 using namespace Xml;
       
    29 
       
    30 class CXdmDocument;
       
    31 class CXdmXmlParser;
       
    32 class MXdmNodeInterface;
       
    33 class CXmlParserNodePath;
       
    34 
       
    35 //CLASS DECLARATION
       
    36 class CXdmXmlContentHandler : public CBase,
       
    37                               public MContentHandler,
       
    38                               public MXmlNodePathInterface
       
    39     {
       
    40     public:  // Constructors and destructor
       
    41         
       
    42         /**
       
    43 		* Symbian OS Constructor
       
    44 		* @param CXdmXmlParser Reference to the main parser class
       
    45 		* @return CXdmXmlContentHandler A new content handler
       
    46 		*/
       
    47         static CXdmXmlContentHandler* NewL( CXdmXmlParser& aParserMain );
       
    48         
       
    49         /**
       
    50         * Destructor.
       
    51         */
       
    52         virtual ~CXdmXmlContentHandler();
       
    53 
       
    54     public: // New functions
       
    55 		
       
    56 	    /**
       
    57 		* Reset content handler
       
    58 		* @return void
       
    59 		*/
       
    60 		void Reset();
       
    61 		
       
    62 		/**
       
    63 		* Set the target document
       
    64 		* @param CXdmDocument& Reference to a document model
       
    65 		* @return void
       
    66 		*/
       
    67 		void SetTarget( const CXdmDocument& aTargetDocument );
       
    68 		
       
    69 		/**
       
    70 		* Set the target element
       
    71 		* @param CXdmDocumentNode Referene to document/fragment root
       
    72 		* @return void
       
    73 		*/
       
    74 		void SetTarget( const CXdmDocumentNode& aDocumentRoot );
       
    75 		
       
    76 	    /**
       
    77 		* Set the target document and element
       
    78 		* @param CXdmDocument Reference to a document model
       
    79 		* @param CXdmDocumentNode Referene to document/fragment root
       
    80 		* @return void
       
    81 		*/
       
    82 		void SetTargetL( const CXdmDocument& aTargetDocument,
       
    83 		                 const CXdmDocumentNode& aTargetNode );
       
    84 		                
       
    85     public: //From MXmlNodePathInterface
       
    86 		
       
    87 		/**
       
    88 		* Return the target attribute
       
    89 		* @return CXdmNodeAttribute* Target attribute
       
    90 		*/
       
    91 		CXdmNodeAttribute* TargetAttribute() const;
       
    92 
       
    93     private:
       
    94         
       
    95         /**
       
    96         * C++ Constructor
       
    97         * @param CXdmXmlParser Reference to the main parser class
       
    98         * @return CXdmXmlContentHandler
       
    99         */
       
   100 		CXdmXmlContentHandler( CXdmXmlParser& aParserMain );
       
   101 		
       
   102 		/**
       
   103         * Symbian OS second-phase constructor
       
   104         */
       
   105 		void ConstructL();
       
   106 		
       
   107     private:  //From Xml::MContentHandler
       
   108         
       
   109         /**
       
   110         * Get extended interface
       
   111         * @param TInt32 UID of the interface
       
   112         * @return TAny* a general pointer to the interface
       
   113         */
       
   114         TAny* GetExtendedInterface( const TInt32 aUid );
       
   115         
       
   116 		/**
       
   117         * Called on content: <elem>content</elem>
       
   118         * @param TDesC& Content bytes
       
   119         * @param TInt Error code
       
   120         * @return void
       
   121         */
       
   122 		void OnContentL( const TDesC8 &aBytes,
       
   123 		                 TInt aErrorCode );
       
   124 		
       
   125 		/**
       
   126         * Called on document end
       
   127         * @param TInt Error code
       
   128         * @return void
       
   129         */
       
   130         void OnEndDocumentL( TInt aErrorCode );
       
   131         
       
   132         /**
       
   133         * Called on element end
       
   134         * @param RTagInfo& Tag info
       
   135         * @param TInt Error code
       
   136         * @return void
       
   137         */
       
   138         void OnEndElementL( const RTagInfo& aElement,
       
   139                             TInt aErrorCode );
       
   140         
       
   141         /**
       
   142         * Called on prefix mapping end
       
   143         * @param RString& Prefix
       
   144         * @param TInt Error code
       
   145         * @return void
       
   146         */
       
   147         void OnEndPrefixMappingL( const RString &aPrefix,
       
   148                                   TInt aErrorCode );
       
   149         
       
   150         /**
       
   151         * Called on error
       
   152         * @param TInt Error code
       
   153         * @return void
       
   154         */
       
   155         void OnError( TInt aErrorCode );
       
   156     
       
   157         /**
       
   158         * Called on ingnorable whitespace
       
   159         * @param TDesC8& Whitespace bytes
       
   160         * @param TInt Error code
       
   161         * @return void
       
   162         */
       
   163         void OnIgnorableWhiteSpaceL( const TDesC8& aBytes,
       
   164                                      TInt aErrorCode );
       
   165    
       
   166         /**
       
   167         * Called on processing instructions
       
   168         * @param TDesC8& Target
       
   169         * @param TDesC8& Data
       
   170         * @param TInt Error code
       
   171         * @return void
       
   172         */
       
   173         void OnProcessingInstructionL( const TDesC8& aTarget,
       
   174                                        const TDesC8& aData,
       
   175                                        TInt aErrorCode );
       
   176     
       
   177         /**
       
   178         * Called on skipped entity
       
   179         * @param RString& Name of the entity
       
   180         * @param TInt Error code
       
   181         * @return void
       
   182         */
       
   183         void OnSkippedEntityL( const RString &aName,
       
   184                                TInt aErrorCode );
       
   185     
       
   186         /**
       
   187         * Called on document start
       
   188         * @param RDocumentParameters& Parameters
       
   189         * @param TInt Error code
       
   190         * @return void
       
   191         */
       
   192         void OnStartDocumentL( const RDocumentParameters& aDocParam,
       
   193                                TInt aErrorCode );
       
   194    
       
   195         /**
       
   196         * Called on element start
       
   197         * @param RTagInfo& The starting element
       
   198         * @param Xml::RAttributeArray Attributes
       
   199         * @param TInt Error code
       
   200         * @return void
       
   201         */
       
   202         void OnStartElementL( const RTagInfo& aElement,
       
   203                               const Xml::RAttributeArray &aAttributes,
       
   204                               TInt aErrorCode );
       
   205     
       
   206         /**
       
   207         * Called on prefix mapping start
       
   208         * @param RString& Prefix
       
   209         * @param RString& URI
       
   210         * @param TInt Error code
       
   211         * @return void
       
   212         */
       
   213         void OnStartPrefixMappingL( const RString& aPrefix,
       
   214                                     const RString& aUri,
       
   215                                     TInt aErrorCode );
       
   216                                     
       
   217     private:
       
   218         
       
   219         /**
       
   220         * Append attributes from the parameter array
       
   221         * @param Xml::RAttributeArray& Attributes
       
   222         * @return void
       
   223         */
       
   224         void AppendAttributeValueL( const Xml::RAttributeArray& aAttributes );
       
   225         
       
   226         /**
       
   227         * Handle next element
       
   228         * @param RTagInfo& The new element
       
   229         * @param Xml::RAttributeArray& Attributes
       
   230         * @return void
       
   231         */
       
   232         void HandleNextElementL( const Xml::RTagInfo& aElement,
       
   233                                  const Xml::RAttributeArray& aAttributes );
       
   234         /**
       
   235         * Is the parameter descriptor a whitespace
       
   236         * @param TDesC8& Bytes to check
       
   237         * @return TBool 
       
   238         */
       
   239         TBool IsWhiteSpace( const TDesC8& aBytes ) const;
       
   240         
       
   241         /**
       
   242         * Append a new namespace
       
   243         * @param TDesC8& Prefix
       
   244         * @param TDesC8& URI
       
   245         * @return void
       
   246         */
       
   247         void AppendNameSpaceL( const TDesC8& aPrefix, const TDesC8& aUri );
       
   248                                    
       
   249         /**
       
   250         * Set the namespace information to the current node
       
   251         * @param RTagInfo& Element
       
   252         * @param MXdmNodeInterface* Node interface
       
   253         * @return void
       
   254         */
       
   255         void SetNamespaceInformationL( const RTagInfo& aElement,
       
   256                                        MXdmNodeInterface* aXcapNode );
       
   257         
       
   258     private:    // Data
       
   259         
       
   260         TInt                             iContentIndex;
       
   261         TBool                            iFinished;
       
   262         TBool                            iIsRootNode;
       
   263         TBool                            iTargetFound;
       
   264         TXdmElementType                  iElementType;
       
   265         TBool                            iPartialDocument;
       
   266         CBufFlat*                        iContentBuffer;
       
   267         CXdmDocument*                    iTargetDocument;
       
   268         CXdmDocumentNode*                iRootNode;
       
   269         CXdmDocumentNode*                iDocumentSubset;
       
   270 		CXdmDocumentNode*                iCurrentNode;
       
   271 		CXdmNodeAttribute*               iTargetAttribute;
       
   272 		CXmlParserNodePath*              iNodePath;
       
   273 		CXdmXmlParser&                   iParserMain;
       
   274     };
       
   275 
       
   276 #endif      // __XDMXMLCONTENTHANDLER__
       
   277             
       
   278 // End of File