xml/xmldomandxpath/src/xmlengineserializer/xmlengdomcontenthandler.h
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Content handler
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22  @released
       
    23 */
       
    24 #ifndef XMLENGSERIALIZER_CONTENTHANDLER_H
       
    25 #define XMLENGSERIALIZER_CONTENTHANDLER_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <xml/contenthandler.h>
       
    29 #include <xml/parser.h>
       
    30 #include <xml/dom/xmlengdom.h>
       
    31 
       
    32 #include <xml/dom/xmlengextendedcontenthandler.h>
       
    33 
       
    34 class RXmlEngDocument;
       
    35 class TXmlEngElement;
       
    36 
       
    37 using namespace Xml;
       
    38 
       
    39 class CXmlEngDOMContentHandler : public CBase, public MContentHandler, public MXmlEngExtendedHandler
       
    40 {
       
    41 
       
    42 public:
       
    43 	
       
    44 	static CXmlEngDOMContentHandler* NewL(RXmlEngDocument& aDoc);
       
    45 	
       
    46 	~CXmlEngDOMContentHandler();
       
    47 
       
    48 /**
       
    49 This method is a callback to indicate the start of the document.
       
    50 @param				aDocParam Specifies the various parameters of the document.
       
    51 @param				aDocParam.iCharacterSetName The character encoding of the document.
       
    52 @param				aErrorCode is the error code. 
       
    53 					If this is not KErrNone then special action may be required.
       
    54 */
       
    55 	void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
       
    56 
       
    57 
       
    58 /**
       
    59 This method is a callback to indicate the end of the document.
       
    60 @param				aErrorCode is the error code. 
       
    61 					If this is not KErrNone then special action may be required.
       
    62 */
       
    63 	void OnEndDocumentL(TInt aErrorCode);
       
    64 
       
    65 
       
    66 /**
       
    67 This method is a callback to indicate an element has been parsed.
       
    68 @param				aElement is a handle to the element's details.
       
    69 @param				aAttributes contains the attributes for the element.
       
    70 @param				aErrorCode is the error code.
       
    71 					If this is not KErrNone then special action may be required.
       
    72 */
       
    73 	void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, 
       
    74 								 TInt aErrorCode);
       
    75 
       
    76 	
       
    77 /**
       
    78 This method is a callback to indicate the end of the element has been reached.
       
    79 @param				aElement is a handle to the element's details.
       
    80 @param				aErrorCode is the error code.
       
    81 					If this is not KErrNone then special action may be required.
       
    82 */
       
    83 	void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
       
    84 
       
    85 
       
    86 /**
       
    87 This method is a callback that sends the content of the element.
       
    88 Not all the content may be returned in one go. The data may be sent in chunks.
       
    89 When an OnEndElementL is received this means there is no more content to be sent.
       
    90 @param				aBytes is the raw content data for the element. 
       
    91 					The client is responsible for converting the data to the 
       
    92 					required character set if necessary.
       
    93 					In some instances the content may be binary and must not be converted.
       
    94 @param				aErrorCode is the error code.
       
    95 					If this is not KErrNone then special action may be required.
       
    96 */
       
    97 	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
    98 
       
    99 	
       
   100 /**
       
   101 This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping.
       
   102 This method is always called before the corresponding OnStartElementL method.
       
   103 @param				aPrefix is the Namespace prefix being declared.
       
   104 @param				aUri is the Namespace URI the prefix is mapped to.
       
   105 @param				aErrorCode is the error code.
       
   106 					If this is not KErrNone then special action may be required.
       
   107 */
       
   108 	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, 
       
   109 									   TInt aErrorCode);
       
   110 
       
   111 
       
   112 /**
       
   113 This method is a notification of the end of the scope of a prefix-URI mapping.
       
   114 This method is called after the corresponding DoEndElementL method.
       
   115 @param				aPrefix is the Namespace prefix that was mapped.
       
   116 @param				aErrorCode is the error code.
       
   117 					If this is not KErrNone then special action may be required.
       
   118 */
       
   119 	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
   120 
       
   121 
       
   122 /**
       
   123 This method is a notification of ignorable whitespace in element content.
       
   124 @param				aBytes are the ignored bytes from the document being parsed.
       
   125 @param				aErrorCode is the error code.
       
   126 					If this is not KErrNone then special action may be required.
       
   127 */
       
   128 	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
   129 
       
   130 
       
   131 /**
       
   132 This method is a notification of a skipped entity. If the parser encounters an 
       
   133 external entity it does not need to expand it - it can return the entity as aName 
       
   134 for the client to deal with.
       
   135 @param				aName is the name of the skipped entity.
       
   136 @param				aErrorCode is the error code.
       
   137 					If this is not KErrNone then special action may be required.
       
   138 */
       
   139 	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
   140 
       
   141 
       
   142 /**
       
   143 This method is a receive notification of a processing instruction.
       
   144 @param				aTarget is the processing instruction target.
       
   145 @param				aData is the processing instruction data. If empty none was supplied.
       
   146 @param				aErrorCode is the error code.
       
   147 					If this is not KErrNone then special action may be required.
       
   148 */
       
   149 	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
       
   150 										  TInt aErrorCode);
       
   151 
       
   152 /**
       
   153  * This method is a callback that sends the binary content of the element.
       
   154  *
       
   155  * @param				aBytes is the raw binary data of the element 
       
   156  *						and must not be converted.
       
   157  * @param				aErrorCode is the error code. If this is not KErrNone
       
   158  *						then special action may be required.
       
   159  */
       
   160     void OnBinaryContentL(const TDesC8& aBytes,
       
   161                           const TDesC8& aCid,
       
   162                           TInt aErrorCode);
       
   163 	
       
   164 /**
       
   165  * This method is a callback that provides data container reference
       
   166  *
       
   167  * @param				aContainer Container encapsulating binary data
       
   168  * @param				aErrorCode is the error code. If this is not KErrNone
       
   169  *						then special action may be required.
       
   170  */	
       
   171 	void OnDataContainerL( const TXmlEngDataContainer& aContainer, 
       
   172 								   TInt aErrorCode);
       
   173 
       
   174 /**
       
   175 This method indicates an error has occurred.
       
   176 @param				aError is the error code
       
   177 */
       
   178 	void OnError(TInt aErrorCode);
       
   179 	
       
   180 	
       
   181 /**
       
   182 This method obtains the interface matching the specified uid.
       
   183 @return				0 if no interface matching the uid is found.
       
   184 					Otherwise, the this pointer cast to that interface.
       
   185 @param				aUid the uid identifying the required interface.
       
   186 */
       
   187 	TAny* GetExtendedInterface(const TInt32 aUid);
       
   188 	
       
   189 private:
       
   190 /**
       
   191 Constructor
       
   192 
       
   193 @param				aDeserializer Pointer to deserializer
       
   194 @param				aContentHandler Pointer to client content handler
       
   195 */
       
   196 	CXmlEngDOMContentHandler(RXmlEngDocument& aDoc);
       
   197 
       
   198 /**
       
   199    Renames TXmlEngElement nodes only.	(static helper method)
       
   200     
       
   201   @param aElement element to rename
       
   202   @param aLocalName New name
       
   203   @param aNamespaceUri New namespace uri
       
   204   @param aPrefix New namespace prefix
       
   205 */	
       
   206 	static void  RenameElementL(TXmlEngElement& aElement,
       
   207 			   const TDesC8& aLocalName, 
       
   208                                const TDesC8& aNamespaceUri, 
       
   209                                const TDesC8& aPrefix); 
       
   210 	
       
   211     /**
       
   212      * Changes name of the element so that Name() on it will return new name
       
   213      *
       
   214      * @param aElement element to change the name on
       
   215      * @param aName New name
       
   216      */	
       
   217 	static void  SetNameL(TXmlEngElement& aElement,
       
   218 			   const TDesC8& aName); 	
       
   219 private:
       
   220 	RXmlEngDocument& iDoc;
       
   221 	TXmlEngElement iTmpElement;
       
   222 	TXmlEngNode iLastElement;
       
   223 };
       
   224 
       
   225 #endif //XMLENGINE_SERIALIZER_CONTENTHANDLER_H