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 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
|
williamr@2
|
17 |
|
williamr@2
|
18 |
/**
|
williamr@4
|
19 |
@file
|
williamr@4
|
20 |
@publishedAll
|
williamr@4
|
21 |
@released
|
williamr@4
|
22 |
*/
|
williamr@4
|
23 |
#ifndef XMLENGNAMESPACE_H
|
williamr@4
|
24 |
#define XMLENGNAMESPACE_H
|
williamr@4
|
25 |
|
williamr@4
|
26 |
#include <xml/dom/xmlengnode.h>
|
williamr@4
|
27 |
|
williamr@4
|
28 |
/**
|
williamr@4
|
29 |
This class represents an existing namespace declaration in the DOM tree or a
|
williamr@4
|
30 |
namespace node returned in RXmlEngNodeSet as a result of some XPath expression.
|
williamr@4
|
31 |
|
williamr@4
|
32 |
All elements and attributes may have a namespace instance associated with them.
|
williamr@4
|
33 |
Once added to an element, a namespace declaration (instance of
|
williamr@4
|
34 |
TXmlEngNamespace) may be referred to by all attributes and descendants of the
|
williamr@4
|
35 |
element (unless the prefix that this namespace-to-prefix binding uses is
|
williamr@4
|
36 |
overriden somewhere below in the document tree).
|
williamr@4
|
37 |
|
williamr@4
|
38 |
General rules for namespace handling:
|
williamr@4
|
39 |
|
williamr@4
|
40 |
- A NULL prefix in the namespace node means NO PREFIX. An empty string "" can
|
williamr@4
|
41 |
be used to specify the absence of a prefix when setting it, however, NULL will
|
williamr@4
|
42 |
be stored and returned.
|
williamr@4
|
43 |
|
williamr@4
|
44 |
- A NULL value for a namespace URI is legal only with a NULL prefix and is only
|
williamr@4
|
45 |
used in the undeclaration of a namespace (@c xmlns="" ). An empty string ""
|
williamr@4
|
46 |
can be used too, however, it will be returned as NULL.
|
williamr@4
|
47 |
|
williamr@4
|
48 |
- A NULL or empty string namespace URI with a non-NULL prefix is illegal
|
williamr@4
|
49 |
acording to the XML specification.
|
williamr@4
|
50 |
|
williamr@4
|
51 |
- The namespace of an element is a default namespace if it has a NULL prefix.
|
williamr@4
|
52 |
|
williamr@4
|
53 |
- Elements with namespace undeclarations (@c xmlns="" ), have no namespace and
|
williamr@4
|
54 |
are treated as local names.
|
williamr@4
|
55 |
|
williamr@4
|
56 |
- Attributes do not have a default namespace. Even if a namespace is applied at
|
williamr@4
|
57 |
element scope, the default namespace declaration is not applied to the
|
williamr@4
|
58 |
element's attributes (according to the XML specification).
|
williamr@4
|
59 |
|
williamr@4
|
60 |
- The namespace of a node (element or attribute) is undefined if no namespace
|
williamr@4
|
61 |
declaration is associated with it.
|
williamr@4
|
62 |
|
williamr@4
|
63 |
- A node with an undefined namespace is serialized as having no prefix. In
|
williamr@4
|
64 |
general, the DOM API handles the complexity of namespace declaration handling,
|
williamr@4
|
65 |
creating neccessary namespace declarations and undeclaring default namespaces.
|
williamr@4
|
66 |
However, some node-creation methods (e.g. TXmlEngElement::AddNewElementL()) do
|
williamr@4
|
67 |
not ensure that a node created with an undefined namespace (i.e. without a
|
williamr@4
|
68 |
prefix) will be treated after serialization as having the default namespace.
|
williamr@4
|
69 |
|
williamr@4
|
70 |
Note:
|
williamr@4
|
71 |
Namespace nodes that are the result of XPath expressions have following restrictions:
|
williamr@4
|
72 |
|
williamr@4
|
73 |
- They cannot be used as namespace definitions, because they are not part of
|
williamr@4
|
74 |
the DOM tree, but rather copies of existing namespace definitions.
|
williamr@4
|
75 |
|
williamr@4
|
76 |
- The namespace prefix is not available because it is not mandated by the DOM
|
williamr@4
|
77 |
Level 3 XPath API. So, in returned copies of the DOM tree, namespace prefix
|
williamr@4
|
78 |
strings are not preserved and Prefix() returns NULL.
|
williamr@4
|
79 |
*/
|
williamr@2
|
80 |
class TXmlEngNamespace: public TXmlEngNode
|
williamr@2
|
81 |
{
|
williamr@4
|
82 |
friend class TXmlEngElement;
|
williamr@4
|
83 |
friend class TXmlEngNode;
|
williamr@4
|
84 |
|
williamr@2
|
85 |
public:
|
williamr@4
|
86 |
/** Default constructor */
|
williamr@2
|
87 |
inline TXmlEngNamespace();
|
williamr@2
|
88 |
|
williamr@2
|
89 |
/**
|
williamr@4
|
90 |
Gets the namespace URI
|
williamr@4
|
91 |
@return Namespace URI string or an empty string if the namespace is either
|
williamr@4
|
92 |
NULL or undeclared (@c xmlns="" )
|
williamr@4
|
93 |
*/
|
williamr@2
|
94 |
IMPORT_C TPtrC8 Uri() const;
|
williamr@2
|
95 |
|
williamr@2
|
96 |
/**
|
williamr@4
|
97 |
Gets the namespace prefix.
|
williamr@4
|
98 |
@return The prefix bound in the namespace declaration or an empty string
|
williamr@4
|
99 |
when there is a default namespace or if no binding exists
|
williamr@4
|
100 |
*/
|
williamr@2
|
101 |
IMPORT_C TPtrC8 Prefix() const;
|
williamr@2
|
102 |
|
williamr@2
|
103 |
/**
|
williamr@4
|
104 |
Check if the namespace is default.
|
williamr@4
|
105 |
@return ETrue if the namespace is default (no prefix), EFalse if the
|
williamr@4
|
106 |
namespace is not default (bound to prefix) or the namespace is NULL
|
williamr@4
|
107 |
*/
|
williamr@2
|
108 |
IMPORT_C TBool IsDefault() const;
|
williamr@2
|
109 |
|
williamr@2
|
110 |
/**
|
williamr@4
|
111 |
Check if the namespace is undefined. A node's namespace is undefined if no
|
williamr@4
|
112 |
namespace declaration is associated with it. This is the same as
|
williamr@4
|
113 |
TXmlEngNode::IsNull().
|
williamr@4
|
114 |
@return ETrue if the namespace is undefined, EFalse otherwise
|
williamr@4
|
115 |
*/
|
williamr@2
|
116 |
IMPORT_C TBool IsUndefined() const;
|
williamr@2
|
117 |
|
williamr@2
|
118 |
protected:
|
williamr@2
|
119 |
/**
|
williamr@4
|
120 |
This method is inherited from TXmlEngNode. To prevent its use, no function body
|
williamr@4
|
121 |
has been supplied. The method Uri() should be used instead.
|
williamr@4
|
122 |
|
williamr@4
|
123 |
@see Uri().
|
williamr@4
|
124 |
*/
|
williamr@2
|
125 |
inline TPtrC8 NamespaceUri();
|
williamr@2
|
126 |
|
williamr@2
|
127 |
protected:
|
williamr@2
|
128 |
/**
|
williamr@4
|
129 |
Constructor
|
williamr@4
|
130 |
@param aPtr Namespace pointer
|
williamr@4
|
131 |
*/
|
williamr@2
|
132 |
inline TXmlEngNamespace(void* aPtr);
|
williamr@2
|
133 |
};
|
williamr@2
|
134 |
|
williamr@4
|
135 |
#include <xml/dom/xmlengnamespace.inl>
|
williamr@2
|
136 |
|
williamr@4
|
137 |
#endif /* XMLENGNAMESPACE_H */
|
williamr@2
|
138 |
|