williamr@2: /* williamr@2: * Copyright (c) 2004-2006 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: Node class declaration williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef XMLENGINE_NODE_H_INCLUDED williamr@2: #define XMLENGINE_NODE_H_INCLUDED williamr@2: williamr@2: #include williamr@2: williamr@2: // forward declaration williamr@2: class TXmlEngNode; williamr@2: williamr@2: // Forward declarations williamr@2: template class RXmlEngNodeList; williamr@2: williamr@2: class RXmlEngDocument; williamr@2: class TXmlEngElement; williamr@2: class TXmlEngAttr; williamr@2: class TXmlEngTextNode; williamr@2: class TXmlEngNamespace; williamr@2: class TXmlEngComment; williamr@2: class TXmlEngCDATASection; williamr@2: class TXmlEngDocumentFragment; williamr@2: class TXmlEngEntityReference; williamr@2: class TXmlEngProcessingInstruction; williamr@2: class MXmlEngUserData; williamr@2: class TXmlEngBinaryContainer; williamr@2: class TXmlEngChunkContainer; williamr@2: class TXmlEngDataContainer; williamr@2: class TXmlEngFileContainer; williamr@2: // williamr@2: williamr@2: /** williamr@2: * Instance of TXmlEngNode class represents an XML node in the DOM tree. williamr@2: * williamr@2: * Class implements methods that are similar for all XML node types williamr@2: * i.e. element, attribute. williamr@2: * williamr@2: * Sample code for node tree modifications: williamr@2: * @code williamr@2: * RXmlEngDOMImplementation domImpl; williamr@2: * domImpl.OpenL(); ///< opening DOM implementation object williamr@2: * RXmlEngDocument iDoc; ///< iDoc with created nodes tree williamr@2: * TXmlEngNode tmp = iDoc.DocumentElement(); williamr@2: * ///< copying first child of iDoc to tmp2 node and appending it williamr@2: * TXmlEngNode tmp2 = tmp.FirstChild().CopyL(); williamr@2: * tmp.AppendChildL(tmp2); williamr@2: * ///< copying next node to the first child of iDoc to the last child place williamr@2: * tmp.FirstChild().NextSibling().CopyToL(tmp.LastChild()); williamr@2: * ///< replasing before last child with second child williamr@2: * tmp.LastChild().PreviousSibling().ReplaceWith(tmp.FirstChild().NextSibling()); williamr@2: * ///< moving first child of iDoc to second child childrens williamr@2: * tmp.FirstChild().MoveTo(tmp.FirstChild().NextSibling()); williamr@2: * iDoc.Close(); ///< closing all opened objects williamr@2: * domImpl.Close(); williamr@2: * @endcode williamr@2: * williamr@2: * @lib XmlEngineDOM.lib williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: class TXmlEngNode williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * The different element types carried by an XML tree. williamr@2: * williamr@2: * @note This is synchronized with DOM Level 3 values williamr@2: * See http://www.w3.org/TR/DOM-Level-3-Core/ williamr@2: * williamr@2: */ williamr@2: enum TXmlEngDOMNodeType { williamr@2: EElement = 1, williamr@2: EAttribute = 2, williamr@2: EText = 3, williamr@2: ECDATASection = 4, williamr@2: EEntityReference = 5, williamr@2: EEntity = 6, //> Not supported currently williamr@2: EProcessingInstruction = 7, williamr@2: EComment = 8, williamr@2: EDocument = 9, williamr@2: EDocumentType = 10, //> Not supported currently williamr@2: EDocumentFragment = 11, williamr@2: ENotation = 12, //> Not supported currently williamr@2: ENamespaceDeclaration = 18, //> Not in DOM spec williamr@2: EBinaryContainer = 30, //> Not in DOM spec williamr@2: EChunkContainer = 31, //> Not in DOM spec williamr@2: EFileContainer = 32 //> Not in DOM spec williamr@2: }; williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Default constructor williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: inline TXmlEngNode(); williamr@2: williamr@2: /** williamr@2: * Constructor williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aInternal node pointer williamr@2: */ williamr@2: inline TXmlEngNode(void* aInternal); williamr@2: williamr@2: /** williamr@2: * Check if node is NULL williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return TRUE if node is NULL in other case FALSE williamr@2: */ williamr@2: inline TBool IsNull() const; williamr@2: williamr@2: /** williamr@2: * Check if node is NULL williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return TRUE if node is not NULL in other case FALSE williamr@2: */ williamr@2: inline TBool NotNull()const; williamr@2: williamr@2: /** williamr@2: * Cast node to attribute node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Attribute node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngAttr& AsAttr() const; williamr@2: williamr@2: /** williamr@2: * Cast node to text node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Text node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngTextNode& AsText() const; williamr@2: williamr@2: /** williamr@2: * Cast node to binary data container williamr@2: * williamr@2: * @since S60 v3.2 williamr@2: * @return Binary container williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngBinaryContainer& AsBinaryContainer() const; williamr@2: williamr@2: /** williamr@2: * Cast node to memory chunk container williamr@2: * williamr@2: * @since S60 v3.2 williamr@2: * @return Chunk container williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngChunkContainer& AsChunkContainer() const; williamr@2: williamr@2: /** williamr@2: * Cast node to file container williamr@2: * williamr@2: * @since S60 v3.2 williamr@2: * @return File container williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngFileContainer& AsFileContainer() const; williamr@2: williamr@2: /** williamr@2: * Cast node to memory chunk container williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Chunk container williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngDataContainer& AsDataContainer() const; williamr@2: williamr@2: /** williamr@2: * Cast node to element node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Element node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngElement& AsElement() const; williamr@2: williamr@2: /** williamr@2: * Cast node to comment node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Comment node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngComment& AsComment() const; williamr@2: williamr@2: /** williamr@2: * Cast node to namespace node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Namespace node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngNamespace& AsNamespace() const; williamr@2: williamr@2: /** williamr@2: * Cast node to CDATA section node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return CDATA section node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngCDATASection& AsCDATASection() const; williamr@2: williamr@2: /** williamr@2: * Cast node to entity reference node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Entity reference node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngEntityReference& AsEntityReference() const; williamr@2: williamr@2: /** williamr@2: * Cast node to processing instruction node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Processing instruction node williamr@2: * williamr@2: * @note williamr@2: * - Never cast nodes to a wrong node type! williamr@2: * - Casting removes const'ness of the node williamr@2: */ williamr@2: inline TXmlEngProcessingInstruction& AsProcessingInstruction() const; williamr@2: williamr@2: /** williamr@2: * Get innerXML string. This method returns all content of the node. williamr@2: * Output text does not include node markup. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aBuffer RBuf8 in which output should be save williamr@2: * @return Size of output buffer williamr@2: * @note Returned RBuf8 should be freed williamr@2: */ williamr@2: IMPORT_C TInt InnerXmlL(RBuf8& aBuffer); williamr@2: williamr@2: /** williamr@2: * Get outerXML string. This method returns all content of the node. williamr@2: * Output text includes node markup. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aBuffer RBuf8 in which output should be save williamr@2: * @return Size of output buffer williamr@2: * @note Returned RBuf8 should be freed williamr@2: */ williamr@2: IMPORT_C TInt OuterXmlL(RBuf8& aBuffer); williamr@2: williamr@2: /** williamr@2: * Moves the node to become the first in the list of its siblings williamr@2: * Node is expected to have a parent. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: IMPORT_C void SetAsFirstSibling(); williamr@2: williamr@2: /** williamr@2: * Moves the node to become the last in the list of its siblings williamr@2: * Node is expected to have a parent. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: IMPORT_C void SetAsLastSibling(); williamr@2: williamr@2: /** williamr@2: * Moves the node in the list of sibling nodes before another node williamr@2: * Node is expected to have a parent. williamr@2: * Do nothing if aSiblingNode is not one of node's siblings williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aSiblingNode Node that should be after current node williamr@2: */ williamr@2: IMPORT_C void MoveBeforeSibling(TXmlEngNode aSiblingNode); williamr@2: williamr@2: /** williamr@2: * Moves the node in the list of sibling nodes after another node williamr@2: * Node is expected to have a parent. williamr@2: * Do nothing if aSiblingNode is not one of the node's siblings williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aSiblingNode Node that should be after current node williamr@2: */ williamr@2: IMPORT_C void MoveAfterSibling(TXmlEngNode aSiblingNode); williamr@2: williamr@2: /** williamr@2: * Moves the node to another part of the tree or another document williamr@2: * The node is unliked from current postion (if any) and appended williamr@2: * to the its new parent. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aParent Parent node williamr@2: * @return Node handle williamr@2: * williamr@2: * @note williamr@2: * In many cases this method call should be followed by ReconcileNamespacesL() on the moved node williamr@2: */ williamr@2: inline TXmlEngNode MoveTo(TXmlEngNode aParent); williamr@2: williamr@2: /** williamr@2: * Detaches a node from document tree williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return This node, which is already not a part of any document williamr@2: * @note Remember to use ReconcileNamespacesL() later, if extracted node (subtree) williamr@2: * contains references to namespace declarations outside of the subtree. williamr@2: * @see ReconcileNamespacesL() williamr@2: * @note The document, from which the is being unlinked, becomes an owner of the node williamr@2: * until it is linked elsewhere. williamr@2: */ williamr@2: IMPORT_C TXmlEngNode Unlink(); williamr@2: williamr@2: /** williamr@2: * Ensures that namespaces referred to in the node and its descendants are williamr@2: * in the scope the node. williamr@2: * williamr@2: * This method checks that all the namespaces declared within the given williamr@2: * tree are properly declared. This is needed for example after Copy or Unlink williamr@2: * and then Append operations. The subtree may still hold pointers to williamr@2: * namespace declarations outside the subtree or they may be invalid/masked. As much williamr@2: * as possible the function try to reuse the existing namespaces found in williamr@2: * the new environment. If not possible, the new namespaces are redeclared williamr@2: * on the top of the subtree. williamr@2: * williamr@2: * This method should be used after unlinking nodes and inserting to another williamr@2: * document tree or to a another part of the original tree, if some nodes of the subtree williamr@2: * are remove from the scope of a namespace declaration they refer to. williamr@2: * williamr@2: * When node is unlinked, it may still refer to namespace declarations from the previous location. williamr@2: * It is important to reconcile subtree's namespaces if previous parent tree is to be destroyed. williamr@2: * On the other hand, if the parent tree is not changed before pasting its unlinked part into another williamr@2: * tree, then reconciliation is needed only after paste operation. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: IMPORT_C void ReconcileNamespacesL(); williamr@2: williamr@2: /** williamr@2: * Unlinks the node and destroys it; all child nodes are destroyed as well and all memory is freed williamr@2: * williamr@2: * @note Document nodes cannot be "removed" with this method, uses RXmlEngDocument-specific methods. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: IMPORT_C void Remove(); williamr@2: williamr@2: /** williamr@2: * Current node is replaced with another node (subtree). williamr@2: * williamr@2: * The replacement node is linked into document tree instead of this node. williamr@2: * The replaced node is destroyed. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aNode Node that repleace current node williamr@2: * williamr@2: * @see SubstituteFor(TXmlEngNode) williamr@2: * williamr@2: * In both cases the argument node is unlinked from its previous location williamr@2: * (which can be NONE, i.e. not linked; SAME or ANOTHER document tree). williamr@2: * williamr@2: * @note Replacement of a node with NULL TXmlEngNode is legal and equivalent to removing the node. williamr@2: * @note Not applicable to document nodes williamr@2: */ williamr@2: IMPORT_C void ReplaceWith(TXmlEngNode aNode); williamr@2: williamr@2: /** williamr@2: * Another node is put instead of the current node. williamr@2: * williamr@2: * Does the same as ReplaceWith(TXmlEngNode) but does not free node and just returns it. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aNode Node that repleace current node williamr@2: * @return Current node after unlinking it from document tree williamr@2: * @see ReplaceWith(TXmlEngNode) williamr@2: * williamr@2: * In both cases the argument node is unlinked from its previous location williamr@2: * (which can be NONE, i.e. not linked; SAME or ANOTHER document tree) williamr@2: * williamr@2: * It is possible to use NULL TXmlEngNode object as an argument. In such case williamr@2: * no new node will be put instead of unlinked one. williamr@2: * williamr@2: * @note Not applicable to document nodes williamr@2: */ williamr@2: IMPORT_C TXmlEngNode SubstituteForL(TXmlEngNode aNode); williamr@2: williamr@2: /** williamr@2: * Retrieves a "handle" for namespace declaration that applies to the node's namespace williamr@2: * Note: DOM specs do not consider namespace declarations as a kind of nodes williamr@2: * This API adds TXmlEngNamespace type of nodes, which is derived from TXmlEngNode. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Object that represents namespace declaration and prefix binding that williamr@2: * act on the node; returns NULL object (check using TXmlEngNamespace.IsNull() williamr@2: * or TXmlEngNamespace.NotNull()) if no namespace associated williamr@2: */ williamr@2: IMPORT_C TXmlEngNamespace NamespaceDeclaration() const; williamr@2: williamr@2: /** williamr@2: * Attaches a user data object to this node. The ownership of the object is transferred. williamr@2: * When the (underlying) node is deleted the Destroy method of the MXmlEngUserData class will be williamr@2: * called. If there already is a user data object associated with this node, it will be williamr@2: * deleted before attaching the new object. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aData Pointer to the data object. williamr@2: * @return true if successful, false if for example underlying node type doesn't support williamr@2: * attaching user data. williamr@2: * @note Only TXmlEngElement and Attribute nodes currently support this feature. williamr@2: * User data is not copied, when node is copied. williamr@2: */ williamr@2: IMPORT_C TBool AddUserData(MXmlEngUserData* aData); williamr@2: williamr@2: /** williamr@2: * Returns the user data object attached to this node. Ownership is not transferred. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Pointer to data object or NULL if it doesn't exist. williamr@2: */ williamr@2: IMPORT_C MXmlEngUserData* UserData() const; williamr@2: williamr@2: /** williamr@2: * Removes the user data onject attached to this node. Ownership is transferred williamr@2: * (the object is not deleted). williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Pointer to data object or NULL if it doesn't exist. williamr@2: */ williamr@2: IMPORT_C MXmlEngUserData* RemoveUserData(); williamr@2: williamr@2: /** williamr@2: * Clones the node completely: all attributes and namespace declarations (for TXmlEngElement nodes), williamr@2: * values and children nodes are copied as well. williamr@2: * williamr@2: * Document nodes cannot be copied with this method: RXmlEngDocument::CloneDocumentL() must be used. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Complete copy of a node or leaves. williamr@2: * @note The node should not be NULL! williamr@2: */ williamr@2: IMPORT_C TXmlEngNode CopyL() const; williamr@2: williamr@2: /** williamr@2: * Creates a deep copy of the node and appends the subtree as a new child williamr@2: * to the provided parent node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Created copy of the node after linking it into the target document tree. williamr@2: * @note Document nodes cannot be copied with this method; use RXmlEngDocument::CloneDocumentL() williamr@2: */ williamr@2: IMPORT_C TXmlEngNode CopyToL(TXmlEngNode aParent) const; williamr@2: williamr@2: /** williamr@2: * Append a child node. williamr@2: * williamr@2: * This is universal operation for any types of nodes. williamr@2: * Note, that some types of nodes cannot have children and williamr@2: * some types of nodes are not allowed to be children of some other types. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aNewChild Child node that should be added williamr@2: * @return Appended node, which could changed as a result of adding it to williamr@2: * list of child nodes (e.g. text nodes can coalesce together) williamr@2: */ williamr@2: IMPORT_C TXmlEngNode AppendChildL(TXmlEngNode aNewChild); williamr@2: williamr@2: /** williamr@2: * Initializes a node list with all children of the node williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aList node list that should be initialized williamr@2: */ williamr@2: IMPORT_C void GetChildNodes(RXmlEngNodeList& aList) const; williamr@2: williamr@2: /** williamr@2: * Get parent node of current node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Parent node of the node or NULL if no parent williamr@2: */ williamr@2: IMPORT_C TXmlEngNode ParentNode() const; williamr@2: williamr@2: /** williamr@2: * Get first child of current node williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return The first child node or NULL if no children williamr@2: */ williamr@2: IMPORT_C TXmlEngNode FirstChild() const; williamr@2: williamr@2: /** williamr@2: * Get last child of current node williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return The last child node or NULL if no children williamr@2: */ williamr@2: IMPORT_C TXmlEngNode LastChild() const; williamr@2: williamr@2: /** williamr@2: * Get previous node of current node williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Previous node in a child list or NULL if no sibling before williamr@2: */ williamr@2: IMPORT_C TXmlEngNode PreviousSibling() const; williamr@2: williamr@2: /** williamr@2: * Get fallowing node of current node williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Following node in a child list or NULL if no sibling after williamr@2: */ williamr@2: IMPORT_C TXmlEngNode NextSibling() const; williamr@2: williamr@2: /** williamr@2: * Get document handle williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return A document node of the DOM tree this node belongs to williamr@2: * williamr@2: * @note An instance of RXmlEngDocument class returns itself williamr@2: */ williamr@2: IMPORT_C RXmlEngDocument OwnerDocument() const; williamr@2: williamr@2: /** williamr@2: * Fetches value of this node, depending on its type. williamr@2: * williamr@2: * @note It is better to always cast nodes to specific type and then use specific williamr@2: * method for getting "node value" williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Node value williamr@2: */ williamr@2: IMPORT_C TPtrC8 Value() const; williamr@2: williamr@2: /** williamr@2: * Get copy of node's text content williamr@2: * What is returned depends on the node type. williamr@2: * Method caller is responsible for freeing returned string. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return the content of the node williamr@2: */ williamr@2: IMPORT_C void WholeTextContentsCopyL(RBuf8& aOutput) const; williamr@2: williamr@2: /** williamr@2: * Sets value of this node. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aValue New value williamr@2: */ williamr@2: IMPORT_C void SetValueL(const TDesC8& aValue); williamr@2: williamr@2: /** williamr@2: * Check if node content is "simple text". williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Whether the value of the node is presented by only one TXmlEngTextNode node williamr@2: * williamr@2: * If the value is "simple text" then it is possible to access it as TDOMString williamr@2: * without making copy, which combines values of all text nodes and entity reference nodes. williamr@2: * williamr@2: * @see TXmlEngNode::Value(), TXmlEngAttr::Value(), TXmlEngElement::Text() williamr@2: * williamr@2: * This method is applicable to TXmlEngElement and TXmlEngAttr nodes. On other nodes FALSE is returned. williamr@2: * williamr@2: * @note williamr@2: * Values (contents) of TXmlEngComment, TXmlEngCDATASection, TXmlEngTextNode, ProcessingInstuction data are williamr@2: * always "simple". williamr@2: * williamr@2: * When the returned result is FALSE, getting value of the node would not returned williamr@2: * whole contents because of either entity references present in the contents or williamr@2: * the contents is mixed (for TXmlEngElement node). In this case WholeTextContentsCopyL() williamr@2: * should be used. williamr@2: * williamr@2: * @see TXmlEngNode::WholeTextContentsCopyL() williamr@2: */ williamr@2: IMPORT_C TBool IsSimpleTextContents() const; williamr@2: williamr@2: /** williamr@2: * Use NodeType() to find out the type of the node prior to casting object williamr@2: * of TXmlEngNode class to one of its derived subclasses (TXmlEngElement, TXmlEngAttr, TXmlEngTextNode, etc.) williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Type of the node williamr@2: * williamr@2: * @see TXmlEngDOMNodeType williamr@2: */ williamr@2: IMPORT_C TXmlEngDOMNodeType NodeType() const; williamr@2: williamr@2: /** williamr@2: * Get node name williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Name of the node williamr@2: * williamr@2: * This method generally follows DOM spec : williamr@2: * ------------------------------------------------------------------------------- williamr@2: * The values of nodeName, nodeValue, and attributes vary according to the node williamr@2: * type as follows: williamr@2: * williamr@2: * interface nodeName nodeValue attributes williamr@2: * ------------------------------------------------------------------------------- williamr@2: * Attr = Attr.name = Attr.value = null williamr@2: * CDATASection = "#cdata-section" = CharacterData.data = null williamr@2: * Comment = "#comment" = CharacterData.data = null williamr@2: * Document = "#document" = null = null williamr@2: * DocumentFragment = "#document-fragment" = null = null williamr@2: * DocumentType = DocumentType.name = null = null williamr@2: * Element = Element.tagName = null = NamedNodeMap williamr@2: * Entity = entity name = null = null williamr@2: * EntityReference = name of entity referenced = null = null williamr@2: * Notation = notation name = null = null williamr@2: * ProcessingInstruction = target = data = null williamr@2: * Text = "#text" = CharacterData.data = null williamr@2: * ------------------------------------------------------------------------------- williamr@2: */ williamr@2: IMPORT_C TPtrC8 Name() const; williamr@2: williamr@2: williamr@2: /** williamr@2: * Check if node has child nodes. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return True if the node is TXmlEngElement and has at least one child node williamr@2: */ williamr@2: IMPORT_C TBool HasChildNodes() const; williamr@2: williamr@2: /** williamr@2: * Check if node has attributes. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return True if the node is TXmlEngElement and has at least one attribute williamr@2: * williamr@2: * @note Namespace-to-prefix bindings are not attributes. williamr@2: */ williamr@2: IMPORT_C TBool HasAttributes() const; williamr@2: williamr@2: /** williamr@2: * Evaluates active base URI for the node by processing xml:base attributes of parents williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return A copy of effective base URI for the node williamr@2: * @note It's up to the caller to free the string williamr@2: */ williamr@2: IMPORT_C void BaseUriL(RBuf8& aBaseUri) const; williamr@2: williamr@2: /** williamr@2: * Compares nodes. williamr@2: * williamr@2: * The nodes are the same if they are referring to the same in-memory williamr@2: * data structure. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aOther Node to compare williamr@2: * @return TRUE if the same williamr@2: */ williamr@2: inline TBool IsSameNode(TXmlEngNode aOther) const; williamr@2: williamr@2: /** williamr@2: * Get namespace uri. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Namespace URI of a node williamr@2: * - NULL is returned for elements and attributes that do not williamr@2: * belong to any namespace. williamr@2: * - bound namespace URI is returned for namespace declaration nodes (instances of TXmlEngNamespace). williamr@2: * - NULL is returned to all other types of node. williamr@2: * williamr@2: * @note use IsNull() and NotNull() for testing returned result on the subject williamr@2: * of having some URI williamr@2: */ williamr@2: IMPORT_C TPtrC8 NamespaceUri() const; williamr@2: williamr@2: /** williamr@2: * Get namespace prefix. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @return Prefix of a node williamr@2: * Returns NULL for elements and attributes that do not have prefix williamr@2: * (node belongs to the default namespace or does not belong to any namespace) williamr@2: * NULL is also returned for all types of node other than TXmlEngElement or TXmlEngAttr williamr@2: */ williamr@2: IMPORT_C TPtrC8 Prefix() const; williamr@2: williamr@2: /** williamr@2: * Check if nemespace is default for this node williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aNamespaceUri Namespace URI williamr@2: * @return True if given namespace URI is a default one for the node (applicable to elements only) williamr@2: * williamr@2: * @note "" or NULL can be used to denote undefined namespace williamr@2: */ williamr@2: IMPORT_C TBool IsDefaultNamespaceL(const TDesC8& aNamespaceUri) const; williamr@2: williamr@2: /** williamr@2: * Searches the prefix that is bound to the given aNamespaceUri and williamr@2: * applicable in the scope of this TXmlEngNode. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aNamespaceUri Namespace Uri that should be found williamr@2: * @return A sought prefix or NULL if not found or aNamespaceUri is the default namespace williamr@2: * williamr@2: * @see TXmlEngElement::LookupNamespaceByUriL(const TDesC8&) williamr@2: */ williamr@2: IMPORT_C TPtrC8 LookupPrefixL(const TDesC8& aNamespaceUri) const; williamr@2: williamr@2: /** williamr@2: * Searches the namespace URI that is bound to the given prefix. williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aPrefix Namespace prefix that should be found williamr@2: * @return A sought URI or NULL if the prefix is not bound williamr@2: * williamr@2: * @see TXmlEngElement::LookupNamespaceByPrefixL(const TDesC8&) williamr@2: */ williamr@2: IMPORT_C TPtrC8 LookupNamespaceUriL(const TDesC8& aPrefix) const; williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * Unlinks the internal libxml2's node from double-linked list. williamr@2: * Relinks neighbour nodes.The node stays virtually linked to its old neighbours! Use with care!! williamr@2: * williamr@2: * No checks are made; nor parent's, nor node's properties updated williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: */ williamr@2: void DoUnlinkNode(); williamr@2: williamr@2: /** williamr@2: * Inserts the node in a double-linked list of nodes before specified node. williamr@2: * williamr@2: * No checks are made; nor parent's, nor node's properties updated (except prev/next) williamr@2: * williamr@2: * @since S60 v3.1 williamr@2: * @param aNode Target node williamr@2: */ williamr@2: void LinkBefore(TXmlEngNode aNode); williamr@2: williamr@2: protected: williamr@2: /** Node pointer */ williamr@2: void* iInternal; williamr@2: williamr@2: }; williamr@2: williamr@2: #include "xmlengnode.inl" williamr@2: williamr@2: #endif /* XMLENGINE_NODE_H_INCLUDED */