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