epoc32/include/xml/dom/xmlengelement.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/xmlengelement.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* 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
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:       Element node functions
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
#ifndef XMLENGINE_ELEMENT_H_INCLUDED
williamr@2
    25
#define XMLENGINE_ELEMENT_H_INCLUDED
williamr@2
    26
williamr@2
    27
#include "XmlEngAttr.h"
williamr@2
    28
#include "XmlEngNamespace.h"
williamr@2
    29
williamr@2
    30
template<class T> class RXmlEngNodeList;
williamr@2
    31
williamr@2
    32
williamr@2
    33
/**
williamr@2
    34
 * Instance of TXmlEngElement class represents an XML element in the DOM tree.
williamr@2
    35
 *
williamr@2
    36
 * <b>Namespace handling:</b>
williamr@2
    37
 *
williamr@2
    38
 * Namespace of XML element is an URI that in pair with <i>local part</i> of
williamr@2
    39
 * element's name consistute <b>expanded-name</b> of element. It is said that "the element
williamr@2
    40
 * is of <i>NNN</i> namespace".
williamr@2
    41
 *
williamr@2
    42
 * XML elements are shown as belonging to a specific namespace by using <i>prefixes</i>
williamr@2
    43
 * that previously were bound to some namespace URIs. The scope of a prefix is the
williamr@2
    44
 * element, where it was declared and all its child (sub-)elements.
williamr@2
    45
 *      
williamr@2
    46
 * Namespace declaration is created by using special <b>xmlns:<i>{prefix-name}</i></b>
williamr@2
    47
 * attribute (which is not really considered as attribute in DOM):
williamr@2
    48
 * @code 
williamr@2
    49
 *    <a xmlns:pr="http://some.uri.com/"> ... </a>
williamr@2
    50
 * OR
williamr@2
    51
 *    <pr:a xmlns:pr="http://some.uri.com/"> ... </a>
williamr@2
    52
 *    <a xmlns="http://some.uri.com/"> ... </a>
williamr@2
    53
 * @endcode
williamr@2
    54
 *
williamr@2
    55
 * The latter two examples are equivalent and show the use of <i>default namespace</i>.
williamr@2
    56
 *    
williamr@2
    57
 * Implementation notes:
williamr@2
    58
 *	- Element having no namespace is either presented with a NULL TXmlEngNamespace node 
williamr@2
    59
 *    or a TXmlEngNamespace node that has NULL prefix and namespace URI set to "". 
williamr@2
    60
 *    The former is used by default on all nodes, whereas the latter is for cases
williamr@2
    61
 *    when some node contains undeclaration of the default namespace:
williamr@2
    62
 * @code
williamr@2
    63
 *	   <a xmlns=""> .. </a>
williamr@2
    64
 * @endcode
williamr@2
    65
 *
williamr@2
    66
 * - The prefix of the default attribute is NULL, not "" (zero-length string)
williamr@2
    67
 *	 "" corresponds to  
williamr@2
    68
 *   @code
williamr@2
    69
 *       <a xmlns:="http://some.uri.com/"> ... </a>
williamr@2
    70
 *   @endcode
williamr@2
    71
 *   (it does not contradict XML spec, but you are strongly advised against using this)
williamr@2
    72
 *
williamr@2
    73
 * - Prefix <b>"xml"</b> is reserved by XML Namespace spec for special purposes; it is implicitly bound
williamr@2
    74
 *   to XML's namespace <i>"http://www.w3.org/XML/1998/namespace"</i> and no one is allowed
williamr@2
    75
 *   to use this prefix except as with spec-defined elements and attributes or to rebind this 
williamr@2
    76
 *   prefix to other namespaces
williamr@2
    77
 *
williamr@2
    78
 * - Namespace URI may be "" only for default namespace. In other words,
williamr@2
    79
 *   "" namespace URI may not be bound to non-NULL prefix. 
williamr@2
    80
 *          
williamr@2
    81
 *   Declaration of "" namespace with NULL prefix results in:
williamr@2
    82
 *   @code
williamr@2
    83
 *       <a xmlns=""> ... </a>
williamr@2
    84
 *   @endcode
williamr@2
    85
 *   which <i>undeclares</i> any existing (in some parent element) default namespace
williamr@2
    86
 *   for the scope of element 'a': element, its attributes and all child nodes of DOM tree.
williamr@2
    87
 *   Note, that such "undeclaration" will be added only if neccessary. 
williamr@2
    88
 *        
williamr@2
    89
 * - Unneccessary namespace declaration are ignored. Attemps to add namespace binding 
williamr@2
    90
 *   using same namespace URI and prefix if such binding already exists in the scope
williamr@2
    91
 *   will have no effect.
williamr@2
    92
 *
williamr@2
    93
 * - <b>IMPORTANT!</b> Attributes DO NOT HAVE default namespaces. If an attribute has no
williamr@2
    94
 *   prefix, its namespace is <b>undeclared</b> even if there is some default namespaces for
williamr@2
    95
 *   the scope of the element, which contains the attribute.
williamr@2
    96
 *
williamr@2
    97
 * So, it is wrong to write something like this:
williamr@2
    98
 * @code
williamr@2
    99
 *     <a xmlns="ns_uri"  attr="value"> ... </a>
williamr@2
   100
 * @endcode
williamr@2
   101
 * and assume that the <b>attr</b> belongs to namespace pointed to with <i>ns_uri</i>.
williamr@2
   102
 *    
williamr@2
   103
 * <b>HINTS:</b>
williamr@2
   104
 * - Use namespace declaration nodes as much as possible (but watch out prefix collisions).
williamr@2
   105
 * - Add most referred to namespace declarations (AddNamespaceDeclarationL(uri,pref)) after
williamr@2
   106
 *   any other namespace declarations in a element -- the will be found faster in
williamr@2
   107
 *   namespace lookups.
williamr@2
   108
 *
williamr@2
   109
 * @lib XmlEngineDOM.lib
williamr@2
   110
 * @since S60 v3.1
williamr@2
   111
 */
williamr@2
   112
williamr@2
   113
