-
Notifications
You must be signed in to change notification settings - Fork 8
/
CXMLNamespaceNode.m
147 lines (114 loc) · 2.26 KB
/
CXMLNamespaceNode.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
// CXMLNamespaceNode.m
// TouchXML
//
#import "CXMLNamespaceNode.h"
@implementation CXMLNamespaceNode
#pragma mark -
#pragma mark Init and dealloc
- (id) initWithPrefix:(NSString *)prefix URI:(NSString *)uri parentElement:(CXMLElement *)parent
{
if (self = [super init])
{
_prefix = [prefix copy];
_uri = [uri copy];
_parent = parent; // Don't retain parent
}
return self;
}
- (void) dealloc
{
[_prefix release], _prefix = nil;
[_uri release], _uri = nil;
_parent = nil; // Parent not retained
[super dealloc];
}
#pragma mark -
#pragma mark Overidden methods
// NB: We need to override every method that relies on _node as namespaces in libXML don't have a xmlNode
- (CXMLNodeKind)kind
{
return CXMLNamespaceKind;
}
- (NSString *)name
{
return _prefix ? [[_prefix copy] autorelease] : @"";
}
- (NSString *)stringValue
{
return _uri ? [[_uri copy] autorelease] : @"";
}
- (NSUInteger)index
{
return 0; // TODO: Write tets, Fix
}
- (NSUInteger)level
{
return _parent ? [_parent level] + 1 : 2;
}
- (CXMLDocument *)rootDocument
{
return [_parent rootDocument];
}
- (CXMLNode *)parent
{
return _parent;
}
- (NSUInteger)childCount
{
return 0;
}
- (NSArray *)children
{
return nil;
}
- (CXMLNode *)childAtIndex:(NSUInteger)index
{
return nil;
}
- (CXMLNode *)previousSibling
{
return nil; // TODO: Write tets, Fix
}
- (CXMLNode *)nextSibling
{
return nil; // TODO: Write tets, Fix
}
//- (CXMLNode *)previousNode;
//- (CXMLNode *)nextNode;
//- (NSString *)XPath;
- (NSString *)localName
{
return [self name];
}
- (NSString *)prefix
{
return @"";
}
- (NSString *)URI
{
return nil;
}
//+ (NSString *)localNameForName:(NSString *)name;
//+ (NSString *)prefixForName:(NSString *)name;
//+ (CXMLNode *)predefinedNamespaceForPrefix:(NSString *)name;
- (NSString *)description
{
if (_prefix && [_prefix length] > 0)
return [NSString stringWithFormat:@"xmlns:%@=\"%@\"", _prefix, _uri];
return [NSString stringWithFormat:@"xmlns=\"%@\"", _uri];
}
- (NSString *)XMLString
{
return [self description];
}
- (NSString *)XMLStringWithOptions:(NSUInteger)options
{
return [self description];
}
//- (NSString *)canonicalXMLStringPreservingComments:(BOOL)comments;
- (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error
{
return nil;
}
@end