1 // Copyright (c) 1999-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // CXmlLibrary is an interface class for a client to access the Xml parsing and validation
15 // services provided by the library. In general, CXmlLibrary should be concidered as a base
16 // class for a library which implements the language specific bits of an Xml-language parser.
18 // - Construction of the class using NewL or NewL
19 // - Pass data to parsing by calling ProcessDataL.
20 // - When all data has been parsed, call CommitL
30 #include <wapengstd.h>
32 // CONSTANT DEFINITIONS
36 ID for the root node attribute that contains the buffered document in case no DTD was available
40 _LIT(KXmlLibBufferedDocumentAttribute, "XmlLibBufferedDocument");
43 The Xml version that XML currently parser supports
47 _LIT(KSupportedXmlVersion, "1.0");
50 ID for node containing text data defined in a CDATA section (i.e. within <![CDATA[ .. ]]> )
54 _LIT(KCDataID, "CDATA");
57 ID for "normal" text nodes
61 _LIT(KPCDataID, "#PCDATA");
64 // Forward class declarations
69 class CAttributeLookupTable;
74 //##ModelId=3B6679A401C8
75 class CXmlLibrary : public CBase
83 // Sets default values values iMIMEType, iDefaultDoctype and iDefaultDTDUrl
84 // An inheriting class should override this constructor and set the variables
85 // with their correct values.
86 //##ModelId=3B6679A402CD
87 IMPORT_C virtual ~CXmlLibrary();
88 //##ModelId=3B6679A402BA
89 IMPORT_C static CXmlLibrary* NewL(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
90 //##ModelId=3B6679A402AF
91 IMPORT_C static CXmlLibrary* NewLC(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
93 //##ModelId=3B6679A40287
94 IMPORT_C virtual TInt ProcessDataL(TDesC8& aData);
96 // Xml Parse given data and generate document tree to the given root node.
98 // aData - document text, or a piece of it
100 // TInt - an error code defined above, KErrNone if no errors.
101 //##ModelId=3B6679A40291
102 IMPORT_C virtual TInt ProcessDataL(HBufC8& aData);
104 // Signal parser that incoming data stream has finished
106 // TInt - an error code defined above, KErrNone if no error occured.
107 // NOTE: In case no DTD was available, the document got buffered and was attached
108 // to an attribute in the root node and CommitL returns KErrDocumentBuffered.
109 // The buffered document will be re-parsed when engine receives the requested
110 // DTD and calls a data handler (defined by iMIMEType) for validation.
111 //##ModelId=3B6679A4027E
112 IMPORT_C virtual TInt CommitL();
114 // Validate the document according to the given DTD.
116 // aDTDRootNode - Root node to the DTD tree which defines the structure of the document.
117 // This referenced node is the DTD root node created by the engine.
118 // The actual DTD tree, if any, is attached as a child to this node.
119 // NO INHERITING CLASS SHOULD OVERRIDE THIS! Override the protected
120 // ValidateL instead.
122 // TInt - an error code defining the reason for validation failure. KErrNone if no errors.
123 //##ModelId=3B6679A40274
124 IMPORT_C virtual TInt ValidateL(CBNFNode& aDTDRootNode);
126 // Set parser and library to its initial state to start parsing of a new document
128 // aRootNode - root node for the new document tree
129 //##ModelId=3B6679A4026B
130 IMPORT_C virtual void ResetL(CXmlElement* aRootNode);
132 // -----------------------------------------------------------------------
133 // (WAP Push Addition)
134 // Wap Push specific method to switch off use of XML validator which doesn't work
135 // with push messages.
136 // iIgnoreValidator will be set on class construction to False with complies with
137 // current code usage; for push messages ONLY set iIgnoreValidator to True
138 // -----------------------------------------------------------------------
139 // inline void OmitValidator(TBool aIgnoreValidator) { iIgnoreValidator = aIgnoreValidator; } ;
141 // -----------------------------------------------------------------------
144 // A simple, internal utility function to setup the Xml parser
145 //##ModelId=3B6679A4026A
146 IMPORT_C void PrepareParserL();
148 //##ModelId=3B6679A40269
149 IMPORT_C void ConstructL();
151 // Default constructor
152 // SEE NOTES ON iMimeType, iDefaultDocType and iDefaultDTDUrl for inheriting class's constuctor
153 IMPORT_C CXmlLibrary(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
155 // Data parsing method for internal usage. Takes ownership of the given data
157 // aData - Pointer to the UNICODE text data. Parser shall take ownership of this data!
159 // TInt - Error code, KErrNone if no errors.
160 //##ModelId=3B6679A402A5
161 TInt ProcessDataL(HBufC16* aData);
163 // Internal utility function for finishing with the parser
165 // TInt - Error code. KErrNone if no errors.
166 //##ModelId=3B6679A40260
167 TInt CommitParserL();
169 // Internal utility function for handling return values from parsing and initiating DTD fetch
171 // TInt - Error code. KErrNone if no errors.
172 //##ModelId=3B6679A4025F
173 TInt ExecuteDataProcessingL();
175 //##ModelId=3B6679A40255
176 CBNFNode* ExtractDTDTree(CBNFNode* aDTDRoot);
178 // Internal validation function that actually performs the validation.
180 // aDTDRootNode - Pointer to the _actual_ dtd tree root node, NOT the root given by angine
182 // TInt - Error code, KErrNone if no errors
183 //##ModelId=3B6679A4024B
184 IMPORT_C virtual TInt ExecuteValidateL(CBNFNode* aDTDRootNode);
186 protected: // Attributes
188 /** Plugin Service Provider
190 //##ModelId=3B6679A40239
191 MWapPluginSP& iPluginSP;
193 /** Document Root Node
195 //##ModelId=3B6679A40225
196 CXmlElement* iRootNode;
198 // The default DTD doctype and Url in case no DTD was defined
199 // NOTE: Inheriting class should set these values in its constructor!!
200 //##ModelId=3B6679A4021B
201 const TDesC* iDefaultDoctype;
203 //##ModelId=3B6679A40211
204 const TDesC* iDefaultDTDUrl;
206 /** The actual DTD tree - not owned
208 //##ModelId=3B6679A401FC
211 private: // Attributes
215 //##ModelId=3B6679A401F2
218 private: // BC-proofing
221 Intended Usage : Reserved for future use
224 //##ModelId=3B6679A40241
225 IMPORT_C virtual void CXmlLibrary_Reserved1();
227 /** Reserved for future use
229 //##ModelId=3B6679A401E8
230 TAny* iCXmlLibrary_Reserved;
234 #endif // __XMLLIB_H__