|
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 <xml/dom/xmlengdeserializer.h> |
|
28 #include <xml/documentparameters.h> |
|
29 #include <f32file.h> |
|
30 |
|
31 const TInt KShortInfoSize = 256; |
|
32 const TInt KLongInfoSize = 1000; |
|
33 |
|
34 using namespace Xml; |
|
35 |
|
36 class CXmlEngContentHandler : public CBase, public Xml::MContentHandler |
|
37 { |
|
38 |
|
39 public: |
|
40 |
|
41 static CXmlEngContentHandler* NewL( CXmlEngDeserializer* aDeserializer, |
|
42 MContentHandler* aContentHandler ); |
|
43 |
|
44 ~CXmlEngContentHandler(); |
|
45 |
|
46 /** |
|
47 This method is a callback to indicate the start of the document. |
|
48 @param aDocParam Specifies the various parameters of the document. |
|
49 @param aDocParam.iCharacterSetName The character encoding of the document. |
|
50 @param aErrorCode is the error code. |
|
51 If this is not KErrNone then special action may be required. |
|
52 */ |
|
53 void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
54 |
|
55 |
|
56 /** |
|
57 This method is a callback to indicate the end of the document. |
|
58 @param aErrorCode is the error code. |
|
59 If this is not KErrNone then special action may be required. |
|
60 */ |
|
61 void OnEndDocumentL(TInt aErrorCode); |
|
62 |
|
63 |
|
64 /** |
|
65 This method is a callback to indicate an element has been parsed. |
|
66 @param aElement is a handle to the element's details. |
|
67 @param aAttributes contains the attributes for the element. |
|
68 @param aErrorCode is the error code. |
|
69 If this is not KErrNone then special action may be required. |
|
70 */ |
|
71 void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, |
|
72 TInt aErrorCode); |
|
73 |
|
74 |
|
75 /** |
|
76 This method is a callback to indicate the end of the element has been reached. |
|
77 @param aElement is a handle to the element's details. |
|
78 @param aErrorCode is the error code. |
|
79 If this is not KErrNone then special action may be required. |
|
80 */ |
|
81 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
82 |
|
83 |
|
84 /** |
|
85 This method is a callback that sends the content of the element. |
|
86 Not all the content may be returned in one go. The data may be sent in chunks. |
|
87 When an OnEndElementL is received this means there is no more content to be sent. |
|
88 @param aBytes is the raw content data for the element. |
|
89 The client is responsible for converting the data to the |
|
90 required character set if necessary. |
|
91 In some instances the content may be binary and must not be converted. |
|
92 @param aErrorCode is the error code. |
|
93 If this is not KErrNone then special action may be required. |
|
94 */ |
|
95 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
96 |
|
97 |
|
98 /** |
|
99 This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping. |
|
100 This method is always called before the corresponding OnStartElementL method. |
|
101 @param aPrefix is the Namespace prefix being declared. |
|
102 @param aUri is the Namespace URI the prefix is mapped to. |
|
103 @param aErrorCode is the error code. |
|
104 If this is not KErrNone then special action may be required. |
|
105 */ |
|
106 void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, |
|
107 TInt aErrorCode); |
|
108 |
|
109 |
|
110 /** |
|
111 This method is a notification of the end of the scope of a prefix-URI mapping. |
|
112 This method is called after the corresponding DoEndElementL method. |
|
113 @param aPrefix is the Namespace prefix that was mapped. |
|
114 @param aErrorCode is the error code. |
|
115 If this is not KErrNone then special action may be required. |
|
116 */ |
|
117 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
118 |
|
119 |
|
120 /** |
|
121 This method is a notification of ignorable whitespace in element content. |
|
122 @param aBytes are the ignored bytes from the document being parsed. |
|
123 @param aErrorCode is the error code. |
|
124 If this is not KErrNone then special action may be required. |
|
125 */ |
|
126 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
127 |
|
128 |
|
129 /** |
|
130 This method is a notification of a skipped entity. If the parser encounters an |
|
131 external entity it does not need to expand it - it can return the entity as aName |
|
132 for the client to deal with. |
|
133 @param aName is the name of the skipped entity. |
|
134 @param aErrorCode is the error code. |
|
135 If this is not KErrNone then special action may be required. |
|
136 */ |
|
137 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
138 |
|
139 |
|
140 /** |
|
141 This method is a receive notification of a processing instruction. |
|
142 @param aTarget is the processing instruction target. |
|
143 @param aData is the processing instruction data. If empty none was supplied. |
|
144 @param aErrorCode is the error code. |
|
145 If this is not KErrNone then special action may be required. |
|
146 */ |
|
147 void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, |
|
148 TInt aErrorCode); |
|
149 |
|
150 |
|
151 /** |
|
152 This method indicates an error has occurred. |
|
153 @param aError is the error code |
|
154 */ |
|
155 void OnError(TInt aErrorCode); |
|
156 |
|
157 |
|
158 /** |
|
159 This method obtains the interface matching the specified uid. |
|
160 @return 0 if no interface matching the uid is found. |
|
161 Otherwise, the this pointer cast to that interface. |
|
162 @param aUid the uid identifying the required interface. |
|
163 */ |
|
164 TAny* GetExtendedInterface(const TInt32 aUid); |
|
165 |
|
166 private: |
|
167 /** |
|
168 Constructor |
|
169 |
|
170 @param aDeserializer Pointer to deserializer |
|
171 @param aContentHandler Pointer to client content handler |
|
172 */ |
|
173 CXmlEngContentHandler(CXmlEngDeserializer* aDeserializer, MContentHandler* aContentHandler); |
|
174 |
|
175 /** |
|
176 * 2nd phase constructor. |
|
177 */ |
|
178 void ConstructL(); |
|
179 |
|
180 /** |
|
181 This method strips CID string from "cid:" prefix to fetch the pure CID value |
|
182 @return CID value |
|
183 @param aCid CID string |
|
184 */ |
|
185 TPtrC8 CidValue(const TDesC8& aCid); |
|
186 |
|
187 /** |
|
188 This method converts element name to lower case and creates new tag info |
|
189 @return New tag info with lower case element name |
|
190 @param aTagInfo Original tag info |
|
191 */ |
|
192 RTagInfo ConvertNameToLowerCaseL(const RTagInfo& aElement); |
|
193 |
|
194 private: //data |
|
195 |
|
196 /** Handle to deserializer **/ |
|
197 CXmlEngDeserializer* iDeserializer; |
|
198 |
|
199 /** Handle to client's content handler **/ |
|
200 MContentHandler* iContentHandler; |
|
201 |
|
202 /** Indicates that xop:Include element is being processed **/ |
|
203 TUint iSkipIncludeElement; |
|
204 TBool iSkipPrefixMapping; |
|
205 |
|
206 /** Arrays for storing namespace mapping events **/ |
|
207 RPointerArray<HBufC8> iCachedPrefixes; |
|
208 RPointerArray<HBufC8> iCachedUris; |
|
209 RArray<TInt> iCachedErrors; |
|
210 |
|
211 /** Internal string pool */ |
|
212 RStringPool iStrPool; |
|
213 |
|
214 }; |
|
215 |
|
216 #endif //XMLENGINE_SERIALIZER_CONTENTHANDLER_H |