|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <xml/dom/xmlengnamespace.h> |
|
17 #include <stdapis/libxml2/libxml2_tree.h> |
|
18 #include "xmlengdomdefs.h" |
|
19 #include <xml/utils/xmlengxestrings.h> //pjj18 new |
|
20 |
|
21 #define LIBXML_NS (static_cast<xmlNsPtr>(iInternal)) |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // @return Namespace URI string |
|
25 // |
|
26 // For TXmlEngNamespace(NULL) or namespace undeclaration (xmlns=""), which are |
|
27 // treatet as <i>undefined namespace</i> returns NULL, |
|
28 // otherwise result is not a NULL string and not a "" (empty string). |
|
29 // |
|
30 // @note "" is never returned - it is replaced with NULL |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C TPtrC8 TXmlEngNamespace::Uri() const |
|
34 { |
|
35 return ((TXmlEngConstString)CAST_XMLCHAR_TO_DOMSTRING( |
|
36 LIBXML_NS && |
|
37 LIBXML_NS->href && |
|
38 *(LIBXML_NS->href) |
|
39 ? LIBXML_NS->href |
|
40 : NULL |
|
41 )).PtrC8(); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Returns prefix that is bound in the namespace declaration |
|
46 // or NULL string for default namespace or if no binding exist |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C TPtrC8 TXmlEngNamespace::Prefix() const |
|
50 { |
|
51 return ((TXmlEngConstString)CAST_XMLCHAR_TO_DOMSTRING( |
|
52 LIBXML_NS |
|
53 ? LIBXML_NS->prefix |
|
54 : NULL |
|
55 )).PtrC8(); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // @return Whether it is a definition of default namespace |
|
60 // TRUE -- is a default namespace (no prefix) |
|
61 // FALSE -- not a default namespace (bound to prefix) or empty |
|
62 // TXmlEngNamespace(NULL) instance |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C TBool TXmlEngNamespace::IsDefault() const |
|
66 { |
|
67 return IsUndefined() || (!LIBXML_NS->prefix); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // @return Whether the namespace is undefined |
|
72 // |
|
73 // A node's namespace is undefined if no namespace declaration associated with it. |
|
74 // |
|
75 // @note Same as TXmlEngNode::IsNull() |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C TBool TXmlEngNamespace::IsUndefined() const |
|
79 { |
|
80 return IsNull() || (!LIBXML_NS->href); |
|
81 } |
|
82 |