williamr@2: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // CXmlLibrary is an interface class for a client to access the Xml parsing and validation williamr@2: // services provided by the library. In general, CXmlLibrary should be concidered as a base williamr@2: // class for a library which implements the language specific bits of an Xml-language parser. williamr@2: // USAGE: williamr@2: // - Construction of the class using NewL or NewL williamr@2: // - Pass data to parsing by calling ProcessDataL. williamr@2: // - When all data has been parsed, call CommitL williamr@2: // williamr@2: // williamr@2: williamr@2: #ifndef __XMLLIB_H__ williamr@2: #define __XMLLIB_H__ williamr@2: williamr@2: // System includes williamr@2: // williamr@2: #include williamr@2: #include williamr@2: williamr@2: // CONSTANT DEFINITIONS williamr@2: // williamr@2: williamr@2: /** williamr@2: ID for the root node attribute that contains the buffered document in case no DTD was available williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: _LIT(KXmlLibBufferedDocumentAttribute, "XmlLibBufferedDocument"); williamr@2: williamr@2: /** williamr@2: The Xml version that XML currently parser supports williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: _LIT(KSupportedXmlVersion, "1.0"); williamr@2: williamr@2: /** williamr@2: ID for node containing text data defined in a CDATA section (i.e. within ) williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: _LIT(KCDataID, "CDATA"); williamr@2: williamr@2: /** williamr@2: ID for "normal" text nodes williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: _LIT(KPCDataID, "#PCDATA"); williamr@2: williamr@2: williamr@2: // Forward class declarations williamr@2: // williamr@2: class CXmlElement; williamr@2: class CXmlParser; williamr@2: class CBNFNode; williamr@2: class CAttributeLookupTable; williamr@2: class MWapPluginSP; williamr@2: williamr@2: // CXmlLibrary williamr@2: // williamr@2: //##ModelId=3B6679A401C8 williamr@2: class CXmlLibrary : public CBase williamr@2: /** williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: { williamr@2: public: // Methods williamr@2: // Default constuctor williamr@2: // Sets default values values iMIMEType, iDefaultDoctype and iDefaultDTDUrl williamr@2: // An inheriting class should override this constructor and set the variables williamr@2: // with their correct values. williamr@2: //##ModelId=3B6679A402CD williamr@2: IMPORT_C virtual ~CXmlLibrary(); williamr@2: //##ModelId=3B6679A402BA williamr@2: IMPORT_C static CXmlLibrary* NewL(MWapPluginSP& aPluginSP, CXmlElement* aRootNode); williamr@2: //##ModelId=3B6679A402AF williamr@2: IMPORT_C static CXmlLibrary* NewLC(MWapPluginSP& aPluginSP, CXmlElement* aRootNode); williamr@2: williamr@2: //##ModelId=3B6679A40287 williamr@2: IMPORT_C virtual TInt ProcessDataL(TDesC8& aData); williamr@2: williamr@2: // Xml Parse given data and generate document tree to the given root node. williamr@2: // INPUT: williamr@2: // aData - document text, or a piece of it williamr@2: // RETURN: williamr@2: // TInt - an error code defined above, KErrNone if no errors. williamr@2: //##ModelId=3B6679A40291 williamr@2: IMPORT_C virtual TInt ProcessDataL(HBufC8& aData); williamr@2: williamr@2: // Signal parser that incoming data stream has finished williamr@2: // RETURN: williamr@2: // TInt - an error code defined above, KErrNone if no error occured. williamr@2: // NOTE: In case no DTD was available, the document got buffered and was attached williamr@2: // to an attribute in the root node and CommitL returns KErrDocumentBuffered. williamr@2: // The buffered document will be re-parsed when engine receives the requested williamr@2: // DTD and calls a data handler (defined by iMIMEType) for validation. williamr@2: //##ModelId=3B6679A4027E williamr@2: IMPORT_C virtual TInt CommitL(); williamr@2: williamr@2: // Validate the document according to the given DTD. williamr@2: // INPUT: williamr@2: // aDTDRootNode - Root node to the DTD tree which defines the structure of the document. williamr@2: // This referenced node is the DTD root node created by the engine. williamr@2: // The actual DTD tree, if any, is attached as a child to this node. williamr@2: // NO INHERITING CLASS SHOULD OVERRIDE THIS! Override the protected williamr@2: // ValidateL instead. williamr@2: // RETURN: williamr@2: // TInt - an error code defining the reason for validation failure. KErrNone if no errors. williamr@2: //##ModelId=3B6679A40274 williamr@2: IMPORT_C virtual TInt ValidateL(CBNFNode& aDTDRootNode); williamr@2: williamr@2: // Set parser and library to its initial state to start parsing of a new document williamr@2: // INPUT: williamr@2: // aRootNode - root node for the new document tree williamr@2: //##ModelId=3B6679A4026B williamr@2: IMPORT_C virtual void ResetL(CXmlElement* aRootNode); williamr@2: williamr@2: // ----------------------------------------------------------------------- williamr@2: // (WAP Push Addition) williamr@2: // Wap Push specific method to switch off use of XML validator which doesn't work williamr@2: // with push messages. williamr@2: // iIgnoreValidator will be set on class construction to False with complies with williamr@2: // current code usage; for push messages ONLY set iIgnoreValidator to True williamr@2: // ----------------------------------------------------------------------- williamr@2: // inline void OmitValidator(TBool aIgnoreValidator) { iIgnoreValidator = aIgnoreValidator; } ; williamr@2: // williamr@2: // ----------------------------------------------------------------------- williamr@2: williamr@2: protected: williamr@2: // A simple, internal utility function to setup the Xml parser williamr@2: //##ModelId=3B6679A4026A williamr@2: IMPORT_C void PrepareParserL(); williamr@2: williamr@2: //##ModelId=3B6679A40269 williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: // Default constructor williamr@2: // SEE NOTES ON iMimeType, iDefaultDocType and iDefaultDTDUrl for inheriting class's constuctor williamr@2: IMPORT_C CXmlLibrary(MWapPluginSP& aPluginSP, CXmlElement* aRootNode); williamr@2: williamr@2: // Data parsing method for internal usage. Takes ownership of the given data williamr@2: // INPUT: williamr@2: // aData - Pointer to the UNICODE text data. Parser shall take ownership of this data! williamr@2: // RETURN: williamr@2: // TInt - Error code, KErrNone if no errors. williamr@2: //##ModelId=3B6679A402A5 williamr@2: TInt ProcessDataL(HBufC16* aData); williamr@2: williamr@2: // Internal utility function for finishing with the parser williamr@2: // RETURN: williamr@2: // TInt - Error code. KErrNone if no errors. williamr@2: //##ModelId=3B6679A40260 williamr@2: TInt CommitParserL(); williamr@2: williamr@2: // Internal utility function for handling return values from parsing and initiating DTD fetch williamr@2: // RETURN: williamr@2: // TInt - Error code. KErrNone if no errors. williamr@2: //##ModelId=3B6679A4025F williamr@2: TInt ExecuteDataProcessingL(); williamr@2: williamr@2: //##ModelId=3B6679A40255 williamr@2: CBNFNode* ExtractDTDTree(CBNFNode* aDTDRoot); williamr@2: williamr@2: // Internal validation function that actually performs the validation. williamr@2: // INPUT: williamr@2: // aDTDRootNode - Pointer to the _actual_ dtd tree root node, NOT the root given by angine williamr@2: // OUTPUT: williamr@2: // TInt - Error code, KErrNone if no errors williamr@2: //##ModelId=3B6679A4024B williamr@2: IMPORT_C virtual TInt ExecuteValidateL(CBNFNode* aDTDRootNode); williamr@2: williamr@2: protected: // Attributes williamr@2: williamr@2: /** Plugin Service Provider williamr@2: */ williamr@2: //##ModelId=3B6679A40239 williamr@2: MWapPluginSP& iPluginSP; williamr@2: williamr@2: /** Document Root Node williamr@2: */ williamr@2: //##ModelId=3B6679A40225 williamr@2: CXmlElement* iRootNode; williamr@2: williamr@2: // The default DTD doctype and Url in case no DTD was defined williamr@2: // NOTE: Inheriting class should set these values in its constructor!! williamr@2: //##ModelId=3B6679A4021B williamr@2: const TDesC* iDefaultDoctype; williamr@2: williamr@2: //##ModelId=3B6679A40211 williamr@2: const TDesC* iDefaultDTDUrl; williamr@2: williamr@2: /** The actual DTD tree - not owned williamr@2: */ williamr@2: //##ModelId=3B6679A401FC williamr@2: CBNFNode* iDTD; williamr@2: williamr@2: private: // Attributes williamr@2: williamr@2: /** The XML parser williamr@2: */ williamr@2: //##ModelId=3B6679A401F2 williamr@2: CXmlParser* iParser; williamr@2: williamr@2: private: // BC-proofing williamr@2: williamr@2: /** williamr@2: Intended Usage : Reserved for future use williamr@2: @since 6.0 williamr@2: */ williamr@2: //##ModelId=3B6679A40241 williamr@2: IMPORT_C virtual void CXmlLibrary_Reserved1(); williamr@2: williamr@2: /** Reserved for future use williamr@2: */ williamr@2: //##ModelId=3B6679A401E8 williamr@2: TAny* iCXmlLibrary_Reserved; williamr@2: williamr@2: }; williamr@2: williamr@2: #endif // __XMLLIB_H__