class TXmlEngElement : public TXmlEngNode
williamr@2
   114
{
williamr@2
   115
  public:
williamr@2
   116
    /**
williamr@2
   117
     * Default constructor for automatic variables (not initialized)
williamr@2
   118
	 *
williamr@2
   119
     * @since S60 v3.1
williamr@2
   120
	 */
williamr@2
   121
    inline TXmlEngElement();
williamr@2
   122
williamr@2
   123
    /**
williamr@2
   124
     * Constructor
williamr@2
   125
     *
williamr@2
   126
     * @since S60 v3.1
williamr@2
   127
	 * @param aInternal element pointer
williamr@2
   128
	 */
williamr@2
   129
    inline TXmlEngElement(void* aInternal);
williamr@2
   130
	
williamr@2
   131
    /** 
williamr@2
   132
    *    @name XmlEngine's non-DOM extensions
williamr@2
   133
    */
williamr@2
   134
    /** @{ */
williamr@2
   135
williamr@2
   136
    /**
williamr@2
   137
     *   Retrieves list of attribute nodes of the element
williamr@2
   138
     *   
williamr@2
   139
     *   @param aList - a node list object to initialize
williamr@2
   140
     *
williamr@2
   141
     *   Passed by reference list of nodes is initialized and after call to
williamr@2
   142
     *   Attributes(..) is ready for use with HasNext() and Next() methods:
williamr@2
   143
     *
williamr@2
   144
     *   @code
williamr@2
   145
     *       ...
williamr@2
   146
     *       TXmlEngElement root = doc.DocumentElement();
williamr@2
   147
     *       RXmlEngNodeList<TXmlEngAttr>    attlist;
williamr@2
   148
     *       root.GetAttributes(attlist);
williamr@2
   149
     *       while (attlist.HasNext())
williamr@2
   150
     *           processAttribute(attlist.Next());
williamr@2
   151
     *       ...
williamr@2
   152
	 *       attlist.Close();
williamr@2
   153
     *   @endcode
williamr@2
   154
	 *
williamr@2
   155
     * @since S60 v3.1
williamr@2
   156
	 */
williamr@2
   157
    IMPORT_C void GetAttributes(RXmlEngNodeList<TXmlEngAttr>& aList) const;
williamr@2
   158
williamr@2
   159
    /**
williamr@2
   160
     * Retrieves list of child elements of the element
williamr@2
   161
     *
williamr@2
   162
     * @since S60 v3.1
williamr@2
   163
	 * @param aList - a node list object to initialize
williamr@2
   164
     *
williamr@2
   165
     * Passed by reference list of nodes is initialized and after the call
williamr@2
   166
     * it is ready for use with HasNext() and Next() methods:
williamr@2
   167
     *   
williamr@2
   168
     * @note Returned list is a "filtered view" of the underlying
williamr@2
   169
     *       list of all element's children (with text nodes, comments
williamr@2
   170
     *       processing instructions, etc.)
williamr@2
   171
	 */ 
williamr@2
   172
    IMPORT_C void GetChildElements(RXmlEngNodeList<TXmlEngElement>& aList) const;
williamr@2
   173
williamr@2
   174
    /**
williamr@2
   175
     * Creates new attribute node out of any namespace (i.e. it has no prefix),
williamr@2
   176
     * sets attribute's value and links it as the last attribute of the current element
williamr@2
   177
     *
williamr@2
   178
     * @since S60 v3.1
williamr@2
   179
	 * @param  aName   A local name of attribute
williamr@2
   180
     * @param  aValue  Value to set for new attribute or NULL (sets value to "")
williamr@2
   181
     * @return         A handler to the newly created attribute node;
williamr@2
   182
     *
williamr@2
   183
     * For adding attribute as the first one, use TXmlEngNode::SetAsFirstSibling() on the attribute:
williamr@2
   184
     * @code
williamr@2
   185
     *     TXmlEngElement el = ... ; // get some element
williamr@2
   186
     *     el.AddNewAttributeL("version","0.1").SetAsFirstSibling();
williamr@2
   187
     * @endcode
williamr@2
   188
     *   
williamr@2
   189
     * @see   SetAsLastSibling(), MoveBeforeSibling(TXmlEngNode) and MoveAfterSibling(TXmlEngNode)
williamr@2
   190
     *
williamr@2
   191
     * @note   - No checks are made that attribute with such name exists
williamr@2
   192
     *           Use this method only on newly created elements!
williamr@2
   193
     *           Otherwise, use TXmlEngElement::SetAttributeL(..)
williamr@2
   194
     *         - Attributes do not inherit default namespace of its element
williamr@2
   195
     *           (http://w3.org/TR/REC-xml-names/#defaulting)
williamr@2
   196
     *         - attribute's value is the second argument in all AddNewAttributeL(..) methods
williamr@2
   197
     *         - Use of NULL as value is more preferrable then "" 
williamr@2
   198
	 */
williamr@2
   199
    IMPORT_C TXmlEngAttr AddNewAttributeL(const TDesC8& aName, const TDesC8& aValue);
williamr@2
   200
    
williamr@2
   201
    /**
williamr@2
   202
     * Creates new attribute node and add it to the element
williamr@2
   203
     *
williamr@2
   204
     * Provided handle to namespace declaration is used to set up
williamr@2
   205
     * attribute's namespace.
williamr@2
   206
     *
williamr@2
   207
     * @since S60 v3.1
williamr@2
   208
	 * @param  aName   A local name of attribute
williamr@2
   209
     * @param  aValue  Value to set for new attribute or NULL (sets value to "")
williamr@2
   210
     * @param  aNsDef  Namespace to add to the attribute
williamr@2
   211
     * @return         A handler to the newly created attribute node;
williamr@2
   212
     *
williamr@2
   213
     * @note If aNsDef is not defined in some of attributes ascendants
williamr@2
   214
     *      (including this element), then
williamr@2
   215
     *      ReconcileNamespacesL() method must be called on
williamr@2
   216
     *      this element later.
williamr@2
   217
	 */
williamr@2
   218
    IMPORT_C TXmlEngAttr AddNewAttributeL(const TDesC8& aName,
williamr@2
   219
                                    const TDesC8& aValue, 
williamr@2
   220
                                    const TXmlEngNamespace aNsDef);
williamr@2
   221
williamr@2
   222
    /**
williamr@2
   223
     * Creates new attribute on the element. Namespace declaration for the attribute namespace is
williamr@2
   224
     * created too.
williamr@2
   225
     *
williamr@2
   226
     * @since S60 v3.1
williamr@2
   227
	 * @param  aName   A local name of attribute
williamr@2
   228
     * @param  aValue  Value to set for new attribute or NULL (sets value to "")
williamr@2
   229
     * @param  aNsUri  Namespace uri
williamr@2
   230
     * @param  aPrefix  Namespace prefix
williamr@2
   231
     * @return         A handler to the newly created attribute node;
williamr@2
   232
     *
williamr@2
   233
     * @note
williamr@2
   234
     *    - Namespace declarations are reused if possible (no redundant ones are created)
williamr@2
   235
     */
williamr@2
   236
    IMPORT_C TXmlEngAttr AddNewAttributeL(const TDesC8& aName, 
williamr@2
   237
                                    const TDesC8& aValue,
williamr@2
   238
                                    const TDesC8& aNsUri, 
williamr@2
   239
                                    const TDesC8& aPrefix);
williamr@2
   240
williamr@2
   241
    /**
williamr@2
   242
     * Creates new attribute node using namespace of its parent element (this element),
williamr@2
   243
     * sets attribute's value and links it as the last attribute of the element
williamr@2
   244
     *
williamr@2
   245
     * @since S60 v3.1
williamr@2
   246
	 * @param aName Local name of attribute 
williamr@2
   247
     * @param aValue Value to set for new attribute or NULL (sets value to "")
williamr@2
   248
     * @return A handler to the newly created attribute node;
williamr@2
   249
     *    
williamr@2
   250
     * For more hints how to use it refer to AddNewAttributeL(const TDesC8&,const TDesC8&)
williamr@2
   251
     *        
williamr@2
   252
     * @note    
williamr@2
   253
     *     - No checks are made that attribute with such name exists
williamr@2
   254
     *     - if namespace of the parent element is default (i.e. bound prefix is NULL),
williamr@2
   255
     *       then temporary prefix will be used and bound to the same namespace URI as elements
williamr@2
   256
     *       (It is due to the fact that default namespaces do not spread on unprefixed attributes,
williamr@2
   257
     *       see http://w3.org/TR/REC-xml-names/#defaulting)
williamr@2
   258
     */
williamr@2
   259
    inline   TXmlEngAttr AddNewAttributeSameNsL(const TDesC8& aName, const TDesC8& aValue);
williamr@2
   260
williamr@2
   261
    /**
williamr@2
   262
     * Creates new attributes using namespace, which is bound to the specified prefix
williamr@2
   263
     *
williamr@2
   264
     * @since S60 v3.1
williamr@2
   265
	 * @param  aLocalName   A local name of attribute
williamr@2
   266
     * @param  aValue  Value to set for new attribute or NULL (sets value to "")
williamr@2
   267
     * @param  aPrefix  Namespace prefix for new attribute
williamr@2
   268
     * @return A handler to the newly created attribute node;
williamr@2
   269
     *
williamr@2
   270
     * Use this mothod only for construction of new parts of DOM tree, where
williamr@2
   271
     * you know for sure that prefix is bound in the given scope.
williamr@2
   272
     * @code
williamr@2
   273
     *     TXmlEngElement el = parent.AddNewAttributeUsePrefixL("property","ObjName","rdf");
williamr@2
   274
     *     el.AddNewAttributeUsePrefixL("type", "xs:integer", "rdf");
williamr@2
   275
     * @endcode
williamr@2
   276
     *
williamr@2
   277
     * Otherwise, you should check that prefix is bound like this example shows:
williamr@2
   278
     * @code
williamr@2
   279
     *     TXmlEngNamespace boundNS = TXmlEngNamespace::LookupByPrefix(thisElement, prefix);
williamr@2
   280
     *     if (boundNS.NotNull()){
williamr@2
   281
     *         thisElement.AddNewAttributeUsePrefixL("name", value, prefix);
williamr@2
   282
     *     }
williamr@2
   283
     * @endcode
williamr@2
   284
     *
williamr@2
   285
     * @note
williamr@2
   286
     *     Use AddNewAttributeNsL(name,value,nsDefNode) as much as you can, because
williamr@2
   287
     *     it is most efficient way to create namespaced DOM elements (no additional
williamr@2
   288
     *     lookups for namespace declarations are required).
williamr@2
   289
     *  
williamr@2
   290
     * @code
williamr@2
   291
     *     // If namespace with given URI is not in the scope, then it will be declared
williamr@2
   292
     *     // and bound to "data" prefix.
williamr@2
   293
     *     TXmlEngNamespace nsDef = elem.FindOrCreateNsDefL("http://../Data", "data");
williamr@2
   294
     *     elem.AddNewAttributeL("location", "...", nsDef);
williamr@2
   295
     *     elem.AddNewElementL("child", nsDef).AddNewAttributeL("attr","...value...");
williamr@2
   296
     *     // the result is
williamr@2
   297
     *         ...
williamr@2
   298
     *      <elem xmlns:data="http://../Data" data:location="...">
williamr@2
   299
     *         <data:child attr="...value..."/>
williamr@2
   300
     *      </elem>
williamr@2
   301
     *         ...
williamr@2
   302
     *     //
williamr@2
   303
     * @endcode    
williamr@2
   304
     */
williamr@2
   305
    IMPORT_C TXmlEngAttr AddNewAttributeUsePrefixL(const TDesC8& aLocalName, 
williamr@2
   306
                                             const TDesC8& aValue, 
williamr@2
   307
                                             const TDesC8& aPrefix);
williamr@2
   308
williamr@2
   309
    /**
williamr@2
   310
     * Creates new attributes using namespace in the scope, which has specified URI
williamr@2
   311
     *   
williamr@2
   312
     * Almost the same as AddNewAttributeUsePrefixL(...) but does lookup by namespace URI
williamr@2
   313
     *
williamr@2
   314
     * @since S60 v3.1
williamr@2
   315
	 * @param  aLocalName   A local name of attribute
williamr@2
   316
     * @param  aValue  Value to set for new attribute or NULL (sets value to "")
williamr@2
   317
     * @param  aNsUri  Namespace uri for new attribute
williamr@2
   318
     * @return - NULL attribute if namespace declaration is not found OR newly added to the end of
williamr@2
   319
     *           attribute list attribute of this element.
williamr@2
   320
     *
williamr@2
   321
     * @see AddNewAttributeUsePrefixL(const TDesC8&,const TDesC8&,const TDesC8&)
williamr@2
   322
     */
williamr@2
   323
    IMPORT_C TXmlEngAttr AddNewAttributeWithNsL(const TDesC8& aLocalName, 
williamr@2
   324
                                          const TDesC8& aValue, 
williamr@2
   325
                                          const TDesC8& aNsUri);
williamr@2
   326
                                          
williamr@2
   327
    /**
williamr@2
   328
     * Add attribute to element that will be used as Xml:Id.
williamr@2
   329
     *
williamr@2
   330
     * No check if such attribute exists are made.
williamr@2
   331
     * 
williamr@2
   332
     * @since S60 v3.2
williamr@2
   333
	 * @param aLocalName Name of attribute that should be add.
williamr@2
   334
	 * @param aValue Value of the attribute
williamr@2
   335
	 * @param aNs Namespace of the attribute
williamr@2
   336
	 * @return Attribute if created. Null attribute if Id exist
williamr@2
   337
     *
williamr@2
   338
     * @note Call RXmlEngDocument.RegisterXmlIdL(aName,aNsUri) first
williamr@2
   339
     *       to register existed id's in the document.
williamr@2
   340
     */
williamr@2
   341
    IMPORT_C TXmlEngAttr AddXmlIdL(const TDesC8& aLocalName,
williamr@2
   342
                                       const TDesC8& aValue,
williamr@2
   343
                                       TXmlEngNamespace aNs = TXmlEngNamespace());
williamr@2
   344
    
williamr@2
   345
    /**
williamr@2
   346
     * Adds child element with no namespace
williamr@2
   347
     *
williamr@2
   348
     * @since S60 v3.1
williamr@2
   349
	 * @param aName name of the element
williamr@2
   350
     * @return A handler to the newly created element node;
williamr@2
   351
     *
williamr@2
   352
     * Results in adding element with aName and no prefix.
williamr@2
   353
     *
williamr@2
   354
     * This method is the best for creation of non-namespace based documents
williamr@2
   355
     * or document fragments, where no default namespace declared.
williamr@2
   356
     *
williamr@2
   357
     * It may be used also as a method for adding element from default namespace,
williamr@2
   358
     * BUT namespace will be assigned ONLY after serialization of the current
williamr@2
   359
     * document and parsing it back into a DOM tree!! If you need that default namespace
williamr@2
   360
     * was inherited by new element immediately use:
williamr@2
   361
     * @code
williamr@2
   362
     *    ...
williamr@2
   363
     *    TXmlEngNamespace defns = element.DefaultNamespace();
williamr@2
   364
     *    TXmlEngElement newEl = element.AddNewElementL("Name",defns);
williamr@2
   365
     *    ...
williamr@2
   366
     * @endcode
williamr@2
   367
     *
williamr@2
   368
     * If truly undefined namespace for the element is required, then <b>DO NOT USE</b>
williamr@2
   369
     * this method if there is a default namespace in the scope!
williamr@2
   370
     */
williamr@2
   371
    IMPORT_C TXmlEngElement AddNewElementL(const TDesC8& aName);
williamr@2
   372
williamr@2
   373
    /**
williamr@2
   374
     * Creates new child element with provided name and namespace declaration
williamr@2
   375
     *
williamr@2
   376
     * @since S60 v3.1
williamr@2
   377
	 * @param aLocalName Name of the element
williamr@2
   378
     * @param aNsDecl Handle of the namespace declaration, that must be retrieved from
williamr@2
   379
     *            one of the ascendant nodes of the new elements (and its prefix
williamr@2
   380
     *            should not be remapped to another namespace URI for the scope
williamr@2
   381
     *            of the new element)
williamr@2
   382
     * @return    Created element node (and added as the last child of its parent)
williamr@2
   383
     */
williamr@2
   384
    IMPORT_C TXmlEngElement AddNewElementL(const TDesC8& aLocalName, TXmlEngNamespace aNsDecl);
williamr@2
   385
williamr@2
   386
    /**
williamr@2
   387
     * Creates new child element with provided name, prefix and namespace URI
williamr@2
   388
     *
williamr@2
   389
     * New namespace declaration will be attached to the parent (this) element and used
williamr@2
   390
     * as namespace for newly created child element. If such binding already exists
williamr@2
   391
     * (same prefix is bound to same URI), it will be reused. If the prefix is already
williamr@2
   392
     * bound to some another namespace URI, it will be rebound by the new namespace
williamr@2
   393
     * declaration node.
williamr@2
   394
     *
williamr@2
   395
     * @since S60 v3.1
williamr@2
   396
	 * @param aLocalName Name of the element
williamr@2
   397
     * @param aNsUri     URI of element's namespace
williamr@2
   398
     * @param aPrefix    Prefix of the element
williamr@2
   399
     * @return Created element node (and added as the last child of its parent)
williamr@2
   400
     */
williamr@2
   401
    IMPORT_C TXmlEngElement AddNewElementL(const TDesC8& aLocalName, 
williamr@2
   402
                                     const TDesC8& aNsUri, 
williamr@2
   403
                                     const TDesC8& aPrefix);
williamr@2
   404
williamr@2
   405
    /**
williamr@2
   406
     * Adds child element with same namespace (and prefix if present) as parent element has
williamr@2
   407
     *
williamr@2
   408
     * @since S60 v3.1
williamr@2
   409
	 * @param aLocalName element's name
williamr@2
   410
     * @return New element that was added to the end of children list of its parent (this element)
williamr@2
   411
     */
williamr@2
   412
    IMPORT_C TXmlEngElement AddNewElementSameNsL(const TDesC8& aLocalName);
williamr@2
   413
williamr@2
   414
    /**
williamr@2
   415
     * Performs lookup for the namespace declaration for specified prefix and
williamr@2
   416
     * adds new child element with found namespace.
williamr@2
   417
     *
williamr@2
   418
     * The assumption is that prefix is bound, otherwise run-time error
williamr@2
   419
     * (Symbian's Leave or exception) occurs
williamr@2
   420
     *
williamr@2
   421
     * @note   Use this method only if there is a binding for the given prefix.
williamr@2
   422
     *
williamr@2
   423
     * @since S60 v3.1
williamr@2
   424
	 * @param aLocalName element's name
williamr@2
   425
     * @param aPrefix    prefix to use
williamr@2
   426
     * @return new TXmlEngElement that was added to the end of children list of its parent (this element)
williamr@2
   427
     */
williamr@2
   428
    IMPORT_C TXmlEngElement AddNewElementUsePrefixL(const TDesC8& aLocalName, const TDesC8& aPrefix);
williamr@2
   429
williamr@2
   430
    /**
williamr@2
   431
     * Performs lookup for the namespace declaration for specified namespace URI and
williamr@2
   432
     * adds new child element with found namespace.
williamr@2
   433
     *
williamr@2
   434
     * The assumption is that namespace with given URI was declared,
williamr@2
   435
     * otherwise run-time error (Symbian' Leave or exception) occurs
williamr@2
   436
     * 
williamr@2
   437
     * @note Use this method only if namespace declaration for the provided URI exists.
williamr@2
   438
     *
williamr@2
   439
     * @since S60 v3.1
williamr@2
   440
	 * @param aLocalName    element's name
williamr@2
   441
     * @param aNsUri        namespace of element
williamr@2
   442
     * @return new TXmlEngElement that was added to the end of children list of its parent (this element)
williamr@2
   443
     */
williamr@2
   444
    IMPORT_C TXmlEngElement AddNewElementWithNsL(const TDesC8& aLocalName, const TDesC8& aNsUri);
williamr@2
   445
williamr@2
   446
    /**
williamr@2
   447
     * Creates new child element; if there is no a prefix binding for new element's namespace,
williamr@2
   448
     * a namespace decaration is created with generated prefix at specified element.
williamr@2
   449
     *
williamr@2
   450
     * @since S60 v3.1
williamr@2
   451
	 * @param aLocalName    Name of the element to create
williamr@2
   452
     * @param aNsUri        Namespace URI of the new element
williamr@2
   453
     * @param aNsDeclTarget An element where namespace declaraton should be placed
williamr@2
   454
     *                     if there is a needed to create new namespace declaration;
williamr@2
   455
     *                     NULL is used to specify the created element itself
williamr@2
   456
     *
williamr@2
   457
     * As aNsDeclTarget any ascendant of the new node may be provided:
williamr@2
   458
     * @code
williamr@2
   459
     *     el.AddNewElementAutoPrefixL(tagName,uri,NULL); // declare on the new element
williamr@2
   460
     *     el.AddNewElementAutoPrefixL(tagName,uri,el);   // declare on the parent element
williamr@2
   461
     *     el.AddNewElementAutoPrefixL(tagName,uri,doc.DocumentElement()); // declare on the root element
williamr@2
   462
     *    ...
williamr@2
   463
     * @endcode
williamr@2
   464
     *
williamr@2
   465
     * @note
williamr@2
   466
     *  The farther namespace declaration up in the document tree,
williamr@2
   467
     *  the longer time namespace declaration lookups take.
williamr@2
   468
     */
williamr@2
   469
    IMPORT_C TXmlEngElement AddNewElementAutoPrefixL(const TDesC8& aLocalName, 
williamr@2
   470
                                               const TDesC8& aNsUri, 
williamr@2
   471
                                               TXmlEngElement aNsDeclTarget);
williamr@2
   472
williamr@2
   473
    /**
williamr@2
   474
     * Get element content.
williamr@2
   475
     * This method may be used in most cases, when element has only simple text content
williamr@2
   476
     * (without entity references embedded).
williamr@2
   477
     * If element's contents is mixed (other types of nodes present), only contents of
williamr@2
   478
     * first child node is returned if it is a TXmlEngTextNode node. For getting mixed contents of the
williamr@2
   479
     * element of contents with entity references, WholeTextValueCopyL() should be used.
williamr@2
   480
     *
williamr@2
   481
     * @since S60 v3.1
williamr@2
   482
	 * @return Basic contents of the element
williamr@2
   483
     * 
williamr@2
   484
     * @see TXmlEngNode::WholeTextContentsCopyL()
williamr@2
   485
     */
williamr@2
   486
    IMPORT_C TPtrC8 Text() const;
williamr@2
   487
williamr@2
   488
    /**
williamr@2
   489
     * Adds text as a child of the element.
williamr@2
   490
     *
williamr@2
   491
     * @since S60 v3.1
williamr@2
   492
	 * @param aString text to be added as element's content.
williamr@2
   493
     * 
williamr@2
   494
     * @note There may be several TXmlEngTextNode and TXmlEngEntityReference nodes added actually,
williamr@2
   495
     *   depending on the aString value
williamr@2
   496
     */
williamr@2
   497
    IMPORT_C void  AddTextL(const TDesC8& aString);
williamr@2
   498
williamr@2
   499
    /**
williamr@2
   500
     * Sets text contents for the element.
williamr@2
   501
     * Any child nodes are removed.
williamr@2
   502
     * Same as TXmlEngNode::SetValueL(TDesC8&)
williamr@2
   503
     *
williamr@2
   504
     * @since S60 v3.1
williamr@2
   505
	 * @param aString text to be set as element's content.
williamr@2
   506
     *
williamr@2
   507
     * @see TXmlEngNode::SetValueL(TDesC8&)
williamr@2
   508
     */
williamr@2
   509
    IMPORT_C void  SetTextL(const TDesC8& aString);
williamr@2
   510
williamr@2
   511
    /**
williamr@2
   512
     * Sets text content of the element from escaped string.
williamr@2
   513
     *
williamr@2
   514
     * @since S60 v3.1
williamr@2
   515
	 * @param aEscapedString New value
williamr@2
   516
     *
williamr@2
   517
     * @see TXmlEngAttr::SetEscapedValueL(TDesC8&)
williamr@2
   518
     */
williamr@2
   519
    IMPORT_C void  SetEscapedTextL(const TDesC8& aEscapedString);
williamr@2
   520
    
williamr@2
   521
    /**
williamr@2
   522
     * Sets new element value exactly as presented in the string.
williamr@2
   523
	 * Predefined entities are not converted into characters they represent.
williamr@2
   524
	 * Any child nodes are removed.     
williamr@2
   525
     *
williamr@2
   526
     * @since S60 v3.2
williamr@2
   527
	 * @param aNotEncText New element value
williamr@2
   528
     *
williamr@2
   529
     * @see TXmlEngAttr::SetValueNoEncL(const TDesC8& aNewValue); 
williamr@2
   530
     */    
williamr@2
   531
    IMPORT_C void SetTextNoEncL(const TDesC8& aNotEncString);
williamr@2
   532
williamr@2
   533
    /**
williamr@2
   534
     * Appends new text node with the value exactly as presented in the string.
williamr@2
   535
	 * Predefined entities are not converted into characters they represent.
williamr@2
   536
	 * Existing child nodes are not removed.    
williamr@2
   537
     *
williamr@2
   538
     * @since S60 v3.2
williamr@2
   539
	 * @param aNotEncText Appended element value
williamr@2
   540
     *
williamr@2
   541
     * @see TXmlEngAttr::SetValueNoEncL(const TDesC8& aNewValue); 
williamr@2
   542
     */  
williamr@2
   543
	IMPORT_C void AppendTextNoEncL(const TDesC8& aNotEncString);   
williamr@2
   544
williamr@2
   545
    /**
williamr@2
   546
     * Adds namespace declaration to the current element, a binding of prefix to namespace URI.
williamr@2
   547
     * 
williamr@2
   548
     * If same namespace declaration exists (same prefix and URI), redundant namespace declaration
williamr@2
   549
     * will not be created.
williamr@2
   550
     * 
williamr@2
   551
     * Both NULL or "" (empty string) may be used for "UNDEFINED URI" and "NO PREFIX" values of arguments. 
williamr@2
   552
     *
williamr@2
   553
     * @since S60 v3.1
williamr@2
   554
	 * @param aNsUri Namespace URI
williamr@2
   555
     * @param aPrefix Namespace prefix
williamr@2
   556
     * @return  A handle to the created (or found, if there is such) namespace declaration node.
williamr@2
   557
     *          If namespace undeclaration is being created, NULL handle is returned -- it can be
williamr@2
   558
     *           used in node-creation methods that take namespace handle as an argument.
williamr@2
   559
     * 
williamr@2
   560
     * @note   Undeclaring of default namespace (xmlns="") is supported by
williamr@2
   561
     *         SetNoDefaultNamespace() method
williamr@2
   562
     * 
williamr@2
   563
     * @see SetNoDefaulNamespace()
williamr@2
   564
     * 
williamr@2
   565
     * @note   By adding namespace declaration that rebinds prefix mapping (or default namespace)
williamr@2
   566
     *         used by nodes lower in the tree, document tree may become
williamr@2
   567
     *         wrongly constructed, because references to namespace declaration are
williamr@2
   568
     *         not updated. However, after serialization the document will have
williamr@2
   569
     *         desired structure.
williamr@2
   570
     *         Use this method with care!
williamr@2
   571
     */ 
williamr@2
   572
    IMPORT_C TXmlEngNamespace AddNamespaceDeclarationL(const TDesC8& aNsUri, const TDesC8& aPrefix);
williamr@2
   573
williamr@2
   574
    /**
williamr@2
   575
     * Adds default namespace declaration.
williamr@2
   576
     *
williamr@2
   577
     * @since S60 v3.1
williamr@2
   578
	 * @param aNsUri   Namespace URI;  both NULL and "" (empty string) are allowed to represent UNDEFINED NAMSPACE
williamr@2
   579
     * @return    Handle to the created namespace declaration (NULL for UNDEFINED NAMESPACE)
williamr@2
   580
     *
williamr@2
   581
     * Same result as with AddNamespaceDeclarationL(aNsUri, NULL), but additionally
williamr@2
   582
     * element's namespace modified (if it has no prefix and there were no default
williamr@2
   583
     * namespace declaration in the scope) to the new default one.
williamr@2
   584
     */
williamr@2
   585
    IMPORT_C TXmlEngNamespace SetDefaultNamespaceL(const TDesC8& aNsUri);
williamr@2
   586
williamr@2
   587
    /**
williamr@2
   588
     * Undeclares any default namespace for current element and its descendants.
williamr@2
   589
     * 
williamr@2
   590
     * If there is already some default namespace,  <i>xmlns=""</i> namespace
williamr@2
   591
     * declaration is added. Otherwise, nothing happens, since element with no
williamr@2
   592
     * prefix in such scope is automaticaly considered as out of any namespace.
williamr@2
   593
     * 
williamr@2
   594
     * The side effect of this method is that namespace of the current element
williamr@2
   595
     * may change from previous <b>default</b> namespace to NULL TXmlEngNamespace, which is
williamr@2
   596
     * considered an absence of namespace.
williamr@2
   597
     * 
williamr@2
   598
     * If the element has prefix (i.e. not having default namespace), 
williamr@2
   599
     * then the only effect for the element is undeclaration of existing default namespace. 
williamr@2
   600
     * 
williamr@2
   601
     * If element is in the scope of another <i>xmlns=""</i> undeclaration, no
williamr@2
   602
     * actions are taken.
williamr@2
   603
     * 
williamr@2
   604
     * @note
williamr@2
   605
     *     Use AddNamespaceDeclarationL(NULL,NULL) to force creation of
williamr@2
   606
     *     xmlns=""  declaration within scope of another such declaration 
williamr@2
   607
     *     (otherwise unneccessary/duplicate declarations are not created)
williamr@2
   608
     * 
williamr@2
   609
     * @note
williamr@2
   610
     *     This method should be called on elements before adding children,
williamr@2
   611
     *     because default namespace undeclaration is not spread into its subtree and 
williamr@2
   612
     *     descedants' default namespaces are not reset to NULL. This should be taken into 
williamr@2
   613
     *     account if later some processing on the subtree occurs.
williamr@2
   614
     *     However, after serialization and deserialization, undeclared default namespace will
williamr@2
   615
     *     affect whole element's subtree correctly.
williamr@2
   616
     *
williamr@2
   617
     * @since S60 v3.1
williamr@2
   618
	 */
williamr@2
   619
    IMPORT_C void SetNoDefaultNamespaceL();
williamr@2
   620
williamr@2
   621
    /**
williamr@2
   622
     * Finds namespace declaration that has specific prefix in the scope for given node
williamr@2
   623
     *
williamr@2
   624
     * Prefix "" or NULL are considered the same, meaning "<b>NO PREFIX</b>".
williamr@2
   625
     * If namespace declaration for "no prefix" is searched, then default namespace is returned. 
williamr@2
   626
     *
williamr@2
   627
     * @since S60 v3.1
williamr@2
   628
	 * @param aPrefix Namespace prefix
williamr@2
   629
     * @return Namespace handler, which may be NULL if prefix is not bound.
williamr@2
   630
     * 
williamr@2
   631
     * NULL result for "no prefix" means that default namespace is undefined.
williamr@2
   632
     */
williamr@2
   633
    IMPORT_C TXmlEngNamespace LookupNamespaceByPrefixL(const TDesC8& aPrefix) const;
williamr@2
   634
williamr@2
   635
    /**
williamr@2
   636
     * Finds namespace declaration that has specific namespace URI
williamr@2
   637
     * in the scope for the given node.
williamr@2
   638
     *
williamr@2
   639
     * @since S60 v3.1
williamr@2
   640
	 * @param aUri  Namespace URI, for which namespace declaration is searched
williamr@2
   641
     * @return Handler to the namespace declaration that binds given namespace URI to some prefix 
williamr@2
   642
     *          or sets it a default namespace.
williamr@2
   643
     * 
williamr@2
   644
     * NULL value of aUri is equivalent to "" and means "<b>UNDEFINED NAMESPACE</b>". 
williamr@2
   645
     * For such URI  a NULL namespace handle is always returned even if there is
williamr@2
   646
     * namespace undeclaration, which has "" URI (and NULL prefix).
williamr@2
   647
     * 
williamr@2
   648
     * <b>Hint:</b><p>
williamr@2
   649
     * Use returned instance of TXmlEngNamespace as aNsDef argument to element's methods
williamr@2
   650
     * that create new element's child elements and attributes. The same handler
williamr@2
   651
     * may be used on more deep descentants of the reference element (and doing
williamr@2
   652
     * this way will generally increase performance of DOM tree construction).<br />
williamr@2
   653
     * <span class="color:red;">However</span>, if namespace bindings are not controlled
williamr@2
   654
     * for element's children and prefix, which is bound to the search namespace, is
williamr@2
   655
     * rebound to some other namespace URI, then reusing namespace may lead to
williamr@2
   656
     * unwanted result.
williamr@2
   657
     * 
williamr@2
   658
     * Consider an example:
williamr@2
   659
     * @code
williamr@2
   660
     *     TXmlEngElement root = doc.DocumentElement();
williamr@2
   661
     *     TXmlEngNamespace targetNs = root.AddNamespaceDeclarationL("http://example.com/","ex");
williamr@2
   662
     *     TXmlEngElement el_1 = root.AddNewElementL("outer", targetNs);
williamr@2
   663
     *     TXmlEngElement el_2 = el_1.AddNewElementL("inner"); // element without prefix
williamr@2
   664
     * 
williamr@2
   665
     *     // NOTE: prefix "ex" is not bound to "http://example.com/" anymore!
williamr@2
   666
     *     el_2.AddNamespaceDeclarationL("http://whatever.com/","ex");
williamr@2
   667
     *     TXmlEngElement el_3 = el_2.AddNewElementL("problem", targetNs);
williamr@2
   668
     *     ...
williamr@2
   669
     * @endcode
williamr@2
   670
     * 
williamr@2
   671
     * The sought result was (showing expanded names of elements):
williamr@2
   672
     * @code
williamr@2
   673
     *     --> "root"
williamr@2
   674
     *         --> {"http://example.com/","outer"}
williamr@2
   675
     *         --> "inner"
williamr@2
   676
     *             -->{"http://example.com/","problem"}
williamr@2
   677
     *                 ...
williamr@2
   678
     *             <--
williamr@2
   679
     *         <-- "inner"
williamr@2
   680
     *         <-- {"http://example.com/","outer"}
williamr@2
   681
     *         ...
williamr@2
   682
     *     <-- </root>
williamr@2
   683
     * @endcode
williamr@2
   684
     * and it may look that it has been achieved. Indeed, if namespace of element "problem"
williamr@2
   685
     * was queried, it would have URI "http://example.com/" and prefix "ex".
williamr@2
   686
     * However, if namespace URI was looked up by "problem"'s prefix, it would be
williamr@2
   687
     * "http://whatever.com/". We have created illegal DOM tree.
williamr@2
   688
     * 
williamr@2
   689
     * The actual DOM tree in serialized form will be:
williamr@2
   690
     * @code
williamr@2
   691
     *     <root>
williamr@2
   692
     *         <ex:outer xmlns:ex="http://example.com/">
williamr@2
   693
     *             <inner xmlns:ex="http://whatever.com/">
williamr@2
   694
     *                 <ex:problem>
williamr@2
   695
     *                 ...
williamr@2
   696
     *                 </ex:problem>
williamr@2
   697
     *             </inner>
williamr@2
   698
     *         </ex:outer>
williamr@2
   699
     *         ...
williamr@2
   700
     *     </root>
williamr@2
   701
     * @endcode
williamr@2
   702
     * 
williamr@2
   703
     * So, reuse of namespace handlers should be performed with special care.
williamr@2
   704
     * 
williamr@2
   705
     * @note
williamr@2
   706
     * At the moment it is possible to retrieve namespace declaration nodes
williamr@2
   707
     * whose prefixes were rebound. Be careful when use returned TXmlEngNamespace object
williamr@2
   708
     * for creation of new elements. In later releases, this method will perform
williamr@2
   709
     * safe lookup. And so far, it is better to make check that prefix of returned
williamr@2
   710
     * namespace declaration has not rebound:
williamr@2
   711
     * @code
williamr@2
   712
     *     TXmlEngNamespace ns = element.LookupNamespaceByUri("a_uri");
williamr@2
   713
     *     if (element.LookupNamespaceByPrefix(ns.Prefix()).IsSameNode(ns)){
williamr@2
   714
     *         ... // now it is safe to create new elements by using "ns"
williamr@2
   715
     *         element.AddNewElementL("product",ns);
williamr@2
   716
     *         ...
williamr@2
   717
     *     }
williamr@2
   718
     * @endcode
williamr@2
   719
     */
williamr@2
   720
    IMPORT_C TXmlEngNamespace LookupNamespaceByUriL(const TDesC8& aUri) const;
williamr@2
   721
williamr@2
   722
    /**
williamr@2
   723
     * Retrieves implicitly declared on every XML infoset binding
williamr@2
   724
     * of 'xml' prefix to XML's namespace URI:
williamr@2
   725
     * "http://www.w3.org/XML/1998/namespace"
williamr@2
   726
     *
williamr@2
   727
     * @since S60 v3.1
williamr@2
   728
	 * @return Handler to {xml,"http://www.w3.org/XML/1998/namespace"} prefix
williamr@2
   729
     *            binding in the current document
williamr@2
   730
     *
williamr@2
   731
     * The result should be used for creating attributes beloging to the XML namespace
williamr@2
   732
     * (xml:lang, xml:space, xml:id , etc.)
williamr@2
   733
     *
williamr@2
   734
     * DO NOT USE methods LookupNamespaceByUriL(const TDesC8&) and LookupNamespaceByPrefixL(const TDesC8&)
williamr@2
   735
     * (with "http://www.w3.org/XML/1998/namespace" and "xml" arguments) for retrieving
williamr@2
   736
     * namespace node, since in a case of [possible] memory allocation fault
williamr@2
   737
     * NULL result is returned (and breaks your program silently)
williamr@2
   738
     * 
williamr@2
   739
     * @note   Normally 'xml' prefix is bound to XML namespace URI in the document
williamr@2
   740
     *        node, BUT if current node is not a part of the document tree yet,
williamr@2
   741
     *        the requested namespace declaration WILL BE ADDED to the current node.
williamr@2
   742
     *        This is the reason why the method may fail in OOM conditions.
williamr@2
   743
     */
williamr@2
   744
    IMPORT_C TXmlEngNamespace TheXMLNamespaceL() const;
williamr@2
   745
williamr@2
   746
    /**
williamr@2
   747
     * Get default namespace for element.
williamr@2
   748
     *
williamr@2
   749
     * @since S60 v3.1
williamr@2
   750
	 * @return Default namespace in the scope of the element
williamr@2
   751
     *
williamr@2
   752
     * NULL TXmlEngNamespace means that element with no prefix have no namespace associated
williamr@2
   753
     * because no default namespace was declared or default namespace was undeclared with <b>xmlns=""</b>
williamr@2
   754
     *
williamr@2
   755
     * Equivalent to LookupNamespaceByPrefixL(const TDesC8&) with NULL (or "") prefix provided
williamr@2
   756
     */
williamr@2
   757
    inline   TXmlEngNamespace DefaultNamespaceL() const;
williamr@2
   758
williamr@2
   759
    /**
williamr@2
   760
     * Performs search of namespace handler in the scope of the element. This method will
williamr@2
   761
     * create new namespace declaration on the element if such namespace is not available.
williamr@2
   762
     *
williamr@2
   763
     * @since S60 v3.1
williamr@2
   764
	 * @param aNsUri   Searched namespace
williamr@2
   765
     * @param aPrefix  Prefix to use for <b>new</b> namespace declaration (if it is to be created)
williamr@2
   766
     * @return    TXmlEngNamespace handler that may be used to create new attributes and child elements of
williamr@2
   767
     *            the element. The namespace may be one of those existed previously or was created
williamr@2
   768
     *
williamr@2
   769
     * @note
williamr@2
   770
     *    Be sure not to use the result of this method for non-descendants of the element or in situations
williamr@2
   771
     *    when prefix overlapping might occur (read also about general general considerations of attributes
williamr@2
   772
     *    and elements creation using namespace handlers)
williamr@2
   773
     */
williamr@2
   774
    IMPORT_C TXmlEngNamespace FindOrCreateNsDeclL(const TDesC8& aNsUri, const TDesC8& aPrefix);
williamr@2
   775
williamr@2
   776
    /**
williamr@2
   777
     * Performs search on the element and its ascendants for any namespace declaration
williamr@2
   778
     * with given URI and create a new namespace declaration with some (unique) prefix
williamr@2
   779
     * if the search was not successful.
williamr@2
   780
     *
williamr@2
   781
     * @since S60 v3.1
williamr@2
   782
	 * @param aNsUri   Searched namespace
williamr@2
   783
     * @return    TXmlEngNamespace handler that may be used to create new attributes and child elements of
williamr@2
   784
     *            the element. The namespace may be one of those existed previously or was created
williamr@2
   785
     */
williamr@2
   786
    IMPORT_C TXmlEngNamespace FindOrCreateNsDeclL(const TDesC8& aNsUri);
williamr@2
   787
williamr@2
   788
    /**
williamr@2
   789
     * Checks whether a prefix has been bound in this element (not in one of its ascendants)
williamr@2
   790
     * 
williamr@2
   791
     * Use this method for preventig prefix-name collision in a element node
williamr@2
   792
     *
williamr@2
   793
     * @since S60 v3.1
williamr@2
   794
	 * @param aPrefix Namespace prefix
williamr@2
   795
     * @return TRUE if there is already namespace declaration that uses aPrefix on this element
williamr@2
   796
     */
williamr@2
   797
    IMPORT_C TBool HasNsDeclarationForPrefixL(const TDesC8& aPrefix) const;
williamr@2
   798
    
williamr@2
   799
    /**
williamr@2
   800
     * Copies the element with its attributes, but not child nodes
williamr@2
   801
     * 
williamr@2
   802
     * If context is preserved, then all namespace declarations that are in the element are
williamr@2
   803
     * writen to element's start tag too.
williamr@2
   804
     *
williamr@2
   805
     * @since S60 v3.1
williamr@2
   806
	 * @param preserveNsContext TRUE if context should be preserved
williamr@2
   807
     * @return handle to copy of element
williamr@2
   808
     */
williamr@2
   809
    IMPORT_C TXmlEngElement ElementCopyNoChildrenL(TBool preserveNsContext) const;
williamr@2
   810
    
williamr@2
   811
    /**
williamr@2
   812
     * Specialized version of TXmlEngNode::CopyL()
williamr@2
   813
     *
williamr@2
   814
     * @since S60 v3.1
williamr@2
   815
	 * @return Deep copy of the element.
williamr@2
   816
     */
williamr@2
   817
    inline   TXmlEngElement CopyL() const;
williamr@2
   818
williamr@2
   819
    /**
williamr@2
   820
     * Resets element's content: all child nodes are removed
williamr@2
   821
     *
williamr@2
   822
     * @since S60 v3.1
williamr@2
   823
	 */
williamr@2
   824
    IMPORT_C void RemoveChildren();
williamr@2
   825
williamr@2
   826
    /**
williamr@2
   827
     * Resets element's attributes
williamr@2
   828
     *
williamr@2
   829
     * @since S60 v3.1
williamr@2
   830
	 */
williamr@2
   831
    IMPORT_C void RemoveAttributes();
williamr@2
   832
williamr@2
   833
    /**
williamr@2
   834
     * Resets all namespace declarations made in the element
williamr@2
   835
     * 
williamr@2
   836
     * @note There can be references to these namespace declaration from elsewhere!
williamr@2
   837
     *      Use ReconcileNamespacesL() to fix that.
williamr@2
   838
     *
williamr@2
   839
     * @since S60 v3.1
williamr@2
   840
	 */
williamr@2
   841
    IMPORT_C void RemoveNamespaceDeclarations();
williamr@2
   842
williamr@2
   843
    /**
williamr@2
   844
     * Removes all element contents: child nodes, attributes and namespace declarations
williamr@2
   845
     *
williamr@2
   846
     * @see RemoveChildren(), RemoveAttributes(), RemoveNamespaceDeclarations();
williamr@2
   847
     *
williamr@2
   848
     * @since S60 v3.1
williamr@2
   849
	 */
williamr@2
   850
    inline   void ClearElement();
williamr@2
   851
williamr@2
   852
    /**
williamr@2
   853
     * Copies attributes from another element
williamr@2
   854
     *
williamr@2
   855
     * It may be a very convenient method for initializing element with a set of predefined attributes.
williamr@2
   856
     *
williamr@2
   857
     * @since S60 v3.1
williamr@2
   858
	 * @param aSrc source element
williamr@2
   859
     * 
williamr@2
   860
     * @note
williamr@2
   861
     *  Namespaces of the this element may need to be reconciled if copied attributes
williamr@2
   862
     *  belong to any namespace that is not declared on some ascendant of this node.
williamr@2
   863
     * @see ReconcileNamespacesL()
williamr@2
   864
     */  
williamr@2
   865
    IMPORT_C void CopyAttributesL(TXmlEngElement aSrc);
williamr@2
   866
williamr@2
   867
    /**
williamr@2
   868
     * Copies a list of elements.
williamr@2
   869
     *
williamr@2
   870
     * Elements are appended to the element's children list.
williamr@2
   871
     *
williamr@2
   872
     * @since S60 v3.1
williamr@2
   873
	 * @param aSrc source element
williamr@2
   874
     *
williamr@2
   875
     * @note Namespaces of the this element may need to be reconciled after copy operation
williamr@2
   876
     * @see  ReconcileNamespacesL()
williamr@2
   877
     */
williamr@2
   878
    IMPORT_C void CopyChildrenL(TXmlEngElement aSrc);
williamr@2
   879
williamr@2
   880
    /**
williamr@2
   881
     * Removes attribute with given name and namespace URI(if such exists).
williamr@2
   882
     * Memory allocated for the attribute is freed.
williamr@2
   883
     *
williamr@2
   884
     * @since S60 v3.1
williamr@2
   885
	 * @param aLocalName Element name
williamr@2
   886
     * @param aNamespaceUri Element namespace
williamr@2
   887
     */
williamr@2
   888
    IMPORT_C void RemoveChildElementsL(const TDesC8& aLocalName,const TDesC8& aNamespaceUri);
williamr@2
   889
williamr@2
   890
    /** @} */
williamr@2
   891
williamr@2
   892
    /** 
williamr@2
   893
    *    @name DOM Level 3 Core methods
williamr@2
   894
    *
williamr@2
   895
    *    @note
williamr@2
   896
    *        Most methods of DOM spec operate with fully-qualified names (QNames)
williamr@2
   897
    *        of elements and attributes. It is different in this API - all methods
williamr@2
   898
    *        instead accept prefix and localName parts of QName.
williamr@2
   899
    */
williamr@2
   900
    /** @{ */
williamr@2
   901
    
williamr@2
   902
    /**
williamr@2
   903
     * Returns value of attribute with given name and namespace URI
williamr@2
   904
     *
williamr@2
   905
     * @since S60 v3.1
williamr@2
   906
	 * @param aLocalName Local name of attribute node
williamr@2
   907
     * @param aNamespaceUri Namespace URI of attribute
williamr@2
   908
     * @return Attribute value
williamr@2
   909
     */
williamr@2
   910
    IMPORT_C TPtrC8 AttributeValueL(const TDesC8& aLocalName, 
williamr@2
   911
                                    const TDesC8& aNamespaceUri = KNullDesC8) const;
williamr@2
   912
williamr@2
   913
    /**
williamr@2
   914
     * Initializes list of child elements with matching name and namespace URI.
williamr@2
   915
     *
williamr@2
   916
     * @since S60 v3.1
williamr@2
   917
	 * @param aList Node list to be initialized
williamr@2
   918
     * @param aLocalName Element name
williamr@2
   919
     * @param aNamespaceUri Namespace URI, default is NULL
williamr@2
   920
     *
williamr@2
   921
     * @note This method does not lists all descedants of the element, only child elements
williamr@2
   922
     */
williamr@2
   923
    IMPORT_C void  GetElementsByTagNameL(RXmlEngNodeList<TXmlEngElement>& aList, 
williamr@2
   924
                                         const TDesC8& aLocalName, 
williamr@2
   925
                                         const TDesC8& aNamespaceUri = KNullDesC8) const;
williamr@2
   926
    
williamr@2
   927
    /**
williamr@2
   928
     * Sets value of attribute; attribute is created if there is no such attribute yet
williamr@2
   929
     *
williamr@2
   930
     * @since S60 v3.1
williamr@2
   931
	 * @param aLocalName Attribute name
williamr@2
   932
     * @param aValue Attribute value
williamr@2
   933
     * @param aNamespaceUri Namespace URI - default is NULL
williamr@2
   934
     * @param aPrefix Namespace prefix - default is NULL
williamr@2
   935
     *
williamr@2
   936
     * @note
williamr@2
   937
     *  If prefix is not NULL (or ""), then namespace URI may not be empty
williamr@2
   938
     *  see http://www.w3.org/TR/REC-xml-names/#ns-decl (Definition #3)
williamr@2
   939
     */
williamr@2
   940
    IMPORT_C void  SetAttributeL(const TDesC8& aLocalName, 
williamr@2
   941
                                 const TDesC8& aValue, 
williamr@2
   942
                                 const TDesC8& aNamespaceUri = KNullDesC8, 
williamr@2
   943
                                 const TDesC8& aPrefix = KNullDesC8);
williamr@2
   944
williamr@2
   945
    /**
williamr@2
   946
     * Removes attribute with given name and namespace URI(if such exists).
williamr@2
   947
     * Memory allocated for the attribute is freed.
williamr@2
   948
     *
williamr@2
   949
     * @since S60 v3.1
williamr@2
   950
	 * @param aLocalName Name of the attribute
williamr@2
   951
     * @param aNamespaceUri Attribute namespace URI, default is NULL
williamr@2
   952
     */
williamr@2
   953
    IMPORT_C void  RemoveAttributeL(const TDesC8& aLocalName, 
williamr@2
   954
                                    const TDesC8& aNamespaceUri = KNullDesC8);
williamr@2
   955
williamr@2
   956
    /**
williamr@2
   957
     * Retrieves attribute node from specific namespace by its name.
williamr@2
   958
     *
williamr@2
   959
     * @since S60 v3.1
williamr@2
   960
	 * @param aLocalName Name of the attribute
williamr@2
   961
     * @param aNamespaceUri Attribute namespace URI, default is NULL
williamr@2
   962
     * @return Attribute node with matching namespace URI and name
williamr@2
   963
     */
williamr@2
   964
    IMPORT_C TXmlEngAttr AttributeNodeL(const TDesC8& aLocalName, 
williamr@2
   965
                                  const TDesC8& aNamespaceUri = KNullDesC8) const;
williamr@2
   966
williamr@2
   967
    /**
williamr@2
   968
     * Check if element has attribute with given parameters.
williamr@2
   969
     *
williamr@2
   970
     * @since S60 v3.1
williamr@2
   971
	 * @param aLocalName Name of attribute
williamr@2
   972
     * @param aNamespaceUri Namespace uri, default is NULL.
williamr@2
   973
     * @return TRUE if the element holds an attribute with such namespace URI and name.
williamr@2
   974
     *
williamr@2
   975
     * Same result gives AttributeNodeL(uri,name).NotNull()
williamr@2
   976
     */
williamr@2
   977
    inline     TBool HasAttributeL(const TDesC8& aLocalName, 
williamr@2
   978
                                   const TDesC8& aNamespaceUri  = KNullDesC8) const;
williamr@2
   979
williamr@2
   980
    /**
williamr@2
   981
     * Links attribute into tree
williamr@2
   982
     *
williamr@2
   983
     * @since S60 v3.1
williamr@2
   984
	 * @param aNewAttr new attribute
williamr@2
   985
     * 
williamr@2
   986
     * The replaced attribute node is not returned and just deleted
williamr@2
   987
     */
williamr@2
   988
    IMPORT_C void  SetAttributeNodeL(TXmlEngAttr aNewAttr);
williamr@2
   989
};
williamr@2
   990
williamr@2
   991
williamr@2
   992
williamr@2
   993
#include "xmlengelement.inl"
williamr@2
   994
williamr@2
   995
#endif /* XMLENGINE_ELEMENT_H_INCLUDED */