|
1 /* |
|
2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
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 |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Namespace node functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #ifndef XMLENGINE_NAMESPACE_H_INCLUDED |
|
25 #define XMLENGINE_NAMESPACE_H_INCLUDED |
|
26 |
|
27 #include "xmlengnode.h" |
|
28 |
|
29 /** |
|
30 * Represents existing namespace declaration in DOM tree <b>OR</b> namespace node returned |
|
31 * in RXmlEngNodeSet as a result of some XPath expression. |
|
32 * |
|
33 * All elements and attributes may have a namespace instance associated. |
|
34 * Once put in element, a namespace declaration (instance of TXmlEngNamespace) may be |
|
35 * referred to by all attributes and descentants of the element (unless |
|
36 * prefix that this namespace-to-prefix binding uses is overriden somewhere below in the document tree) |
|
37 * |
|
38 * <b>General rules of namespace handling:</b> |
|
39 * |
|
40 * - <b>NULL</b> prefix in namespace node means NO PREFIX. ""(empty string '\\0') can be used for specifying |
|
41 * absense of prefix when setting it, however <b>NULL</b> will be stored and returned. |
|
42 * |
|
43 * - <b>NULL</b> value of namespace URI is legal only with <b>NULL</b> prefix and only met in |
|
44 * undeclaration of namespace (<i>xmlns=""</i>). <b>""</b> (empty string) can be used too, however it |
|
45 * will be returned as <b>NULL</b>. |
|
46 * |
|
47 * - <b>NULL</b> or <b>""</b> namespace <b>URI</b> with non-<b>NULL</b> prefix is illegal acording to the XML specification. |
|
48 * |
|
49 * - Namespace of a element is <b>default</b> if it is associated with some namespace declaration with <b>NULL</b> prefix. |
|
50 * |
|
51 * - Elements are never associated with namespace undeclarations (<b>xmlns=""</b>), instead, such elements have no |
|
52 * namespace declaration referred to. |
|
53 * |
|
54 * - Attributes do not have <i>default</i> namespace. Even if it is effective at element scope, |
|
55 * default namespace declaration is not applied to element's attributes (according to the XML specification) |
|
56 * |
|
57 * - Namespace of a node (element or attribute) is <b>undefined</b> if no namespace declaration is |
|
58 * associated with it. |
|
59 * |
|
60 * - Node with <i>undefined</i> namespace is serialized as having no prefix. In general, |
|
61 * DOM API handles the complexity of namespace declaration handling and creates neccessary |
|
62 * namespace declarations and undeclares default namespace. However, some node-creation methods (e.g. TXmlEngElement::AddNewElementL()) |
|
63 * do not ensure that created node with undefined namespace (thus, without a prefix) will |
|
64 * actually treated after serialization as having some <i>default</i> namespace |
|
65 * |
|
66 * @note |
|
67 * Namespace nodes that are result of XPath expression have following restrictions: |
|
68 * - they cannot be used as namespace definitions, because they are not part of |
|
69 * the DOM tree, but copies of existing namespace definitions. |
|
70 * - namespace prefix is not available because it is not mandated by DOM Level 3 XPath module API, |
|
71 * so in returned copies of DOM tree, namespaces prefix strings are not preserved |
|
72 * and Prefix() returns NULL. |
|
73 * |
|
74 * @lib XmlEngineDOM.lib |
|
75 * @since S60 v3.1 |
|
76 */ |
|
77 class TXmlEngNamespace: public TXmlEngNode |
|
78 { |
|
79 public: |
|
80 /** |
|
81 * Default constructor |
|
82 * |
|
83 * @since S60 v3.1 |
|
84 */ |
|
85 inline TXmlEngNamespace(); |
|
86 |
|
87 /** |
|
88 /** |
|
89 * Get namespace URI |
|
90 * |
|
91 * @since S60 v3.1 |
|
92 * @return Namespace URI string |
|
93 * @note "" is never returned - it is replaced with NULL |
|
94 * |
|
95 * For TXmlEngNamespace(NULL) or namespace undeclaration (xmlns=""), which are |
|
96 * treatet as <i>undefined namespace</i> returns NULL, |
|
97 * otherwise result is not a NULL string and not a "" (empty string). |
|
98 */ |
|
99 IMPORT_C TPtrC8 Uri() const; |
|
100 |
|
101 /** |
|
102 * Get namespace prefix. |
|
103 * |
|
104 * @since S60 v3.1 |
|
105 * @return prefix that is bound in the namespace declaration |
|
106 * or NULL string for default namespace or if no binding exist |
|
107 */ |
|
108 IMPORT_C TPtrC8 Prefix() const; |
|
109 |
|
110 /** |
|
111 * Check if namespace is default. |
|
112 * |
|
113 * @since S60 v3.1 |
|
114 * @return Whether it is a definition of default namespace |
|
115 * TRUE -- is a default namespace (no prefix) |
|
116 * FALSE -- not a default namespace (bound to prefix) or empty TXmlEngNamespace(NULL) instance |
|
117 */ |
|
118 IMPORT_C TBool IsDefault() const; |
|
119 |
|
120 /** |
|
121 * Check if namespace is undefined |
|
122 * |
|
123 * @since S60 v3.1 |
|
124 * @return Whether the namespace is undefined |
|
125 * |
|
126 * A node's namespace is undefined if no namespace declaration associated with it. |
|
127 * @note Same as TXmlEngNode::IsNull() |
|
128 */ |
|
129 IMPORT_C TBool IsUndefined() const; |
|
130 |
|
131 protected: |
|
132 /** |
|
133 * Workaround to avoid misuse of TXmlEngNode::NamespaceUri() method, which should not be |
|
134 * applied to TXmlEngNamespace node. Since the name of the inherited method from TXmlEngNode |
|
135 * is too similar to TXmlEngNamespace::Uri(), NamespaceUri() is disabled for direct |
|
136 * use. |
|
137 * If NamespaceUri() is called on the TXmlEngNamespace object that is downcasted to TXmlEngNode, then |
|
138 * NamespaceUri()'s result equals to result of Uri() method. |
|
139 * |
|
140 * @since S60 v3.1 |
|
141 * @return NULL |
|
142 */ |
|
143 inline TPtrC8 NamespaceUri(); |
|
144 |
|
145 protected: |
|
146 /** |
|
147 * Constructor |
|
148 * |
|
149 * @since S60 v3.1 |
|
150 * @param aPtr Namespace pointer |
|
151 */ |
|
152 inline TXmlEngNamespace(void* aPtr); |
|
153 |
|
154 friend class TXmlEngElement; |
|
155 friend class TXmlEngNode; |
|
156 }; |
|
157 |
|
158 #include "xmlengnamespace.inl" |
|
159 |
|
160 #endif /* XMLENGINE_NAMESPACE_H_INCLUDED */ |
|
161 |