epoc32/include/xml/dom/xmlengnode.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     2
// All rights reserved.
williamr@4
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@4
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     7
//
williamr@4
     8
// Initial Contributors:
williamr@4
     9
// Nokia Corporation - initial contribution.
williamr@4
    10
//
williamr@4
    11
// Contributors:
williamr@4
    12
//
williamr@4
    13
// Description:
williamr@4
    14
// Node class declaration
williamr@4
    15
//
williamr@4
    16
williamr@4
    17
williamr@4
    18
williamr@4
    19
/**
williamr@4
    20
 @file
williamr@4
    21
 @publishedAll
williamr@4
    22
 @released
williamr@2
    23
*/
williamr@4
    24
#ifndef XMLENGNODE_H
williamr@4
    25
#define XMLENGNODE_H
williamr@2
    26
williamr@2
    27
#include <e32base.h>
williamr@2
    28
williamr@2
    29
class TXmlEngNode;
williamr@2
    30
template<class T> class RXmlEngNodeList;
williamr@2
    31
class RXmlEngDocument;
williamr@2
    32
class TXmlEngElement;
williamr@2
    33
class TXmlEngAttr;
williamr@2
    34
class TXmlEngTextNode;
williamr@2
    35
class TXmlEngNamespace;
williamr@2
    36
class TXmlEngComment;
williamr@2
    37
class TXmlEngCDATASection;
williamr@2
    38
class TXmlEngDocumentFragment;
williamr@2
    39
class TXmlEngEntityReference;
williamr@2
    40
class TXmlEngProcessingInstruction;
williamr@2
    41
class MXmlEngUserData;
williamr@2
    42
class TXmlEngBinaryContainer;
williamr@2
    43
class TXmlEngChunkContainer;
williamr@2
    44
class TXmlEngDataContainer;
williamr@2
    45
class TXmlEngFileContainer;
williamr@2
    46
williamr@2
    47
/**
williamr@4
    48
This class represents an XML node in the DOM tree.
williamr@4
    49
williamr@4
    50
As the base class for other node types (element, attribute, etc.) this class
williamr@4
    51
implements common methods that are similar for all XML node types.
williamr@4
    52
williamr@4
    53
Sample code for tree manipulations:
williamr@4
    54
@code  
williamr@4
    55
    RXmlEngDOMImplementation domImpl;
williamr@4
    56
    domImpl.OpenL();        	// opening DOM implementation object 
williamr@4
    57
    RXmlEngDocument iDoc; 		// iDoc with created nodes tree
williamr@4
    58
    TXmlEngNode tmp = iDoc.DocumentElement();
williamr@4
    59
 	// copying first child of iDoc to tmp2 node and appending it
williamr@4
    60
	TXmlEngNode tmp2 = tmp.FirstChild().CopyL();
williamr@4
    61
 	tmp.AppendChildL(tmp2);
williamr@4
    62
 	// copying the second child of iDoc to the last child
williamr@4
    63
 	tmp.FirstChild().NextSibling().CopyToL(tmp.LastChild());
williamr@4
    64
 	// replacing the second to last child with the second child 
williamr@4
    65
 	tmp.LastChild().PreviousSibling().ReplaceWith(tmp.FirstChild().NextSibling());
williamr@4
    66
 	// moving first child of iDoc to second child's children
williamr@4
    67
 	tmp.FirstChild().MoveTo(tmp.FirstChild().NextSibling());	
williamr@4
    68
    iDoc.Close();				// closing all opened objects
williamr@4
    69
    domImpl.Close();
williamr@4
    70
@endcode 
williamr@4
    71
williamr@4
    72
A node is NULL when the internal data pointer is NULL.  This is the default
williamr@4
    73
state of a newly created node.  Many DOM APIs that return TXmlEngNode objects
williamr@4
    74
use this NULL state to indicate a failure of some kind.  The methods IsNull()
williamr@4
    75
and NotNull() can be used to determine whether a node is NULL.
williamr@4
    76
*/
williamr@2
    77
