epoc32/include/xmllib.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    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.
       
    17 // USAGE:
       
    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
       
    21 // 
       
    22 //
       
    23 
       
    24 #ifndef __XMLLIB_H__
       
    25 #define __XMLLIB_H__
       
    26 
       
    27 // System includes
       
    28 //
       
    29 #include <e32base.h>
       
    30 #include <wapengstd.h>
       
    31 
       
    32 //	CONSTANT DEFINITIONS
       
    33 //
       
    34 
       
    35 /**
       
    36 ID for the root node attribute that contains the buffered document in case no DTD was available
       
    37 @publishedAll
       
    38 @deprecated
       
    39 */
       
    40 _LIT(KXmlLibBufferedDocumentAttribute, "XmlLibBufferedDocument");
       
    41 
       
    42 /**
       
    43 The Xml version that XML currently parser supports
       
    44 @publishedAll
       
    45 @deprecated
       
    46 */
       
    47 _LIT(KSupportedXmlVersion, "1.0");
       
    48 
       
    49 /**
       
    50 ID for node containing text data defined in a CDATA section (i.e. within <![CDATA[ .. ]]> )
       
    51 @publishedAll
       
    52 @deprecated
       
    53 */
       
    54 _LIT(KCDataID, "CDATA");
       
    55 
       
    56 /**
       
    57 ID for "normal" text nodes
       
    58 @publishedAll
       
    59 @deprecated
       
    60 */
       
    61 _LIT(KPCDataID, "#PCDATA");
       
    62 
       
    63 
       
    64 // Forward class declarations
       
    65 //
       
    66 class CXmlElement;
       
    67 class CXmlParser;
       
    68 class CBNFNode;
       
    69 class CAttributeLookupTable;
       
    70 class MWapPluginSP;
       
    71 
       
    72 //	CXmlLibrary
       
    73 //
       
    74 //##ModelId=3B6679A401C8
       
    75 class CXmlLibrary : public CBase
       
    76 /**
       
    77 @publishedAll
       
    78 @deprecated
       
    79 */
       
    80 	{
       
    81 public:	// Methods
       
    82 	// Default constuctor
       
    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);
       
    92 
       
    93 	//##ModelId=3B6679A40287
       
    94 	IMPORT_C virtual TInt ProcessDataL(TDesC8& aData);
       
    95 
       
    96 	// Xml Parse given data and generate document tree to the given root node.
       
    97 	// INPUT:
       
    98 	//	aData - document text, or a piece of it
       
    99 	// RETURN:
       
   100 	//	TInt - an error code defined above, KErrNone if no errors.
       
   101 	//##ModelId=3B6679A40291
       
   102 	IMPORT_C virtual TInt ProcessDataL(HBufC8& aData);
       
   103 
       
   104 	// Signal parser that incoming data stream has finished
       
   105 	// RETURN:
       
   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();
       
   113 
       
   114 	// Validate the document according to the given DTD.
       
   115 	// INPUT:
       
   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.
       
   121 	// RETURN:
       
   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);
       
   125 
       
   126 	// Set parser and library to its initial state to start parsing of a new document
       
   127 	// INPUT:
       
   128 	//	aRootNode - root node for the new document tree
       
   129 	//##ModelId=3B6679A4026B
       
   130 	IMPORT_C virtual void ResetL(CXmlElement* aRootNode);
       
   131 
       
   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; } ;
       
   140 	//
       
   141 	// -----------------------------------------------------------------------
       
   142 
       
   143 protected:
       
   144 	// A simple, internal utility function to setup the Xml parser
       
   145 	//##ModelId=3B6679A4026A
       
   146 	IMPORT_C void PrepareParserL();
       
   147 
       
   148 	//##ModelId=3B6679A40269
       
   149 	IMPORT_C void ConstructL();
       
   150 
       
   151 	// Default constructor
       
   152 	// SEE NOTES ON iMimeType, iDefaultDocType and iDefaultDTDUrl for inheriting class's constuctor
       
   153 	IMPORT_C CXmlLibrary(MWapPluginSP& aPluginSP, CXmlElement* aRootNode);
       
   154 
       
   155 	// Data parsing method for internal usage. Takes ownership of the given data
       
   156 	// INPUT:
       
   157 	// aData - Pointer to the UNICODE text data. Parser shall take ownership of this data!
       
   158 	// RETURN:
       
   159 	// TInt - Error code, KErrNone if no errors.
       
   160 	//##ModelId=3B6679A402A5
       
   161 	TInt ProcessDataL(HBufC16* aData);
       
   162 
       
   163 	// Internal utility function for finishing with the parser
       
   164 	// RETURN:
       
   165 	// TInt - Error code. KErrNone if no errors.
       
   166 	//##ModelId=3B6679A40260
       
   167 	TInt CommitParserL();
       
   168 
       
   169 	// Internal utility function for handling return values from parsing and initiating DTD fetch
       
   170 	// RETURN:
       
   171 	// TInt - Error code. KErrNone if no errors.
       
   172 	//##ModelId=3B6679A4025F
       
   173 	TInt ExecuteDataProcessingL();
       
   174 
       
   175 	//##ModelId=3B6679A40255
       
   176 	CBNFNode* ExtractDTDTree(CBNFNode* aDTDRoot);
       
   177 
       
   178 	// Internal validation function that actually performs the validation.
       
   179 	// INPUT:
       
   180 	// aDTDRootNode - Pointer to the _actual_ dtd tree root node, NOT the root given by angine
       
   181 	// OUTPUT:
       
   182 	// TInt - Error code, KErrNone if no errors
       
   183 	//##ModelId=3B6679A4024B
       
   184 	IMPORT_C virtual TInt ExecuteValidateL(CBNFNode* aDTDRootNode);
       
   185 
       
   186 protected:	// Attributes
       
   187 
       
   188 	/** Plugin Service Provider
       
   189 	 */
       
   190 	//##ModelId=3B6679A40239
       
   191 	MWapPluginSP&		iPluginSP;
       
   192 
       
   193 	/** Document Root Node
       
   194 	 */
       
   195 	//##ModelId=3B6679A40225
       
   196 	CXmlElement*		iRootNode;
       
   197 
       
   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;
       
   202 
       
   203 	//##ModelId=3B6679A40211
       
   204 	const TDesC*		iDefaultDTDUrl;
       
   205 
       
   206 	/** The actual DTD tree - not owned
       
   207 	 */
       
   208 	//##ModelId=3B6679A401FC
       
   209 	CBNFNode*			iDTD;
       
   210 
       
   211 private:	// Attributes
       
   212 
       
   213 	/** The XML parser
       
   214 	 */
       
   215 	//##ModelId=3B6679A401F2
       
   216 	CXmlParser*			iParser;
       
   217 
       
   218 private:	// BC-proofing
       
   219 
       
   220 /**
       
   221 	Intended Usage	:	Reserved for future use
       
   222 	@since			6.0
       
   223  */
       
   224 	//##ModelId=3B6679A40241
       
   225 	IMPORT_C virtual void CXmlLibrary_Reserved1();
       
   226 
       
   227 	/** Reserved for future use
       
   228 	 */
       
   229 	//##ModelId=3B6679A401E8
       
   230 	TAny*				iCXmlLibrary_Reserved;
       
   231 
       
   232 	};
       
   233 
       
   234 #endif // __XMLLIB_H__