williamr@2
|
1 |
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@2
|
4 |
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@2
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
// CXmlLibrary is an interface class for a client to access the Xml parsing and validation
|
williamr@2
|
15 |
// services provided by the library. In general, CXmlLibrary should be concidered as a base
|
williamr@2
|
16 |
// class for a library which implements the language specific bits of an Xml-language parser.
|
williamr@2
|
17 |
// USAGE:
|
williamr@2
|
18 |
// - Construction of the class using NewL or NewL
|
williamr@2
|
19 |
// - Pass data to parsing by calling ProcessDataL.
|
williamr@2
|
20 |
// - When all data has been parsed, call CommitL
|
williamr@2
|
21 |
//
|
williamr@2
|
22 |
//
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#ifndef __XMLLIB_H__
|
williamr@2
|
25 |
#define __XMLLIB_H__
|
williamr@2
|
26 |
|
williamr@2
|
27 |
// System includes
|
williamr@2
|
28 |
//
|
williamr@2
|
29 |
#include <e32base.h>
|
williamr@2
|
30 |
#include <wapengstd.h>
|
williamr@2
|
31 |
|
williamr@2
|
32 |
// CONSTANT DEFINITIONS
|
williamr@2
|
33 |
//
|
williamr@2
|
34 |
|
williamr@2
|
35 |
/**
|
williamr@2
|
36 |
ID for the root node attribute that contains the buffered document in case no DTD was available
|
williamr@2
|
37 |
@publishedAll
|
williamr@2
|
38 |
@deprecated
|
williamr@2
|
39 |
*/
|
williamr@2
|
40 |
_LIT(KXmlLibBufferedDocumentAttribute, "XmlLibBufferedDocument");
|
williamr@2
|
41 |
|
williamr@2
|
42 |
/**
|
williamr@2
|
43 |
The Xml version that XML currently parser supports
|
williamr@2
|
44 |
@publishedAll
|
williamr@2
|
45 |
@deprecated
|
williamr@2
|
46 |
*/
|
williamr@2
|
47 |
_LIT(KSupportedXmlVersion, "1.0");
|
williamr@2
|
48 |
|
williamr@2
|
49 |
/**
|
williamr@2
|
50 |
ID for node containing text data defined in a CDATA section (i.e. within <![CDATA[ .. ]]> )
|
williamr@2
|
51 |
@publishedAll
|
williamr@2
|
52 |
@deprecated
|
williamr@2
|
53 |
*/
|
williamr@2
|
54 |
_LIT(KCDataID, "CDATA");
|
williamr@2
|
55 |
|
williamr@2
|
56 |
/**
|
williamr@2
|
57 |
ID for "normal" text nodes
|
williamr@2
|
58 |
@publishedAll
|
williamr@2
|
59 |
@deprecated
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
_LIT(KPCDataID, "#PCDATA");
|
williamr@2
|
62 |
|
williamr@2
|
63 |
|
williamr@2
|
64 |
// Forward class declarations
|
williamr@2
|
65 |
//
|
williamr@2
|
66 |
class CXmlElement;
|
williamr@2
|
67 |
class CXmlParser;
|
williamr@2
|
68 |
class CBNFNode;
|
williamr@2
|
69 |
class CAttributeLookupTable;
|
williamr@2
|
70 |
class MWapPluginSP;
|
williamr@2
|
71 |
|
williamr@2
|
72 |
// CXmlLibrary
|
williamr@2
|
73 |
//
|
williamr@2
|
74 |
//##ModelId=3B6679A401C8
|
williamr@2
|
75 |
class CXmlLibrary : public CBase
|
williamr@2
|
76 |
/**
|
williamr@2
|
77 |
@publishedAll
|
williamr@2
|
78 |
@deprecated
|
williamr@2
|
79 |
*/
|
williamr@2
|
80 |
{
|
williamr@2
|
81 |
public: // Methods
|
williamr@2
|
82 |
// Default constuctor
|
williamr@2
|
83 |
// Sets default values values iMIMEType, iDefaultDoctype and iDefaultDTDUrl
|
williamr@2
|
84 |
// An inheriting class should override this constructor and set the variables
|
williamr@2
|
85 |
// with their correct values.
|
williamr@2
|
86 |
//##ModelId=3B6679A402CD
|
williamr@2
|
87 |
IMPORT_C virtual ~CXmlLibrary();
|
williamr@2
|
88 |
//##ModelId=3B6679A402BA
|
williamr@2
|
89 |
IMPORT_C static CXmlLibrary* NewL(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
|
williamr@2
|
90 |
//##ModelId=3B6679A402AF
|
williamr@2
|
91 |
IMPORT_C static CXmlLibrary* NewLC(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
|
williamr@2
|
92 |
|
williamr@2
|
93 |
//##ModelId=3B6679A40287
|
williamr@2
|
94 |
IMPORT_C virtual TInt ProcessDataL(TDesC8& aData);
|
williamr@2
|
95 |
|
williamr@2
|
96 |
// Xml Parse given data and generate document tree to the given root node.
|
williamr@2
|
97 |
// INPUT:
|
williamr@2
|
98 |
// aData - document text, or a piece of it
|
williamr@2
|
99 |
// RETURN:
|
williamr@2
|
100 |
// TInt - an error code defined above, KErrNone if no errors.
|
williamr@2
|
101 |
//##ModelId=3B6679A40291
|
williamr@2
|
102 |
IMPORT_C virtual TInt ProcessDataL(HBufC8& aData);
|
williamr@2
|
103 |
|
williamr@2
|
104 |
// Signal parser that incoming data stream has finished
|
williamr@2
|
105 |
// RETURN:
|
williamr@2
|
106 |
// TInt - an error code defined above, KErrNone if no error occured.
|
williamr@2
|
107 |
// NOTE: In case no DTD was available, the document got buffered and was attached
|
williamr@2
|
108 |
// to an attribute in the root node and CommitL returns KErrDocumentBuffered.
|
williamr@2
|
109 |
// The buffered document will be re-parsed when engine receives the requested
|
williamr@2
|
110 |
// DTD and calls a data handler (defined by iMIMEType) for validation.
|
williamr@2
|
111 |
//##ModelId=3B6679A4027E
|
williamr@2
|
112 |
IMPORT_C virtual TInt CommitL();
|
williamr@2
|
113 |
|
williamr@2
|
114 |
// Validate the document according to the given DTD.
|
williamr@2
|
115 |
// INPUT:
|
williamr@2
|
116 |
// aDTDRootNode - Root node to the DTD tree which defines the structure of the document.
|
williamr@2
|
117 |
// This referenced node is the DTD root node created by the engine.
|
williamr@2
|
118 |
// The actual DTD tree, if any, is attached as a child to this node.
|
williamr@2
|
119 |
// NO INHERITING CLASS SHOULD OVERRIDE THIS! Override the protected
|
williamr@2
|
120 |
// ValidateL instead.
|
williamr@2
|
121 |
// RETURN:
|
williamr@2
|
122 |
// TInt - an error code defining the reason for validation failure. KErrNone if no errors.
|
williamr@2
|
123 |
//##ModelId=3B6679A40274
|
williamr@2
|
124 |
IMPORT_C virtual TInt ValidateL(CBNFNode& aDTDRootNode);
|
williamr@2
|
125 |
|
williamr@2
|
126 |
// Set parser and library to its initial state to start parsing of a new document
|
williamr@2
|
127 |
// INPUT:
|
williamr@2
|
128 |
// aRootNode - root node for the new document tree
|
williamr@2
|
129 |
//##ModelId=3B6679A4026B
|
williamr@2
|
130 |
IMPORT_C virtual void ResetL(CXmlElement* aRootNode);
|
williamr@2
|
131 |
|
williamr@2
|
132 |
// -----------------------------------------------------------------------
|
williamr@2
|
133 |
// (WAP Push Addition)
|
williamr@2
|
134 |
// Wap Push specific method to switch off use of XML validator which doesn't work
|
williamr@2
|
135 |
// with push messages.
|
williamr@2
|
136 |
// iIgnoreValidator will be set on class construction to False with complies with
|
williamr@2
|
137 |
// current code usage; for push messages ONLY set iIgnoreValidator to True
|
williamr@2
|
138 |
// -----------------------------------------------------------------------
|
williamr@2
|
139 |
// inline void OmitValidator(TBool aIgnoreValidator) { iIgnoreValidator = aIgnoreValidator; } ;
|
williamr@2
|
140 |
//
|
williamr@2
|
141 |
// -----------------------------------------------------------------------
|
williamr@2
|
142 |
|
williamr@2
|
143 |
protected:
|
williamr@2
|
144 |
// A simple, internal utility function to setup the Xml parser
|
williamr@2
|
145 |
//##ModelId=3B6679A4026A
|
williamr@2
|
146 |
IMPORT_C void PrepareParserL();
|
williamr@2
|
147 |
|
williamr@2
|
148 |
//##ModelId=3B6679A40269
|
williamr@2
|
149 |
IMPORT_C void ConstructL();
|
williamr@2
|
150 |
|
williamr@2
|
151 |
// Default constructor
|
williamr@2
|
152 |
// SEE NOTES ON iMimeType, iDefaultDocType and iDefaultDTDUrl for inheriting class's constuctor
|
williamr@2
|
153 |
IMPORT_C CXmlLibrary(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
|
williamr@2
|
154 |
|
williamr@2
|
155 |
// Data parsing method for internal usage. Takes ownership of the given data
|
williamr@2
|
156 |
// INPUT:
|
williamr@2
|
157 |
// aData - Pointer to the UNICODE text data. Parser shall take ownership of this data!
|
williamr@2
|
158 |
// RETURN:
|
williamr@2
|
159 |
// TInt - Error code, KErrNone if no errors.
|
williamr@2
|
160 |
//##ModelId=3B6679A402A5
|
williamr@2
|
161 |
TInt ProcessDataL(HBufC16* aData);
|
williamr@2
|
162 |
|
williamr@2
|
163 |
// Internal utility function for finishing with the parser
|
williamr@2
|
164 |
// RETURN:
|
williamr@2
|
165 |
// TInt - Error code. KErrNone if no errors.
|
williamr@2
|
166 |
//##ModelId=3B6679A40260
|
williamr@2
|
167 |
TInt CommitParserL();
|
williamr@2
|
168 |
|
williamr@2
|
169 |
// Internal utility function for handling return values from parsing and initiating DTD fetch
|
williamr@2
|
170 |
// RETURN:
|
williamr@2
|
171 |
// TInt - Error code. KErrNone if no errors.
|
williamr@2
|
172 |
//##ModelId=3B6679A4025F
|
williamr@2
|
173 |
TInt ExecuteDataProcessingL();
|
williamr@2
|
174 |
|
williamr@2
|
175 |
//##ModelId=3B6679A40255
|
williamr@2
|
176 |
CBNFNode* ExtractDTDTree(CBNFNode* aDTDRoot);
|
williamr@2
|
177 |
|
williamr@2
|
178 |
// Internal validation function that actually performs the validation.
|
williamr@2
|
179 |
// INPUT:
|
williamr@2
|
180 |
// aDTDRootNode - Pointer to the _actual_ dtd tree root node, NOT the root given by angine
|
williamr@2
|
181 |
// OUTPUT:
|
williamr@2
|
182 |
// TInt - Error code, KErrNone if no errors
|
williamr@2
|
183 |
//##ModelId=3B6679A4024B
|
williamr@2
|
184 |
IMPORT_C virtual TInt ExecuteValidateL(CBNFNode* aDTDRootNode);
|
williamr@2
|
185 |
|
williamr@2
|
186 |
protected: // Attributes
|
williamr@2
|
187 |
|
williamr@2
|
188 |
/** Plugin Service Provider
|
williamr@2
|
189 |
*/
|
williamr@2
|
190 |
//##ModelId=3B6679A40239
|
williamr@2
|
191 |
MWapPluginSP& iPluginSP;
|
williamr@2
|
192 |
|
williamr@2
|
193 |
/** Document Root Node
|
williamr@2
|
194 |
*/
|
williamr@2
|
195 |
//##ModelId=3B6679A40225
|
williamr@2
|
196 |
CXmlElement* iRootNode;
|
williamr@2
|
197 |
|
williamr@2
|
198 |
// The default DTD doctype and Url in case no DTD was defined
|
williamr@2
|
199 |
// NOTE: Inheriting class should set these values in its constructor!!
|
williamr@2
|
200 |
//##ModelId=3B6679A4021B
|
williamr@2
|
201 |
const TDesC* iDefaultDoctype;
|
williamr@2
|
202 |
|
williamr@2
|
203 |
//##ModelId=3B6679A40211
|
williamr@2
|
204 |
const TDesC* iDefaultDTDUrl;
|
williamr@2
|
205 |
|
williamr@2
|
206 |
/** The actual DTD tree - not owned
|
williamr@2
|
207 |
*/
|
williamr@2
|
208 |
//##ModelId=3B6679A401FC
|
williamr@2
|
209 |
CBNFNode* iDTD;
|
williamr@2
|
210 |
|
williamr@2
|
211 |
private: // Attributes
|
williamr@2
|
212 |
|
williamr@2
|
213 |
/** The XML parser
|
williamr@2
|
214 |
*/
|
williamr@2
|
215 |
//##ModelId=3B6679A401F2
|
williamr@2
|
216 |
CXmlParser* iParser;
|
williamr@2
|
217 |
|
williamr@2
|
218 |
private: // BC-proofing
|
williamr@2
|
219 |
|
williamr@2
|
220 |
/**
|
williamr@2
|
221 |
Intended Usage : Reserved for future use
|
williamr@2
|
222 |
@since 6.0
|
williamr@2
|
223 |
*/
|
williamr@2
|
224 |
//##ModelId=3B6679A40241
|
williamr@2
|
225 |
IMPORT_C virtual void CXmlLibrary_Reserved1();
|
williamr@2
|
226 |
|
williamr@2
|
227 |
/** Reserved for future use
|
williamr@2
|
228 |
*/
|
williamr@2
|
229 |
//##ModelId=3B6679A401E8
|
williamr@2
|
230 |
TAny* iCXmlLibrary_Reserved;
|
williamr@2
|
231 |
|
williamr@2
|
232 |
};
|
williamr@2
|
233 |
|
williamr@2
|
234 |
#endif // __XMLLIB_H__
|