class TXmlEngNode
williamr@2
    78
{
williamr@2
    79
public:
williamr@2
    80
   /**
williamr@4
    81
   The different node types in a XML tree.
williamr@4
    82
   */
williamr@2
    83
    enum TXmlEngDOMNodeType {
williamr@2
    84
        EElement                =        1,
williamr@2
    85
        EAttribute              =        2,
williamr@2
    86
        EText                   =        3,
williamr@2
    87
        ECDATASection           =        4,
williamr@2
    88
        EEntityReference        =        5,
williamr@4
    89
		/** Not supported */
williamr@4
    90
        EEntity                 =        6,
williamr@2
    91
        EProcessingInstruction  =        7,
williamr@2
    92
        EComment                =        8,
williamr@2
    93
        EDocument               =        9,
williamr@4
    94
		/** Not supported */
williamr@4
    95
        EDocumentType           =        10,
williamr@2
    96
        EDocumentFragment       =        11,
williamr@4
    97
		/** Not supported */
williamr@4
    98
        ENotation               =        12,
williamr@4
    99
		/** Extension to the DOM spec */
williamr@4
   100
        ENamespaceDeclaration   =        18,
williamr@4
   101
		/** Extension to the DOM spec */
williamr@4
   102
		EBinaryContainer 		= 		 30,
williamr@4
   103
		/** Extension to the DOM spec */
williamr@4
   104
		EChunkContainer 		= 		 31,
williamr@4
   105
		/** Extension to the DOM spec */
williamr@4
   106
		EFileContainer 			= 		 32
williamr@2
   107
    };
williamr@2
   108
williamr@2
   109
public:
williamr@4
   110
    /** Default constructor */
williamr@2
   111
    inline TXmlEngNode();
williamr@2
   112
williamr@2
   113
    /**
williamr@4
   114
    Constructor
williamr@4
   115
    @param aInternal node pointer
williamr@4
   116
    */
williamr@2
   117
    inline TXmlEngNode(void* aInternal);
williamr@2
   118
williamr@2
   119
    /**
williamr@4
   120
    Check if the node is NULL
williamr@4
   121
    @return ETrue if node is NULL, otherwise EFalse 
williamr@4
   122
    */
williamr@2
   123
    inline TBool IsNull() const;
williamr@2
   124
williamr@2
   125
    /**
williamr@4
   126
    Check if node is not NULL
williamr@4
   127
    @return ETrue if node is not NULL, otherwise EFalse
williamr@4
   128
    */
williamr@4
   129
    inline TBool NotNull() const;
williamr@2
   130
williamr@2
   131
    /**
williamr@4
   132
    Cast to an attribute node.
williamr@4
   133
	Note:
williamr@4
   134
         - Never cast nodes to the wrong node type!
williamr@4
   135
         - Casting removes the const'ness of the node
williamr@4
   136
    @return This node as an attribute node
williamr@4
   137
    */
williamr@4
   138
    inline TXmlEngAttr& AsAttr() const;
williamr@2
   139
williamr@2
   140
    /**
williamr@4
   141
    Cast to a text node.
williamr@4
   142
	Note:
williamr@4
   143
        - Never cast nodes to the wrong node type!
williamr@4
   144
        - Casting removes the const'ness of the node
williamr@4
   145
    @return This node as a text node
williamr@4
   146
    */
williamr@4
   147
    inline TXmlEngTextNode& AsText() const;
williamr@2
   148
williamr@2
   149
    /**
williamr@4
   150
    Cast to a binary data container
williamr@4
   151
	Note:
williamr@4
   152
        - Never cast nodes to the wrong node type!
williamr@4
   153
        - Casting removes the const'ness of the node
williamr@4
   154
    @return This node as a binary container
williamr@4
   155
    */
williamr@4
   156
    inline TXmlEngBinaryContainer& AsBinaryContainer() const;
williamr@2
   157
williamr@2
   158
    /**
williamr@4
   159
    Cast to a memory chunk container
williamr@4
   160
	Note:
williamr@4
   161
        - Never cast nodes to the wrong node type!
williamr@4
   162
        - Casting removes the const'ness of the node
williamr@4
   163
    @return This node as a chunk container
williamr@4
   164
    */
williamr@4
   165
    inline TXmlEngChunkContainer& AsChunkContainer() const;
williamr@2
   166
williamr@2
   167
    /**
williamr@4
   168
    Cast to a file container
williamr@4
   169
	Note:
williamr@4
   170
        - Never cast nodes to the wrong node type!
williamr@4
   171
        - Casting removes the const'ness of the node
williamr@4
   172
    @return This node as a file container
williamr@4
   173
    */
williamr@4
   174
    inline TXmlEngFileContainer& AsFileContainer() const;
williamr@2
   175
williamr@2
   176
    /**
williamr@4
   177
    Cast to a memory chunk container
williamr@4
   178
    Note:
williamr@4
   179
        - Never cast nodes to the wrong node type!
williamr@4
   180
        - Casting removes the const'ness of the node
williamr@4
   181
    @return This node as a chunk container
williamr@4
   182
    */
williamr@4
   183
    inline TXmlEngDataContainer& AsDataContainer() const;
williamr@2
   184
williamr@2
   185
    /**
williamr@4
   186
    Cast to an element node.
williamr@4
   187
    Note:
williamr@4
   188
         - Never cast nodes to the wrong node type!
williamr@4
   189
         - Casting removes the const'ness of the node
williamr@4
   190
    @return This node as an element node
williamr@4
   191
    */
williamr@2
   192
    inline TXmlEngElement& AsElement() const;
williamr@2
   193
williamr@2
   194
    /**
williamr@4
   195
    Cast to a comment node.
williamr@4
   196
    Note:
williamr@4
   197
         - Never cast nodes to the wrong node type!
williamr@4
   198
         - Casting removes the const'ness of the node
williamr@4
   199
    @return This node as a comment node
williamr@4
   200
    */
williamr@2
   201
    inline TXmlEngComment& AsComment() const;
williamr@2
   202
williamr@2
   203
    /**
williamr@4
   204
    Cast to a namespace node.
williamr@4
   205
    Note:
williamr@4
   206
         - Never cast nodes to the wrong node type!
williamr@4
   207
         - Casting removes the const'ness of the node
williamr@4
   208
    @return This node as a namespace node
williamr@4
   209
    */
williamr@2
   210
    inline TXmlEngNamespace& AsNamespace() const;
williamr@2
   211
williamr@2
   212
    /**
williamr@4
   213
    Cast to a CDATA section node.
williamr@4
   214
    Note:
williamr@4
   215
         - Never cast nodes to the wrong node type!
williamr@4
   216
         - Casting removes the const'ness of the node
williamr@4
   217
    @return This node as a CDATA section node
williamr@4
   218
    */
williamr@2
   219
    inline TXmlEngCDATASection& AsCDATASection() const;
williamr@2
   220
williamr@2
   221
    /**
williamr@4
   222
    Cast to an entity reference node.
williamr@4
   223
    Note:
williamr@4
   224
         - Never cast nodes to the wrong node type!
williamr@4
   225
         - Casting removes the const'ness of the node
williamr@4
   226
    @return This node as an entity reference node
williamr@4
   227
    */
williamr@2
   228
    inline TXmlEngEntityReference& AsEntityReference() const;
williamr@2
   229
williamr@2
   230
    /**
williamr@4
   231
    Cast to a Document Fragment.
williamr@4
   232
    Note:
williamr@4
   233
         - Never cast nodes to the wrong node type!
williamr@4
   234
         - Casting removes the const'ness of the node
williamr@4
   235
    @return This node as a Document Fragment
williamr@4
   236
    */
williamr@4
   237
	inline TXmlEngDocumentFragment& AsDocumentFragment() const;
williamr@4
   238
williamr@4
   239
    /**
williamr@4
   240
    Cast to a processing instruction node.
williamr@4
   241
    Note:
williamr@4
   242
         - Never cast nodes to the wrong node type!
williamr@4
   243
         - Casting removes the const'ness of the node
williamr@4
   244
    @return This node as a Processing instruction node
williamr@4
   245
    */
williamr@2
   246
    inline TXmlEngProcessingInstruction& AsProcessingInstruction() const;
williamr@2
   247
williamr@4
   248
	/**
williamr@4
   249
	Get the inner XML string. This method returns all content of the node,
williamr@4
   250
	exluding node markup.  Child nodes will be included.  Any existing contents
williamr@4
   251
	in aBuffer will be destroyed.  This method allocates memory for the buffer.
williamr@4
   252
williamr@4
   253
    @param aBuffer A buffer owned by the caller that contains the result
williamr@4
   254
    @return Length of the output buffer
williamr@4
   255
	@leave KXmlEngErrWrongUseOfAPI Node is NULL
williamr@4
   256
	@leave - One of the system-wide error codes
williamr@4
   257
    */
williamr@2
   258
    IMPORT_C TInt InnerXmlL(RBuf8& aBuffer);
williamr@2
   259
    
williamr@4
   260
	/**
williamr@4
   261
	Get the outer XML string. This method returns all content of the node,
williamr@4
   262
	including node markup.  Child nodes will be included.  Any existing
williamr@4
   263
	contents in aBuffer will be destroyed.  This method allocates memory for
williamr@4
   264
	the buffer.
williamr@4
   265
williamr@4
   266
    @param aBuffer A buffer owned by the caller that contains the result
williamr@4
   267
    @return Length of the output buffer
williamr@4
   268
	@leave KXmlEngErrWrongUseOfAPI Node is NULL
williamr@4
   269
	@leave KXmlEngErrNegativeOutputSize Output has a negative length
williamr@4
   270
	@leave - One of the system-wide error codes
williamr@4
   271
    */
williamr@2
   272
    IMPORT_C TInt OuterXmlL(RBuf8& aBuffer);
williamr@2
   273
williamr@2
   274
    /**
williamr@4
   275
    Moves the node to become the first in the list of its siblings
williamr@4
   276
	@pre The node has a parent
williamr@4
   277
    */
williamr@2
   278
    IMPORT_C void SetAsFirstSibling();
williamr@2
   279
williamr@2
   280
    /**
williamr@4
   281
    Moves the node to become the last in the list of its siblings
williamr@4
   282
    @pre The node has a parent.
williamr@4
   283
    */
williamr@2
   284
    IMPORT_C void SetAsLastSibling();
williamr@2
   285
williamr@4
   286
	/**
williamr@4
   287
	Moves the node to come before the specified node in the list of sibling
williamr@4
   288
	nodes.  This method does nothing if aSiblingNode is not one of the node's
williamr@4
   289
	siblings.
williamr@4
   290
    @pre The node has a parent.
williamr@4
   291
	@param aSiblingNode The node is moved to fall before this sibling
williamr@4
   292
    */
williamr@2
   293
    IMPORT_C void MoveBeforeSibling(TXmlEngNode aSiblingNode);
williamr@2
   294
williamr@4
   295
	/**
williamr@4
   296
	Moves the node to come after the specified node in the list of sibling
williamr@4
   297
	nodes.  This method does nothing if aSiblingNode is not one of the node's
williamr@4
   298
	siblings.
williamr@4
   299
	@pre The node has a parent
williamr@4
   300
	@param aSiblingNode The node is moved to fall after this sibling
williamr@4
   301
    */    
williamr@2
   302
    IMPORT_C void MoveAfterSibling(TXmlEngNode aSiblingNode);
williamr@2
   303
williamr@4
   304
	/**
williamr@4
   305
	Moves the node to another part of the tree or to another document.  The
williamr@4
   306
	node is unlinked from its current postion (if any) and appended to its new
williamr@4
   307
	parent.
williamr@4
   308
williamr@4
   309
	Note: In many cases this method call should be followed by a call to
williamr@4
   310
	ReconcileNamespacesL().
williamr@4
   311
williamr@4
   312
    @param aParent This node will be moved to be a child of this node
williamr@4
   313
    @return This node
williamr@4
   314
	@leave KXmlEngErrNullNode The node is NULL
williamr@4
   315
	@leave - One of the system-wide error codes
williamr@4
   316
    */
williamr@4
   317
    inline TXmlEngNode MoveToL(TXmlEngNode aParent);
williamr@2
   318
williamr@2
   319
    /**
williamr@4
   320
	Moves the node to another part of the tree or to another document.  The
williamr@4
   321
	node is unlinked from its current postion (if any) and appended to its new
williamr@4
   322
	parent.
williamr@4
   323
    
williamr@4
   324
	Note: In many cases this method call should be followed by a call to
williamr@4
   325
	ReconcileNamespacesL().
williamr@4
   326
williamr@4
   327
    @see     ReconcileNamespacesL()
williamr@4
   328
    @param aParent This node will be moved to be a child of this node
williamr@4
   329
    @return This node
williamr@4
   330
	@leave KXmlEngErrNullNode The node is NULL
williamr@4
   331
	@leave - One of the system-wide error codes
williamr@4
   332
    
williamr@4
   333
	@deprecated This method has been deprecated and will be removed in a future
williamr@4
   334
	release.
williamr@4
   335
    */
williamr@4
   336
	inline TXmlEngNode MoveTo(TXmlEngNode aParent);
williamr@4
   337
williamr@4
   338
	/**
williamr@4
   339
	Detaches the node from the document tree.  The document maintains ownership
williamr@4
   340
	of the node until it is linked elsewhere.
williamr@4
   341
williamr@4
   342
	Note: Remember to use ReconcileNamespacesL() later, if the extracted node
williamr@4
   343
	(or subtree) contains references to namespace declarations outside of the
williamr@4
   344
	subtree.
williamr@4
   345
williamr@4
   346
    @see     ReconcileNamespacesL()
williamr@4
   347
    @return This node
williamr@4
   348
    */
williamr@2
   349
    IMPORT_C TXmlEngNode Unlink();
williamr@2
   350
williamr@2
   351
    /**
williamr@4
   352
    Ensures that namespaces referred to in the node and its descendants are
williamr@4
   353
    within the scope of the node.
williamr@4
   354
    
williamr@4
   355
	This method checks that all the namespaces declared within the subtree
williamr@4
   356
	parented by this node are properly declared. This is needed for example
williamr@4
   357
	after a Copy or an Unlink followed by an Append operation. The subtree may
williamr@4
   358
	still hold pointers to namespace declarations outside the subtree or they
williamr@4
   359
	may be invalid/masked.  The function tries to reuse the existing namespaces
williamr@4
   360
	found in the new environment as much as possible. If not possible, the new
williamr@4
   361
	namespaces are redeclared at the top of the subtree.
williamr@4
   362
    
williamr@4
   363
	This method should be used after unlinking nodes and inserting them into
williamr@4
   364
	another document tree or into another part of the original tree, if some
williamr@4
   365
	nodes of the subtree are removed from the scope of the namespace
williamr@4
   366
	declaration they refer to.
williamr@4
   367
    
williamr@4
   368
	When a node is unlinked, it may still refer to namespace declarations from
williamr@4
   369
	the previous location.  It is important to reconcile the subtree's
williamr@4
   370
	namespaces if the previous parent tree is to be destroyed.  On the other
williamr@4
   371
	hand, if the parent tree is not changed before pasting its unlinked part
williamr@4
   372
	into another tree, then reconciliation is needed only after the paste
williamr@4
   373
	operation.
williamr@4
   374
	@leave - One of the system-wide error codes
williamr@4
   375
    */
williamr@4
   376
	IMPORT_C void ReconcileNamespacesL();
williamr@2
   377
williamr@4
   378
	/**
williamr@4
   379
	Unlinks this node and destroys it; all child nodes are also destroyed and
williamr@4
   380
	all memory is freed.
williamr@4
   381
    
williamr@4
   382
	Note:  Document nodes cannot be removed with this method. Use 
williamr@4
   383
	RXmlEngDocument::Close() instead.
williamr@4
   384
    */
williamr@4
   385
	IMPORT_C void Remove();
williamr@2
   386
williamr@4
   387
	/**
williamr@4
   388
	This node is replaced with another node (or subtree).  The replacement node
williamr@4
   389
	is linked into the document tree instead of this node.  The replaced node
williamr@4
   390
	is destroyed.  Replacement of a node with a NULL TXmlEngNode is legal and
williamr@4
   391
	equivalent to removing the node.
williamr@4
   392
williamr@4
   393
	aNode is unlinked from its previous location, which can be none (i.e. not
williamr@4
   394
	linked), within the same document tree, or within another document tree.
williamr@4
   395
williamr@4
   396
	Note:  Not applicable to document nodes.
williamr@4
   397
williamr@4
   398
    @see SubstituteForL(TXmlEngNode)
williamr@4
   399
    @param aNode Node that replaces this node
williamr@4
   400
	@leave KXmlEngErrNullNode Node is NULL
williamr@4
   401
	@leave KXmlEngErrWrongUseOfAPI Node is a document node
williamr@4
   402
	@leave - One of the system-wide error codes
williamr@4
   403
    */
williamr@4
   404
    IMPORT_C void ReplaceWithL(TXmlEngNode aNode);
williamr@4
   405
williamr@4
   406
	/**
williamr@4
   407
	This node is replaced with another node (or subtree).  The replacement node
williamr@4
   408
	is linked into the document tree instead of this node.  The replaced node
williamr@4
   409
	is destroyed.  Replacement of a node with a NULL TXmlEngNode is legal and
williamr@4
   410
	equivalent to removing the node.
williamr@4
   411
williamr@4
   412
	aNode is unlinked from its previous location, which can be none (i.e. not
williamr@4
   413
	linked), within the same document tree, or within another document tree.
williamr@4
   414
williamr@4
   415
	Note:  Not applicable to document nodes.
williamr@4
   416
williamr@4
   417
    @see SubstituteForL(TXmlEngNode)
williamr@4
   418
    @param aNode Node that replaces this node
williamr@4
   419
	@deprecated This method has been deprecated and will be removed in a future
williamr@4
   420
	release.
williamr@4
   421
    */
williamr@2
   422
    IMPORT_C void ReplaceWith(TXmlEngNode aNode);
williamr@2
   423
williamr@4
   424
	/**
williamr@4
   425
	Unlinks this node and puts another in its place.  This function is the same
williamr@4
   426
	as ReplaceWithL(), but this node is not freed.
williamr@4
   427
williamr@4
   428
	aNode is unlinked from its previous location, which can be none (i.e. not
williamr@4
   429
	linked), within the same document tree, or within another document tree.
williamr@4
   430
williamr@4
   431
	It is possible to use a NULL TXmlEngNode object as an argument. In this
williamr@4
   432
	case, this node will simply be removed from the tree, but not freed.
williamr@4
   433
williamr@4
   434
	Note:  Not applicable to document nodes.
williamr@4
   435
    
williamr@4
   436
    @see ReplaceWithL()
williamr@4
   437
    @param aNode Node that replaces current node
williamr@4
   438
    @return The current node after unlinking it from document tree
williamr@4
   439
	@leave KXmlEngErrNullNode Node is NULL
williamr@4
   440
	@leave KXmlEngErrWrongUseOfAPI Node is a document node
williamr@4
   441
	@leave - One of the system-wide error codes
williamr@4
   442
    */
williamr@2
   443
    IMPORT_C TXmlEngNode SubstituteForL(TXmlEngNode aNode);
williamr@2
   444
williamr@2
   445
    /**
williamr@4
   446
    Retrieves the namespace declaration that applies to the node's namespace
williamr@2
   447
williamr@4
   448
	Note: The DOM spec does not consider namespace declarations as a kind of
williamr@4
   449
	node.  This API adds TXmlEngNamespace, which is derived from TXmlEngNode.
williamr@4
   450
    
williamr@4
   451
	@return The namespace declaration and prefix binding that act on the node;
williamr@4
   452
	returns a NULL object if no namespace associated
williamr@4
   453
    */
williamr@4
   454
	IMPORT_C TXmlEngNamespace NamespaceDeclaration() const;
williamr@4
   455
williamr@4
   456
	/**
williamr@4
   457
	Attaches a user data object to this node. The ownership of the object is
williamr@4
   458
	transferred.  When the node is deleted, the Destroy method of the
williamr@4
   459
	MXmlEngUserData class will be called. If there is a user data object
williamr@4
   460
	already associated with this node, it will be deleted before attaching the
williamr@4
   461
	new object.
williamr@4
   462
williamr@4
   463
	Only TXmlEngElement and TXmlEngAttr nodes currently support this feature.  
williamr@4
   464
williamr@4
   465
    User data is not copied when the node is copied. 
williamr@4
   466
williamr@4
   467
    @param aData Pointer to the data object.
williamr@4
   468
    @return ETrue if successful or EFalse if the node type does not support this operation
williamr@4
   469
    */
williamr@2
   470
    IMPORT_C TBool AddUserData(MXmlEngUserData* aData);
williamr@2
   471
williamr@2
   472
    /**
williamr@4
   473
    Gets the user data object attached to this node. Ownership is not transferred.
williamr@4
   474
    @return Pointer to data object or NULL if it doesn't exist.
williamr@4
   475
    */
williamr@2
   476
    IMPORT_C MXmlEngUserData* UserData() const;
williamr@2
   477
williamr@4
   478
	/**
williamr@4
   479
	Removes the user data object attached to this node and transfers ownership
williamr@4
   480
	to the caller.  The user data object is not deleted.
williamr@4
   481
    @return Pointer to the user data object or NULL if it doesn't exist.
williamr@4
   482
    */
williamr@2
   483
    IMPORT_C MXmlEngUserData* RemoveUserData();
williamr@2
   484
williamr@4
   485
	/**
williamr@4
   486
	Creates a deep copy of the node.  All values and children nodes are copied.
williamr@4
   487
	Attributes and namespace declarations are also copied for TXmlEngElement
williamr@4
   488
	nodes.  Document nodes cannot be copied with this method.  Use
williamr@4
   489
	RXmlEngDocument::CloneDocumentL() instead.
williamr@4
   490
williamr@4
   491
	User data stored with AddUserData() is not copied.
williamr@4
   492
	
williamr@4
   493
    @return A complete copy of the node or NULL if the node is a document node
williamr@4
   494
	@leave KXmlEngErrNullNode Node is NULL
williamr@4
   495
	@leave - One of the system-wide error codes
williamr@4
   496
    */
williamr@2
   497
    IMPORT_C TXmlEngNode CopyL() const;
williamr@2
   498
williamr@4
   499
	/**
williamr@4
   500
	Creates a deep copy of the node and appends the subtree as a new child to
williamr@4
   501
	the provided parent node.  Document nodes cannot be copied with this
williamr@4
   502
	method.  Use RXmlEngDocument::CloneDocumentL() instead.
williamr@4
   503
williamr@4
   504
	User data stored with AddUserData() is not copied.
williamr@4
   505
	
williamr@4
   506
    @return Created copy of the node after linking it into the target document tree.
williamr@4
   507
	@leave KXmlEngErrNullNode Node is NULL
williamr@4
   508
	@leave KXmlEngErrWrongUseOfAPI Node is document node
williamr@4
   509
	@leave - One of the system-wide error codes
williamr@4
   510
    */
williamr@2
   511
    IMPORT_C TXmlEngNode CopyToL(TXmlEngNode aParent) const;
williamr@2
   512
williamr@4
   513
	/**
williamr@4
   514
	Append a child node.  This is a universal operation for any type of node.
williamr@4
   515
	Note that some types of nodes cannot have children and some types of nodes
williamr@4
   516
	are not allowed to be children of some other types.  These relationships
williamr@4
   517
	are not enforced by this function.
williamr@4
   518
    
williamr@4
   519
    @param aNewChild The node that should be added as a child
williamr@4
   520
    @return The appended node, which could be changed as a result of adding it to
williamr@4
   521
    list of child nodes (e.g. text nodes can coalesce together)
williamr@4
   522
	@leave KXmlEngErrNullNode Node or aNewChild is NULL
williamr@4
   523
	@leave KErrNoMemory Memory allocation failure
williamr@4
   524
	@leave - One of the system-wide error codes
williamr@4
   525
    */
williamr@2
   526
    IMPORT_C TXmlEngNode AppendChildL(TXmlEngNode aNewChild);
williamr@2
   527
williamr@2
   528
    /**
williamr@4
   529
    Gets the list of children.
williamr@4
   530
    @param aList The list of children returned
williamr@4
   531
    */
williamr@2
   532
    IMPORT_C void GetChildNodes(RXmlEngNodeList<TXmlEngNode>& aList) const;
williamr@2
   533
williamr@2
   534
    /**
williamr@4
   535
    Gets the parent node
williamr@4
   536
    @return The parent node or NULL if no parent exists
williamr@4
   537
    */
williamr@2
   538
    IMPORT_C TXmlEngNode ParentNode() const;
williamr@2
   539
williamr@2
   540
    /**
williamr@4
   541
    Gets the first child
williamr@4
   542
    @return The first child node or NULL if no children
williamr@4
   543
    */
williamr@2
   544
    IMPORT_C TXmlEngNode FirstChild() const;
williamr@2
   545
williamr@2
   546
    /**
williamr@4
   547
    Gets the last child
williamr@4
   548
    @return The last child node or NULL if no children
williamr@4
   549
    */
williamr@2
   550
    IMPORT_C TXmlEngNode LastChild() const;
williamr@2
   551
williamr@2
   552
    /**
williamr@4
   553
    Gets the previous sibling
williamr@4
   554
    @return The previous sibling or NULL if there is no sibling before
williamr@4
   555
    */
williamr@2
   556
    IMPORT_C TXmlEngNode PreviousSibling() const;
williamr@2
   557
williamr@2
   558
    /**
williamr@4
   559
    Gets the next sibling
williamr@4
   560
    @return The next sibling or NULL if there is no sibling after
williamr@4
   561
    */
williamr@2
   562
    IMPORT_C TXmlEngNode NextSibling() const;
williamr@2
   563
williamr@4
   564
	/**
williamr@4
   565
	Gets the owning document 
williamr@4
   566
williamr@4
   567
	Note:  An instance of the RXmlEngDocument class returns itself
williamr@4
   568
williamr@4
   569
	@pre Node must not be NULL.
williamr@4
   570
	@return The document node of the DOM tree that this node belongs to or a
williamr@4
   571
	NULL document if no owning document.
williamr@4
   572
    */
williamr@2
   573
    IMPORT_C RXmlEngDocument OwnerDocument() const;
williamr@2
   574
williamr@2
   575
    /**
williamr@4
   576
	Gets the value of this node.  
williamr@4
   577
    
williamr@4
   578
	Note:  Since this is not a virtual function, it is better to always cast
williamr@4
   579
	nodes to a specific type and then use the specific method for getting the
williamr@4
   580
	"node value".
williamr@4
   581
    
williamr@4
   582
    @return The node value
williamr@4
   583
    */
williamr@2
   584
    IMPORT_C TPtrC8 Value() const;
williamr@2
   585
williamr@4
   586
	/**
williamr@4
   587
	Gets a copy of the node's text content.  What is returned depends on the
williamr@4
   588
	node type.  Any existing content in the specified buffer is destroyed.
williamr@4
   589
	This method allocates memory for the buffer.
williamr@4
   590
    
williamr@4
   591
	@param aOutput A buffer owned by the caller which holds the returned string
williamr@4
   592
	@leave - One of the system-wide error codes
williamr@4
   593
    */
williamr@2
   594
    IMPORT_C void WholeTextContentsCopyL(RBuf8& aOutput) const;
williamr@2
   595
williamr@2
   596
    /**
williamr@4
   597
    Copies the specified string and sets the value of this node.
williamr@4
   598
    @param aValue The value to set
williamr@4
   599
	@leave KXmlEngErrNullNode The node is NULL
williamr@4
   600
	@leave - One of the system-wide error codes
williamr@4
   601
    */
williamr@2
   602
    IMPORT_C void SetValueL(const TDesC8& aValue);
williamr@2
   603
williamr@2
   604
    /**
williamr@4
   605
    Check if the node content is "simple text" for element and attribute nodes.
williamr@4
   606
    
williamr@4
   607
	If the node content is "simple text" then it is represented by a single
williamr@4
   608
	TXmlEngTextNode (or derived type).  The contents can be obtained through a
williamr@4
   609
	call to Value().  A node that has multiple child text nodes does not have
williamr@4
   610
	node content that is "simple text" and the contents must be obtained
williamr@4
   611
	through a call to WholeTextContentsCopyL().
williamr@2
   612
williamr@4
   613
	The contents of TXmlEngComment, TXmlEngCDATASection, TXmlEngTextNode, and
williamr@4
   614
	Processing Instuction data are always "simple".
williamr@4
   615
    
williamr@4
   616
    @see TXmlEngNode::Value()
williamr@4
   617
	@see TXmlEngAttr::Value()
williamr@4
   618
	@see TXmlEngElement::Text()
williamr@4
   619
    @see TXmlEngNode::WholeTextContentsCopyL()
williamr@4
   620
   
williamr@4
   621
	@return ETrue if the node is an element or attribute node and content is
williamr@4
   622
	represented by one TXmlEngTextNode or EFalse otherwise
williamr@4
   623
    */
williamr@4
   624
	IMPORT_C TBool IsSimpleTextContents() const;
williamr@4
   625
williamr@4
   626
	/**
williamr@4
   627
	Gets the node type.  Used to find out the type of the node prior to casting
williamr@4
   628
	the node to one of TXmlEngNode class to one of its derived subclasses
williamr@4
   629
	(TXmlEngElement, TXmlEngAttr, TXmlEngTextNode, etc.).
williamr@4
   630
    
williamr@4
   631
    @see TXmlEngDOMNodeType
williamr@4
   632
	@pre Node must not be NULL
williamr@4
   633
    @return The type of the node
williamr@4
   634
    */
williamr@2
   635
    IMPORT_C TXmlEngDOMNodeType NodeType() const;
williamr@2
   636
williamr@2
   637
    /**
williamr@4
   638
    Gets the node name.
williamr@4
   639
     
williamr@4
   640
    This method generally follows the DOM spec:
williamr@4
   641
    -------------------------------------------------------------------------------
williamr@4
   642
    The values of nodeName, nodeValue, and attributes vary according to the node
williamr@4
   643
    type as follows:
williamr@4
   644
    
williamr@4
   645
    interface              nodeName                nodeValue            attributes
williamr@4
   646
    -------------------------------------------------------------------------------
williamr@4
   647
    Attr                   = Attr.name              = Attr.value             = null
williamr@4
   648
    CDATASection           = "#cdata-section"       = CharacterData.data     = null
williamr@4
   649
    Comment                = "#comment"             = CharacterData.data     = null
williamr@4
   650
    Document               = "#document"            = null                   = null
williamr@4
   651
    DocumentFragment       = "#document-fragment"   = null                   = null
williamr@4
   652
    DocumentType           = DocumentType.name      = null                   = null
williamr@4
   653
    Element                = Element.tagName        = null           = NamedNodeMap
williamr@4
   654
    Entity                 = entity name            = null                   = null
williamr@4
   655
    EntityReference        = name of entity referenced  = null               = null
williamr@4
   656
    Notation               = notation name          = null                   = null
williamr@4
   657
    ProcessingInstruction  = target                 = data                   = null
williamr@4
   658
    Text                   = "#text"                = CharacterData.data     = null
williamr@4
   659
    -------------------------------------------------------------------------------
williamr@4
   660
williamr@4
   661
    @return The name of the node
williamr@4
   662
    */
williamr@2
   663
    IMPORT_C TPtrC8 Name() const;
williamr@2
   664
williamr@2
   665
williamr@2
   666
    /**
williamr@4
   667
    Check if the node has child nodes.
williamr@4
   668
    @return ETrue if the node has child nodes, EFalse otherwise
williamr@4
   669
    */
williamr@2
   670
    IMPORT_C TBool HasChildNodes() const;
williamr@2
   671
williamr@4
   672
	/**
williamr@4
   673
	Check if the node has attributes.  Namespace-to-prefix bindings are not
williamr@4
   674
	considered attributes.
williamr@4
   675
	@return ETrue if the node is an Element node and has at least one
williamr@4
   676
	attribute, EFalse otherwise
williamr@4
   677
    */
williamr@4
   678
	IMPORT_C TBool HasAttributes() const;
williamr@2
   679
williamr@4
   680
	/**
williamr@4
   681
	Evaluates the active base URI for the node by processing the xml:base
williamr@4
   682
	attributes of the parents of the node.  If no xml:base attributes exist,
williamr@4
   683
	an empty string is returned.  Any existing content in the specified buffer
williamr@4
   684
	is destroyed.  This function allocates memory for the buffer.
williamr@4
   685
williamr@4
   686
	@param aBaseUri A buffer owned by the caller that holds the result.
williamr@4
   687
	@leave - One of the system-wide error codes
williamr@4
   688
    */
williamr@2
   689
    IMPORT_C void BaseUriL(RBuf8& aBaseUri) const;
williamr@2
   690
williamr@4
   691
	/**
williamr@4
   692
	Checks if a node is the same as this node.  Nodes are considered the same
williamr@4
   693
	if they refer to the same in-memory data structure.
williamr@4
   694
    
williamr@4
   695
    @param aOther Node to compare
williamr@4
   696
    @return ETrue if the nodes are the same, EFalse otherwise
williamr@4
   697
    */
williamr@2
   698
    inline TBool IsSameNode(TXmlEngNode aOther) const;
williamr@2
   699
williamr@2
   700
    /**
williamr@4
   701
    Gets the namespace URI.
williamr@4
   702
williamr@4
   703
	@return The namespace URI of a TXmlEngNamespace, TXmlEngAttr or
williamr@4
   704
	TXmlEngElement node if bound, NULL in all other cases.
williamr@4
   705
    */
williamr@2
   706
    IMPORT_C TPtrC8 NamespaceUri() const;
williamr@2
   707
williamr@2
   708
    /**
williamr@4
   709
    Gets the namespace prefix.
williamr@4
   710
    
williamr@4
   711
	@return The prefix of an element or attribute node if bound, NULL in all
williamr@4
   712
	other cases.
williamr@4
   713
    */
williamr@4
   714
	IMPORT_C TPtrC8 Prefix() const;
williamr@2
   715
williamr@4
   716
	/**
williamr@4
   717
	Check if the given namespace is the same as the default namespace for this
williamr@4
   718
	node.
williamr@4
   719
williamr@4
   720
	Note:  "" or NULL can be used to denote undefined namespace
williamr@4
   721
    
williamr@4
   722
    @param aNamespaceUri Namespace URI
williamr@4
   723
	@return ETrue if the node is an element node and its default namespace URI is the same as the given namespace URI, EFalse otherwise
williamr@4
   724
	@leave - One of the system-wide error codes
williamr@4
   725
    */
williamr@2
   726
    IMPORT_C TBool IsDefaultNamespaceL(const TDesC8& aNamespaceUri) const;
williamr@2
   727
williamr@4
   728
	/**
williamr@4
   729
	Searches for the prefix bound to the given aNamespaceUri and applicable
williamr@4
   730
	within the scope of this node.
williamr@4
   731
williamr@4
   732
    @see TXmlEngElement::LookupNamespaceByUriL()
williamr@4
   733
    
williamr@4
   734
    @param aNamespaceUri The Namespace URI to search for
williamr@4
   735
williamr@4
   736
    @return The sought prefix or NULL if not found or if aNamespaceUri is the default namespace
williamr@4
   737
    @leave KXmlEngErrNullNode The node is NULL
williamr@4
   738
	@leave - One of the system-wide error codes
williamr@4
   739
    */
williamr@2
   740
    IMPORT_C TPtrC8 LookupPrefixL(const TDesC8& aNamespaceUri) const;
williamr@2
   741
williamr@2
   742
    /**
williamr@4
   743
    Searches for the namespace URI that is bound to the given prefix.
williamr@4
   744
williamr@4
   745
    @see TXmlEngElement::LookupNamespaceByPrefixL(const TDesC8&)
williamr@4
   746
     
williamr@4
   747
    @param aPrefix The namespace prefix to search for
williamr@4
   748
    @return The sought URI or NULL if the prefix is not bound
williamr@4
   749
	@leave KXmlEngErrNullNode The node is NULL
williamr@4
   750
	@leave - One of the system-wide error codes
williamr@4
   751
    */
williamr@2
   752
    IMPORT_C TPtrC8 LookupNamespaceUriL(const TDesC8& aPrefix) const;
williamr@2
   753
williamr@2
   754
protected:
williamr@4
   755
	/**
williamr@4
   756
	Unlinks the node from the double-linked list and relinks any neighbour
williamr@4
   757
	nodes.  Despite being removed from the list, the node retains links to its
williamr@4
   758
	old neighbours!  Use with care!!
williamr@4
   759
    
williamr@4
   760
	No checks are made.  Neither the parent's, nor the node's properties are
williamr@4
   761
	updated.
williamr@4
   762
    */
williamr@4
   763
	void DoUnlinkNode();
williamr@2
   764
williamr@2
   765
    /**
williamr@4
   766
	Inserts this node before the specified node in the double-linked list.
williamr@4
   767
    
williamr@4
   768
	No checks are made.  Neither the parent's, nor the node's properties are
williamr@4
   769
	updated.
williamr@4
   770
    
williamr@4
   771
	@param aNode After insertion, this node will come before aNode in the list
williamr@4
   772
    */
williamr@2
   773
    void LinkBefore(TXmlEngNode aNode);
williamr@2
   774
williamr@2
   775
protected:
williamr@2
   776
	/** Node pointer */
williamr@2
   777
    void* iInternal;
williamr@2
   778
williamr@2
   779
};
williamr@2
   780
williamr@4
   781
#include <xml/dom/xmlengnode.inl>
williamr@2
   782
williamr@4
   783
#endif /* XMLENGNODE_H */
williamr@4
   784