williamr@2: /* williamr@2: * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: This abstract class defines the interface for WSF XML williamr@2: * fragment classes. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef M_SEN_FRAGMENT_H williamr@2: #define M_SEN_FRAGMENT_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@4: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CSenElement; williamr@2: williamr@2: using namespace Xml; williamr@2: williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * This abstract class defines the interface for XML fragment classes. williamr@2: * The subclasses are used to extract certain part of XML document into williamr@2: * a separate XML subtree, called fragment. This M-class is typically used williamr@2: * when a safe reference to some actual implementation is required. williamr@2: * Fragment classes are content handlers for SAX callback events received williamr@2: * from CSenXmlReader class. They typically inherit MSenContentHandlerClient williamr@2: * to achive this. williamr@2: * @lib SenXML.dll williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: class MSenFragment williamr@2: { williamr@2: public: // New functions williamr@2: /** williamr@2: * Getting the fragment as an XML element. This method will panic if williamr@2: * element has not been initialized (EFragmentElementNotInitialized). williamr@2: * @since Series60 3.0 williamr@2: * @return the current object as element. Ownership is not transferred. williamr@2: */ williamr@2: virtual CSenElement& AsElement() = 0; williamr@2: williamr@2: /** williamr@2: * Method extracts the root element (whole data) from this fragment. williamr@2: * After calling this method, the fragment does not have any williamr@2: * internal element. Method is often called before fragment is williamr@2: * destroyed, in order to fetch its content and transfer ownership williamr@2: * to that content to some other object. williamr@2: * @since Series60 3.0 williamr@2: * @return the current object as element. May return NULL. williamr@2: * Ownership is transferred to the caller. williamr@2: */ williamr@2: virtual CSenElement* ExtractElement() = 0; williamr@2: williamr@2: /** williamr@2: * Sets the XML reader to be used for parsing for the fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aReader: the reader to be used. williamr@2: * Ownership is NOT transferred. williamr@2: */ williamr@2: virtual void SetReader(CSenXmlReader& aReader) = 0; williamr@2: williamr@2: /** williamr@2: * Gets the XML reader which this fragment uses for parsing. williamr@2: * @since Series60 3.0 williamr@2: * @param aReader: the reader to be used. williamr@2: * Ownerships is not transferred. williamr@2: * May return NULL. williamr@2: */ williamr@2: virtual CSenXmlReader* Reader() = 0; williamr@2: williamr@2: /** williamr@2: * Method to invoke parsing of a UTF-8 form XML data. williamr@2: * Note that SetReader() must be called before this williamr@2: * method can be used. williamr@2: * Parsing is dependent of preset localname or qualifiedname williamr@2: * and possible namespace for this fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aBuf: The XML to be parsed. williamr@2: */ williamr@2: virtual void ParseL(const TDesC8& aBuf) = 0; williamr@2: williamr@2: /** williamr@2: * Same as ParseL() except that it doesn't leave in case of an error. williamr@2: * Instead errors are trapped and error is returned. williamr@2: * SetReader() must be called before this method can be used. williamr@2: * @since Series60 3.0 williamr@2: * @param aBuf: The XML to be parsed. williamr@2: * @return KErrNone or other system-wide Symbian error codes williamr@2: */ williamr@2: virtual TInt BuildFrom(const TDesC8& aBuf) = 0; williamr@2: williamr@2: /** williamr@2: * Let the delegate MSenFragment handle the following SAX events. williamr@2: * This fragment is made the owner of the delegate and the delegate williamr@2: * is expected to make this MSenFragment the receiver of SAX events williamr@2: * once it has seen the end element for itself. This is achieved by williamr@2: * ResumeParsingFromL(), which delegate will call from his parent. williamr@2: * The currently set XML reader is used to parse XML for the delagate, williamr@2: * too. williamr@2: * @since Series60 3.0 williamr@2: * @param aDelegate: the fragment to start handling the SAX events. williamr@2: */ williamr@2: virtual void DelegateParsingL(MSenFragment& aDelegate) = 0; williamr@2: williamr@2: /** williamr@2: * Creates a new delegate (fragment) using the given arguments williamr@2: * and lets it handle the SAX events according williamr@2: * to given localname (or qualifiedname) and possible namespace. williamr@2: * This instance is made the owner of the delegate and the delegate williamr@2: * is expected to resume parsing to this MSenFragment after it has williamr@2: * finished handling the dedicated part of XML document in question. williamr@2: * at the EndElementL(). williamr@2: * The currently set XML reader is used to parse XML for the delagate, williamr@2: * too. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri: the namespace URI of the new delegate williamr@2: * @param aLocalName: the local name of the new delegate williamr@2: * @param aQName: the qualified name of the new delegate williamr@2: * @param aAttrs: the attributes which to be set for the new delegate williamr@2: */ williamr@2: virtual void DelegateParsingL( const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs) = 0; williamr@2: williamr@2: /** williamr@2: * Method sets the reader for this fragment and sets this to be the williamr@2: * content handler for the SAX events according to preset localname williamr@2: * (or qualifiedname) and possible namespace. williamr@2: * @since Series60 3.0 williamr@2: * @param aReader: Reader to be used. williamr@2: */ williamr@2: virtual void ParseWithL(CSenXmlReader& aReader) = 0; williamr@2: williamr@2: /** williamr@2: * Sets a new owner (parent) for this fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aFragment: the new parent. williamr@2: */ williamr@2: virtual void SetOwner(MSenFragment& aFragment) = 0; williamr@2: williamr@2: /** williamr@2: * Resumes the parsing. Usually called by some delegate williamr@2: * fragment which was parsing itself through DelegateParsingL() williamr@2: * call from this instance. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri The namespace URI of the current element williamr@2: * @param aLocalName The local name of the current element williamr@2: * @param aQName The qualified name of the current element williamr@2: */ williamr@2: virtual void ResumeParsingFromL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName) = 0; williamr@2: williamr@2: /** williamr@2: * Sets the attributes for the fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aAttrs: the array of attributes. williamr@2: */ williamr@2: virtual void SetAttributesL(const RAttributeArray& aAttrs) = 0; williamr@2: williamr@2: /** williamr@2: * Writes the start element tag to the content stream. williamr@2: * Subclasses typically override this. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri The namespace URI of the current element williamr@2: * @param aLocalName The local name of the current element williamr@2: * @param aQName The qualified name of the current element williamr@2: * @param aAttrs: the array of attributes. williamr@2: */ williamr@2: virtual void WriteStartElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs) = 0; williamr@2: williamr@2: /** williamr@2: * Writes the end element tag to the content stream. williamr@2: * Subclasses typically override this williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri The namespace URI of the current element williamr@2: * @param aLocalName The local name of the current element williamr@2: * @param aQName The qualified name of the current element williamr@2: */ williamr@2: virtual void WriteEndElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName) = 0; williamr@2: williamr@2: /** williamr@2: * Getter for fragment XML local name. williamr@2: * @since Series60 3.0 williamr@2: * @return localname or KNullDesC8 if not set. williamr@2: */ williamr@2: virtual const TDesC8& LocalName() const = 0; williamr@2: williamr@2: /** williamr@2: * Getter for fragment XML namespace URI. williamr@2: * @since Series60 3.0 williamr@2: * @return namespace URI or KNullDesC8 if not set. williamr@2: */ williamr@2: virtual const TDesC8& NsUri() const = 0; williamr@2: williamr@2: /** williamr@2: * Getter for XML namespace prefix of this fragment. williamr@2: * @since Series60 3.0 williamr@2: * @return namespace prefix or KNullDesC8 if not set. williamr@2: */ williamr@2: virtual const TDesC8& NsPrefix() const = 0; williamr@2: williamr@2: /** williamr@2: * Fragment writes itself to a write stream using UTF-8 encoding. williamr@2: * @since Series60 3.0 williamr@2: * @param aWriteStream: The stream to write to. williamr@2: */ williamr@2: virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0; williamr@2: williamr@2: /** williamr@2: * Gets the fragment as Unicode (UCS-2) form XML. williamr@2: * @since Series60 3.0 williamr@2: * @return fragment as XML. Caller takes ownership. williamr@2: */ williamr@2: virtual HBufC* AsXmlUnicodeL() = 0; williamr@2: williamr@2: /** williamr@2: * Gets the fragment as a UTF-8 form XML. williamr@2: * @since Series60 3.0 williamr@2: * @return fragment as XML. Caller takes ownership. williamr@2: */ williamr@2: virtual HBufC8* AsXmlL() = 0; williamr@2: williamr@2: /** williamr@2: * Checks if fragment matches to another fragment by its content and williamr@2: * child elements. Fragment can contain more data than the given williamr@2: * candidate. williamr@2: * @since Series60 3.0 williamr@2: * @param aCandidate The pattern to be matched. Must contain same or williamr@2: * less data for match to come true. williamr@2: * @return ETrue if content and possible children match exactly williamr@2: * to given pattern. EFalse otherwise. williamr@2: */ williamr@2: virtual TBool ConsistsOfL(MSenFragment& aCandidate) = 0; williamr@2: }; williamr@2: williamr@2: #endif // M_SEN_FRAGMENT_H williamr@2: williamr@2: // End of File