websrv_pub/xml_extensions_api/inc/SenBaseFragment.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:        Class implements basic functionality of an XML fragment
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef SEN_BASE_FRAGMENT_H
       
    26 #define SEN_BASE_FRAGMENT_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include <MSenContentHandlerClient.h>
       
    30 #include <SenElement.h>
       
    31 #include <SenFragment.h>
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // Fragment's internal states.
       
    36 const TInt KStateNotSet = -1;
       
    37 const TInt KStateIgnore =  0;
       
    38 const TInt KStateSave   =  1;
       
    39 const TInt KStateResume =  2;
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CSenXmlReader;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47 * Class implements basic functionality of an XML fragment
       
    48 * Typically BaseFragment is used to parse certain part of some XML document.
       
    49 * The element is identified by localname (or qualifiedname) and namespace.
       
    50 * All child elements between start tag and and end tag defined this fragment
       
    51 * will become content of this BaseFragment. In other words, BaseFragment has
       
    52 * all data inside a single element.
       
    53 * BaseFragment will parse only namespace (xmlns) attributes from a document
       
    54 * and rest of the attributes are to be handled by subclasses, which should
       
    55 * overwrite SetAttributesL() method to achieve this.
       
    56 * The CSenXmlReader class will do the actual parsing and this class will
       
    57 * act as content handler for XML parser SAX events.
       
    58 * @lib SenXML.dll
       
    59 * @since Series60 3.0
       
    60 */
       
    61 class CSenBaseFragment : public CSenFragment, public MSenContentHandlerClient 
       
    62     {
       
    63     public:  // Constructors and destructor
       
    64         
       
    65         /**
       
    66          *  Standard 2 phase constructor.
       
    67          *  @since Series60 3.0
       
    68          *  @param aElement is the element where construction 
       
    69          *                  data will be copied from.
       
    70          */
       
    71         IMPORT_C static CSenBaseFragment* NewL(const CSenElement& aElement);
       
    72 
       
    73         /**
       
    74          *  Standard 2 phase constructor.
       
    75          *  Leave codes:    
       
    76          *      KErrSenInvalidCharacters if aLocalName contains
       
    77          *      illegal characters.     
       
    78          *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
       
    79          *  @since Series60 3.0
       
    80          *  @param aLocalName: is the XML localname for this fragment
       
    81          */
       
    82         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aLocalName);
       
    83 
       
    84         /**
       
    85          *  Standard 2 phase constructor.
       
    86          *  Leave codes:    
       
    87          *      KErrSenInvalidCharacters if aLocalName contains
       
    88          *      illegal characters.     
       
    89          *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
       
    90          *  @since Series60 3.0
       
    91          *  @param aNsUri:  XML namespace URI
       
    92          *  @param aLocalName:  XML localname
       
    93          */
       
    94         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
       
    95                                                const TDesC8& aLocalName);
       
    96 
       
    97         /**
       
    98          *  Standard 2 phase constructor.
       
    99          *  Leave codes:    
       
   100          *      KErrSenInvalidCharacters if aLocalName or aQName contains
       
   101          *      illegal characters.     
       
   102          *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
       
   103          *  @since Series60 3.0
       
   104          *  @param aNsUri:  XML namespace URI
       
   105          *  @param aLocalName:  XML localname
       
   106          *  @param aQName:  XML qualifiedname
       
   107          */
       
   108         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
       
   109                                                const TDesC8& aLocalName,
       
   110                                                const TDesC8& aQName);
       
   111 
       
   112         /**
       
   113          * Standard 2 phase constructor.
       
   114          * Leave codes: 
       
   115          *      KErrSenInvalidCharacters if aLocalName or aQName contains
       
   116          *      illegal characters.     
       
   117          *      KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length.
       
   118          * @since Series60 3.0
       
   119          * @param aNsUri:   XML namespace URI
       
   120          * @param aLocalName:   XML localname
       
   121          * @param aQName:   XML qualifiedname
       
   122          * @param apAttrs:  XML attributes
       
   123          */
       
   124          IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
       
   125                                                 const TDesC8& aLocalName,
       
   126                                                 const TDesC8& aQName,
       
   127                                                 const RAttributeArray& apAttrs);
       
   128 
       
   129         /**
       
   130          *  Standard 2 phase constructor.
       
   131          *  @param aParent  Element to be set as fragment's parent element.
       
   132          *    Leave codes:  
       
   133          *          KErrSenInvalidCharacters if aLocalName or aQName contains
       
   134          *          illegal characters.     
       
   135          *          KErrSenZeroLengthDescriptor if aLocalName or aQName is of
       
   136          *      zero length.
       
   137          *  @since Series60 3.0
       
   138          *  @param aNsUri:  XML namespace URI
       
   139          *  @param aLocalName:  XML localname
       
   140          *  @param aQName:  XML qualifiedname
       
   141          *  @param apAttrs: XML attributes
       
   142          *  @param aParent: Parent element
       
   143          */
       
   144         IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri,
       
   145                                                const TDesC8& aLocalName,
       
   146                                                const TDesC8& aQName,
       
   147                                                const RAttributeArray& apAttrs,
       
   148                                                CSenElement& aParent);
       
   149 
       
   150         /**
       
   151          * Destructor.
       
   152          */
       
   153         IMPORT_C virtual ~CSenBaseFragment();
       
   154 
       
   155 
       
   156         // New functions
       
   157     
       
   158         /**
       
   159          * Getter for the content,which is returned as UTF-8 form XML.
       
   160          * @since Series60 3.0
       
   161          * @return content as UTF-8 form XML.
       
   162          */
       
   163         IMPORT_C virtual TPtrC8 Content();
       
   164         /**
       
   165          * Gets the namespace object with a given prefix.
       
   166          * @since Series60 3.0
       
   167          * @param   aPrefix:    prefix that wanted namespace should have.
       
   168          * @return namespace with the given prefix. If not found or given prefix
       
   169          * is zero length, will return NULL.
       
   170          */
       
   171         IMPORT_C virtual CSenNamespace* Namespace(const TDesC8& aPrefix);
       
   172         
       
   173         /**
       
   174          * @since Series60 3.0
       
   175          * @param aPrefix is the XML namespace prefix
       
   176          */
       
   177         IMPORT_C virtual void EnsureNamespace(const TDesC8& aPrefix);
       
   178         
       
   179         /**
       
   180          * @since Series60 3.0
       
   181          * @return Detaches this fragment from its owner. All namespace
       
   182          * references from possible parent fragments are declared in
       
   183          * the scope of this fragment prior detaching.
       
   184          */
       
   185         IMPORT_C virtual void DetachL();
       
   186         
       
   187         /**
       
   188          * @since Series60 3.0
       
   189          * @param aAttrs are the attributes from which the namespaces
       
   190          *        are searched from.
       
   191          * @param aEnsure if set to TRUE, the namespaces are copied into
       
   192          *         this fragment. If FALSE, then the namespaces are only
       
   193          *         referenced, but not copied and owned by this class.
       
   194          */
       
   195         IMPORT_C virtual void SaveNamespacesL(const RAttributeArray& aAttrs,
       
   196                                               TBool aEnsure);
       
   197 
       
   198         /**
       
   199          * Resets the content of the fragment, and resets the namespaces.
       
   200          * @since Series60 3.0
       
   201          */
       
   202         IMPORT_C virtual void ResetContentL();
       
   203 
       
   204         // Functions from base classes
       
   205 
       
   206         // From CSenFragment 
       
   207         
       
   208         /** 
       
   209          * @since Series60 3.0
       
   210          * @return the localname of this fragment as UTF-8 form descriptor
       
   211          */
       
   212         IMPORT_C virtual const TDesC8& LocalName() const;
       
   213         
       
   214         /**
       
   215          * Getter for Fragment's namespace URI..
       
   216          * @since Series60 3.0
       
   217          * @return Namespace URI or KNullDesC if not set.
       
   218          */
       
   219         IMPORT_C virtual const TDesC8& NsUri() const;
       
   220 
       
   221         /**
       
   222          * Getter for namespace prefix of this fragment.
       
   223          * @since Series60 3.0
       
   224          * @return namespace prefix or KNullDesC if not set.
       
   225          */
       
   226         IMPORT_C virtual const TDesC8& NsPrefix() const;    
       
   227 
       
   228         /**
       
   229          * Getting the fragment as an XML element. This method will panic if 
       
   230          * element has not been initialized for any reason.
       
   231          * @since Series60 3.0
       
   232          * @return the current object as element. Ownership is not transferred.
       
   233          */
       
   234         IMPORT_C virtual CSenElement& AsElement();
       
   235 
       
   236         /**
       
   237          * Etracts the XML element from the fragment, leaving the fragment empty.
       
   238          * Note(!): the return value (CSenElement) STRONGLY suggests that
       
   239          * subclasses INHERIT CSenFragment in order properly comply the
       
   240          * requirement of the ExtractElement() implementation.
       
   241          * @since Series60 3.0
       
   242          * @return the current object as element. May return NULL.
       
   243          * Ownership IS TRANSFERRED to the caller.
       
   244          */
       
   245         IMPORT_C virtual CSenElement* ExtractElement();
       
   246         
       
   247         /**
       
   248          * Gets the XML reader which this fragment uses for parsing.
       
   249          * @since Series60 3.0
       
   250          * @return the XML reader. Ownerships is not transferred,
       
   251          * due even this class does not own the XML reader instance.
       
   252          */
       
   253         IMPORT_C virtual CSenXmlReader* Reader();
       
   254 
       
   255         /**
       
   256          * Sets the XML reader to be used for parsing for the fragment.
       
   257          * @since Series60 3.0
       
   258          * @param aReader:      the reader to be used. 
       
   259          *                      Ownership is NOT transferred.
       
   260          */ 
       
   261         IMPORT_C virtual void SetReader(CSenXmlReader& aReader);
       
   262 
       
   263         /**
       
   264          *  Leave codes:    
       
   265          *  KErrSenXmlReaderNotSet  if XML reader has not been set.
       
   266          *  Method to invoke parsing of a XML data.
       
   267          *  Note that SetReader() must be called before this method can be used.
       
   268          *  Note that CSenBaseFragment does not parse any other
       
   269          *  attributes, but XML namespace attributes only. This
       
   270          *  is due to allow subclasses to process only those attributes
       
   271          *  they are interested in, and not others.
       
   272          *  @since Series60 3.0
       
   273          *  @param aXml:    The data to be parsed.
       
   274          */ 
       
   275         IMPORT_C virtual void ParseL(const TDesC8& aXml);
       
   276 
       
   277         /**
       
   278          * Same as ParseL() except that it doesn't leave in case of an error. 
       
   279          * Instead errors are trapped and error is returned.
       
   280          * SetReader() must be called before this method can be used.
       
   281          * @since Series60 3.0
       
   282          * @param aXml: The data to be parsed.
       
   283          * @return KErrNone or other system-wide Symbian error codes.
       
   284          */ 
       
   285         IMPORT_C virtual TInt BuildFrom(const TDesC8& aXml);
       
   286 
       
   287         /**
       
   288          * Leave codes: 
       
   289          * KErrSenXmlReaderNotSet   if XML reader has not been set.
       
   290          * Let the delegate MSenFragment handle the following SAX events.
       
   291          * This fragment is made the owner of the delegate and the delegate
       
   292          * is expected to make this MSenFragment the receiver of SAX events
       
   293          * once it has seen the end element for itself.
       
   294          * @since Series60 3.0
       
   295          * @param aDelegate is the fragment to start handling the SAX events.
       
   296          */
       
   297         IMPORT_C virtual void DelegateParsingL(MSenFragment& aDelegate);
       
   298 
       
   299         /**
       
   300          * Leave codes: 
       
   301          * KErrSenXmlReaderNotSet   if XML reader has not been set.
       
   302          * Creates a new fragment and lets the created MSenFragment handle the 
       
   303          * following SAX events. This fragment is made the owner of the delegate
       
   304          * and the delegate is expected to make this MSenFragment act as receiver
       
   305          * for SAX events (callbacks) once it has seen the end element for itself.
       
   306          * @since Series60 3.0
       
   307          * @param aNsUri    The XML namespace URI for the delegate to be created
       
   308          * @param aLocalName    The XML localname for the delegate to be created
       
   309          * @param aQName    The XML qualifiedname for the delegate to be created
       
   310          * @param aAttrs:   The XML attributes for the delegate to be created
       
   311          */
       
   312         IMPORT_C virtual void DelegateParsingL(const TDesC8& aNsUri,
       
   313                                                const TDesC8& aLocalName,
       
   314                                                const TDesC8& aQName,
       
   315                                                const RAttributeArray& aAttrs);
       
   316         
       
   317         /**
       
   318          * Sets the reader for this fragment and sets this to be the 
       
   319          * content handler of the following SAX events.
       
   320          * @since Series60 3.0
       
   321          * @param aReader is the XML parser to be used.
       
   322          */ 
       
   323         IMPORT_C virtual void ParseWithL(CSenXmlReader& aReader);
       
   324 
       
   325         /**
       
   326          * Sets a new parent for this fragment.
       
   327          * @since Series60 3.0
       
   328          * @param aFragment:    the new parent.
       
   329          */
       
   330         IMPORT_C virtual void SetOwner(MSenFragment& aFragment);
       
   331 
       
   332         /**
       
   333          * Leave codes: 
       
   334          * KErrSenXmlReaderNotSet   if XML reader has not been set.  Resumes 
       
   335          *     parsing to be handled by this fragment. Usually called by some
       
   336          *     delegate fragment which was set to be content handler because this
       
   337          *     fragment called DelegateParsingL().
       
   338          * @since Series60 3.0
       
   339          * @param aNsUri    The namespace URI of the current element
       
   340          * @param aLocalName    The local name of the current element
       
   341          * @param aQName    The qualified name of the current element
       
   342          */ 
       
   343         IMPORT_C virtual void ResumeParsingFromL(const TDesC8& aNsUri,
       
   344                                                  const TDesC8& aLocalName,
       
   345                                                  const TDesC8& aQName);
       
   346 
       
   347         /**
       
   348          * Sets the attributes for the fragment. BaseFragment parses only
       
   349          * namespace (xmlns) attributes from the document.
       
   350          * Subclasses should override this method if they are intrested
       
   351          * of handling any other XML attributes and their corresponding
       
   352          * values.
       
   353          * @since Series60 3.0
       
   354          * @param aAttrs:   the array of attributes.
       
   355          */
       
   356         IMPORT_C virtual void SetAttributesL(const RAttributeArray& aAttrs);
       
   357         
       
   358         /**
       
   359          * Writes the start element tag to the content stream. 
       
   360          * Derivants can override the basic usage used in BaseFragment.
       
   361          * @since Series60 3.0
       
   362          * @param aNsUri        The namespace URI of the current element
       
   363          * @param aLocalName        The local name of the current element
       
   364          * @param aQName        The qualified name of the current element
       
   365          * @param aAttrs        is the array of attributes.
       
   366          */
       
   367         IMPORT_C void WriteStartElementL(const TDesC8& aNsUri,
       
   368                                          const TDesC8& aLocalName,
       
   369                                          const TDesC8& aQName,
       
   370                                          const RAttributeArray& aAttrs);
       
   371         
       
   372         /**
       
   373          * Writes the end element tag to the content stream. 
       
   374          * Derivants can override the basic usage used in BaseFragment.
       
   375          * @since Series60 3.0
       
   376          * @param aNsUri        The namespace URI of the current element
       
   377          * @param aLocalName    The local name of the current element
       
   378          * @param aQName        The qualified name of the current element
       
   379          */
       
   380         IMPORT_C void WriteEndElementL(const TDesC8& aNsUri,
       
   381                                        const TDesC8& aLocalName,
       
   382                                        const TDesC8& aQName);
       
   383 
       
   384         /**
       
   385          * Gets the fragment data as an unicode XML.
       
   386          * @since Series60 3.0
       
   387          * @return  fragment as XML. Caller takes ownership.
       
   388          */ 
       
   389         IMPORT_C virtual HBufC* AsXmlUnicodeL();
       
   390 
       
   391         /**
       
   392          * Gets the fragment data as an UTF-8 form XML.
       
   393          * @since Series60 3.0
       
   394          * @return  fragment as XML. Caller takes ownership.
       
   395          */ 
       
   396         IMPORT_C virtual HBufC8* AsXmlL();
       
   397 
       
   398         /**
       
   399          * Invokes AsElement()->WriteAsXMLToL(aWs);
       
   400          * @since Series60 3.0
       
   401          * @param aWs is the stream into which the UTF-8 form XML will
       
   402          *            be written.
       
   403          */
       
   404         IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs);
       
   405 
       
   406         /**
       
   407          * Checks if fragment matches to another fragment 
       
   408          * by its content and child elements. 
       
   409          * Fragment can contain more data than the given candidate.
       
   410          * @since Series60 3.0
       
   411          * @param aCandidate    The pattern to be matched. Must contain same or 
       
   412          *                      less data for match to come true.
       
   413          * @return ETrue if content and possible children match exactly 
       
   414          *               to given pattern. EFalse otherwise.
       
   415          */
       
   416         IMPORT_C virtual TBool ConsistsOfL(MSenFragment& aCandidate);
       
   417 
       
   418     protected:  
       
   419         
       
   420         /**
       
   421         * C++ default constructor.
       
   422         */
       
   423         IMPORT_C CSenBaseFragment();        
       
   424         
       
   425         /**
       
   426          * Following BaseConstructL methods should be called from ConstructL() 
       
   427          * methods of some deriving (fragment) class.
       
   428          */
       
   429 
       
   430         /**
       
   431         * BaseConstructL, where an element is given as initializer.
       
   432         * @since Series60 3.0
       
   433         * @param aElement from which this fragment will be constructed from.
       
   434         */
       
   435         IMPORT_C void BaseConstructL(const CSenElement& aElement);
       
   436         
       
   437         /**
       
   438         * BaseConstructL setting XML localname for this fragment.
       
   439         * @since Series60 3.0
       
   440         * @param aLocalName XML localname for this fragment
       
   441         */
       
   442         IMPORT_C void BaseConstructL(const TDesC8& aLocalName);
       
   443 
       
   444         /**
       
   445         * BaseConstructL offering possibility to set XML namespace and localname.
       
   446         * @since Series60 3.0
       
   447         * @param aNsUri XML namespace URI for this fragment
       
   448         * @param aLocalName XML localname for this fragment
       
   449         */
       
   450         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
       
   451                                      const TDesC8& aLocalName);
       
   452 
       
   453         /**
       
   454         * Base constructor
       
   455         * @since Series60 3.0
       
   456         * @param aNsUri XML namespace URI for this fragment
       
   457         * @param aLocalName XML localname for this fragment
       
   458         * @param aQName XML qualifiedname for this fragment
       
   459         */
       
   460         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
       
   461                                      const TDesC8& aLocalName,
       
   462                                      const TDesC8& aQName);
       
   463         /**
       
   464         * Base constructor
       
   465         * @since Series60 3.0
       
   466         * @param aNsUri XML namespace URI for this fragment
       
   467         * @param aLocalName XML localname for this fragment
       
   468         * @param aQName XML qualifiedname for this fragment
       
   469         * @param aAttrs XML attributes for this fragment
       
   470         */
       
   471         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
       
   472                                      const TDesC8& aLocalName,
       
   473                                      const TDesC8& aQName,
       
   474                                      const RAttributeArray& aAttrs);
       
   475 
       
   476         /**
       
   477         * Base constructor
       
   478         * @since Series60 3.0
       
   479         * @param aNsUri XML namespace URI for this fragment
       
   480         * @param aLocalName XML localname for this fragment
       
   481         * @param aQName XML qualifiedname for this fragment
       
   482         * @param aAttrs XML attributes for this fragment
       
   483         * @param aParent parent to be set for this fragmemt
       
   484         */
       
   485         IMPORT_C void BaseConstructL(const TDesC8& aNsUri,
       
   486                                      const TDesC8& aLocalName,
       
   487                                      const TDesC8& aQName,
       
   488                                      const RAttributeArray& aAttrs,
       
   489                                      CSenElement& aParent);
       
   490 
       
   491         /**
       
   492         * BaseConstructL() setting the XML reader for this fragment
       
   493         * @since Series60 3.0
       
   494         * @param aReader is the XML reader for this fragment
       
   495         */
       
   496         IMPORT_C void BaseConstructL(CSenXmlReader& aReader);
       
   497         
       
   498         // New functions
       
   499          
       
   500         /**
       
   501         * Makes the content internal stream for content saving available.
       
   502         * @since Series60 3.0
       
   503         */
       
   504         IMPORT_C virtual void AllocContentSaverL();     
       
   505 
       
   506         /**
       
   507          * Callback function implementing the XML content handler interface.
       
   508          * Inheriting classes can override these.
       
   509          * @since Series60 3.0
       
   510          * @param aNsUri        The namespace URI of the new element
       
   511          * @param aLocalName    The local name of the new element
       
   512          * @param aQName        The qualified name of the new element
       
   513          * @param aAttrs        The attributes of the new element
       
   514          */
       
   515         IMPORT_C virtual void StartElementL(const TDesC8& aNsUri,
       
   516                                             const TDesC8& aLocalName,
       
   517                                             const TDesC8& aQName,
       
   518                                             const RAttributeArray& aAttrs);
       
   519 
       
   520         /**
       
   521         * Callback function which implement the XML content handler interface.
       
   522         * Inheriting classes can override these.
       
   523         * @since Series60 3.0
       
   524         * @param aNsUri     The namespace URI of the new element
       
   525         * @param aLocalName     The local name of the new element
       
   526         * @param aQName     The qualified name of the new element
       
   527         */
       
   528         IMPORT_C virtual void EndElementL(const TDesC8& aNsUri,
       
   529                                           const TDesC8& aLocalName,
       
   530                                           const TDesC8& aQName);
       
   531 
       
   532         /**
       
   533         * Function which implement the XML content handler interface.
       
   534         * Inheriting classes can override these.
       
   535         * This one is called when content is starting.
       
   536         * @since Series60 3.0
       
   537         * @param aChars     The content characters.
       
   538         * @param aStart     The starting index
       
   539         * @param aLength        The length of the characters.
       
   540         */
       
   541         IMPORT_C virtual void CharactersL(const TDesC8& aChars,
       
   542                                           TInt aStart,
       
   543                                           TInt aLength);
       
   544 
       
   545         /**
       
   546         *  Callback function which implement the XML content handler interface.
       
   547         *  Inheriting classes can override these. Note that overrides should
       
   548         *  return TRUE (1) on success and FALSE (0) on failure to parser.
       
   549         *
       
   550         *  @since Series60 3.0
       
   551         *  @param aName     The entity name
       
   552         *
       
   553         */
       
   554         IMPORT_C TInt StartEntity(TDesC8& aName);
       
   555 
       
   556         /**
       
   557          * Sets content to a child element. If no element with given local name
       
   558          * is not found, new one is added and content is set to that one.
       
   559          * @since Series60 3.0
       
   560          * @param aLocalName    The local name of element which content
       
   561          *                      is about to be set
       
   562          * @param aContent      Content to be set.
       
   563          * @return              the element where content was set.
       
   564          * Leave codes: 
       
   565          *      KErrSenInvalidCharacters if aLocalName contains illegal characters.     
       
   566          *      KErrSenZeroLengthDescriptor if aLocalName is zero length.
       
   567          */
       
   568         IMPORT_C MSenElement& SetContentOfL(const TDesC8& aLocalName,
       
   569                                             const TDesC8& aContent);
       
   570         /**
       
   571          * Gets the content of a given element.
       
   572          * @since Series60 3.0
       
   573          * @param aLocalName    The local name of the element which content is 
       
   574          *                      asked
       
   575          * @return  the content which was asked
       
   576          */
       
   577         IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName);        
       
   578 
       
   579     private: // New functions
       
   580         
       
   581         /**
       
   582          * Leaving variant which is then trapped in the non-leaving function.
       
   583          */
       
   584         TPtrC8 ContentL();
       
   585     
       
   586         // Functions from base classes
       
   587 
       
   588         // From MSenContentHandlerClient
       
   589         
       
   590         IMPORT_C virtual TInt StartDocument();
       
   591         IMPORT_C virtual TInt EndDocument();
       
   592         IMPORT_C virtual TInt StartElement(const TDesC8& aNsUri,
       
   593                                            const TDesC8& aLocalName,
       
   594                                            const TDesC8& aQName,
       
   595                                            const RAttributeArray& aAttrs);
       
   596         
       
   597         IMPORT_C virtual TInt EndElement(const TDesC8& aNsUri,
       
   598                                          const TDesC8& aLocalName,
       
   599                                          const TDesC8& aQName);
       
   600 
       
   601         IMPORT_C virtual TInt Characters(const TDesC8& aChars,
       
   602                                          const TInt aStart,
       
   603                                          const TInt aLength);
       
   604 
       
   605         IMPORT_C virtual TInt Error(TInt aErrorCode);
       
   606 
       
   607         //IMPORT_C TInt StartEntityL(const TDesC8& aName);
       
   608 
       
   609 
       
   610     protected: // Data
       
   611 
       
   612         // State variable indicating what this fragment
       
   613         // is currently parsing. Even states (like 0)
       
   614         // mean that this fragment is ignoring the
       
   615         // data, and odd states indicate, that fragment
       
   616         // is storing the data into itself.
       
   617         TInt iState;
       
   618         // Owned element containing this XML fragment data.
       
   619         CSenElement* ipElement;
       
   620         // Pointer to XML parser. Not owned.
       
   621         CSenXmlReader* iXmlReader;      
       
   622         // Possible owner fragment, if such exists. Not owned.
       
   623         MSenFragment* ipOwner;
       
   624         // Internal write stream, into which UTF-8 form XML is stored
       
   625         RWriteStream iWs;
       
   626 
       
   627     private: // Data
       
   628          
       
   629         // Owned pointer to delegate fragment
       
   630         CSenFragment* ipDelegate;
       
   631         // Not owned. Holds namespaces that are referred to from 
       
   632         // within the content but were not declared within this 
       
   633         // BaseFragment.
       
   634         RPointerArray<CSenNamespace> iNamespaces;
       
   635         // Owned. Holds prefixes that have been declared within the 
       
   636         // scope of this BaseFragment
       
   637         RPointerArray<HBufC8> iPrefixes;
       
   638         // Actual flat buffer to content which includes namespaces.
       
   639         CBufFlat* ipContentWithNamespaces;
       
   640         // Indicating that content writing stream is initialized.
       
   641         TBool hasContentWriteStream;
       
   642         // Indicates whether or not ipElement member is an owned
       
   643         TBool iElementOwned;
       
   644     };
       
   645 
       
   646 #endif //SEN_BASE_FRAGMENT_H
       
   647 
       
   648 // End of File
       
   649 
       
   650 
       
   651