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: Inline functions specyfic for element node
|
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 |
|
williamr@2
|
25 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
26 |
// Default constructor
|
williamr@2
|
27 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
28 |
//
|
williamr@2
|
29 |
inline TXmlEngElement::TXmlEngElement():TXmlEngNode(NULL) {}
|
williamr@2
|
30 |
|
williamr@2
|
31 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
32 |
// Constructor
|
williamr@2
|
33 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
34 |
//
|
williamr@2
|
35 |
inline TXmlEngElement::TXmlEngElement(void* aInternal): TXmlEngNode(aInternal) {}
|
williamr@2
|
36 |
|
williamr@2
|
37 |
|
williamr@2
|
38 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
39 |
// Creates new attribute node using namespace of its parent element (this element),
|
williamr@2
|
40 |
// sets attribute's value and links it as the last attribute of the element
|
williamr@2
|
41 |
//
|
williamr@2
|
42 |
// @param aName - Local name of attribute
|
williamr@2
|
43 |
// @param aValue - Value to set for new attribute or NULL (sets value to "")
|
williamr@2
|
44 |
// @return A handler to the newly created attribute node;
|
williamr@2
|
45 |
//
|
williamr@2
|
46 |
// For more hints how to use it refer to AddNewAttributeL(const TDesC8&,const TDesC8&)
|
williamr@2
|
47 |
//
|
williamr@2
|
48 |
// @note
|
williamr@2
|
49 |
// - No checks are made that attribute with such name exists
|
williamr@2
|
50 |
// - if namespace of the parent element is default (i.e. bound prefix is NULL),
|
williamr@2
|
51 |
// then temporary prefix will be used and bound to the same namespace URI as elements
|
williamr@2
|
52 |
// (It is due to the fact that default namespaces do not spread on unprefixed attributes,
|
williamr@2
|
53 |
// see http://w3.org/TR/REC-xml-names/#defaulting)
|
williamr@2
|
54 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
55 |
//
|
williamr@2
|
56 |
inline TXmlEngAttr TXmlEngElement::AddNewAttributeSameNsL(const TDesC8& aName, const TDesC8& aValue)
|
williamr@2
|
57 |
{
|
williamr@2
|
58 |
return AddNewAttributeL(aName, aValue, NamespaceDeclaration());
|
williamr@2
|
59 |
}
|
williamr@2
|
60 |
|
williamr@2
|
61 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
62 |
// @return Default namespace in the scope of the element
|
williamr@2
|
63 |
//
|
williamr@2
|
64 |
// NULL TXmlEngNamespace means that element with no prefix have no namespace associated
|
williamr@2
|
65 |
// because no default namespace was declared or default namespace was undeclared with <b>xmlns=""</b>
|
williamr@2
|
66 |
//
|
williamr@2
|
67 |
// Equivalent to LookupNamespaceByPrefixL() with NULL (or "") prefix provided
|
williamr@2
|
68 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
69 |
//
|
williamr@2
|
70 |
inline TXmlEngNamespace TXmlEngElement::DefaultNamespaceL() const
|
williamr@2
|
71 |
{
|
williamr@2
|
72 |
return LookupNamespaceByPrefixL(KNullDesC8);
|
williamr@2
|
73 |
}
|
williamr@2
|
74 |
|
williamr@2
|
75 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
76 |
// Specialized version of TXmlEngNode::CopyL()
|
williamr@2
|
77 |
//
|
williamr@2
|
78 |
// @return Deep copy of the element.
|
williamr@2
|
79 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
80 |
//
|
williamr@2
|
81 |
inline TXmlEngElement TXmlEngElement::CopyL() const
|
williamr@2
|
82 |
{return TXmlEngNode::CopyL().AsElement();}
|
williamr@2
|
83 |
|
williamr@2
|
84 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
85 |
// Removes all element contents: child nodes, attributes and namespace declarations
|
williamr@2
|
86 |
//
|
williamr@2
|
87 |
// @see RemoveChildren(), RemoveAttributes(), RemoveNamespaceDeclarations();
|
williamr@2
|
88 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
89 |
//
|
williamr@2
|
90 |
inline void TXmlEngElement::ClearElement()
|
williamr@2
|
91 |
{
|
williamr@2
|
92 |
RemoveChildren();
|
williamr@2
|
93 |
RemoveAttributes();
|
williamr@2
|
94 |
RemoveNamespaceDeclarations();
|
williamr@2
|
95 |
}
|
williamr@2
|
96 |
|
williamr@2
|
97 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
98 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
99 |
//
|
williamr@2
|
100 |
|
williamr@2
|
101 |
|
williamr@2
|
102 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
103 |
// Returns TRUE if the element holds an attribute with such namespace URI and name.
|
williamr@2
|
104 |
//
|
williamr@2
|
105 |
// Same result gives AttributeNodeL(uri,name).NotNull()
|
williamr@2
|
106 |
// -------------------------------------------------------------------------------------
|
williamr@2
|
107 |
//
|
williamr@2
|
108 |
inline TBool TXmlEngElement::HasAttributeL(const TDesC8& aLocalName, const TDesC8& aNamespaceUri) const
|
williamr@2
|
109 |
{return AttributeNodeL(aLocalName, aNamespaceUri).NotNull();}
|
williamr@2
|
110 |
|
williamr@2
|
111 |
|
williamr@2
|
112 |
|
williamr@2
|
113 |
|