DDXMLNode.h
4.29 KB
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
#import <Foundation/Foundation.h>
@class DDXMLDocument;
/**
* Welcome to KissXML.
*
* The project page has documentation if you have questions.
* https://github.com/robbiehanson/KissXML
*
* If you're new to the project you may wish to read the "Getting Started" wiki.
* https://github.com/robbiehanson/KissXML/wiki/GettingStarted
*
* KissXML provides a drop-in replacement for Apple's NSXML class cluster.
* The goal is to get the exact same behavior as the NSXML classes.
*
* For API Reference, see Apple's excellent documentation,
* either via Xcode's Mac OS X documentation, or via the web:
*
* https://github.com/robbiehanson/KissXML/wiki/Reference
**/
enum {
DDXMLInvalidKind = 0,
DDXMLDocumentKind,
DDXMLElementKind,
DDXMLAttributeKind,
DDXMLNamespaceKind,
DDXMLProcessingInstructionKind,
DDXMLCommentKind,
DDXMLTextKind,
DDXMLDTDKind,
DDXMLEntityDeclarationKind,
DDXMLAttributeDeclarationKind,
DDXMLElementDeclarationKind,
DDXMLNotationDeclarationKind
};
typedef NSUInteger DDXMLNodeKind;
enum {
DDXMLNodeOptionsNone = 0,
DDXMLNodeExpandEmptyElement = 1 << 1,
DDXMLNodeCompactEmptyElement = 1 << 2,
DDXMLNodePrettyPrint = 1 << 17,
};
NS_ASSUME_NONNULL_BEGIN
@interface DDXMLNode : NSObject <NSCopying>
//- (instancetype)initWithKind:(DDXMLNodeKind)kind;
//- (instancetype)initWithKind:(DDXMLNodeKind)kind options:(NSUInteger)options;
//+ (instancetype)document;
//+ (instancetype)documentWithRootElement:(DDXMLElement *)element;
+ (id)elementWithName:(NSString *)name;
+ (id)elementWithName:(NSString *)name URI:(NSString *)URI;
+ (id)elementWithName:(NSString *)name stringValue:(NSString *)string;
+ (id)elementWithName:(NSString *)name children:(nullable NSArray<DDXMLNode *> *)children attributes:(nullable NSArray<DDXMLNode *> *)attributes;
+ (id)attributeWithName:(NSString *)name stringValue:(NSString *)stringValue;
+ (id)attributeWithName:(NSString *)name URI:(NSString *)URI stringValue:(NSString *)stringValue;
+ (id)namespaceWithName:(NSString *)name stringValue:(NSString *)stringValue;
+ (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)stringValue;
+ (id)commentWithStringValue:(NSString *)stringValue;
+ (id)textWithStringValue:(NSString *)stringValue;
//+ (instancetype)DTDNodeWithXMLString:(NSString *)string;
#pragma mark --- Properties ---
@property (readonly) DDXMLNodeKind kind;
@property (nullable, copy) NSString *name;
//- (void)setObjectValue:(id)value;
//- (instancetype)objectValue;
@property (nullable, copy) NSString *stringValue;
//- (void)setStringValue:(NSString *)string resolvingEntities:(BOOL)resolve;
#pragma mark --- Tree Navigation ---
@property (readonly) NSUInteger index;
@property (readonly) NSUInteger level;
@property (nullable, readonly, retain) DDXMLDocument *rootDocument;
@property (nullable, readonly, copy) DDXMLNode *parent;
@property (readonly) NSUInteger childCount;
@property (nullable, readonly, copy) NSArray<DDXMLNode *> *children;
- (nullable DDXMLNode *)childAtIndex:(NSUInteger)index;
@property (nullable, readonly, copy) DDXMLNode *previousSibling;
@property (nullable, readonly, copy) DDXMLNode *nextSibling;
@property (nullable, readonly, copy) DDXMLNode *previousNode;
@property (nullable, readonly, copy) DDXMLNode *nextNode;
- (void)detach;
@property (nullable, readonly, copy) NSString *XPath;
#pragma mark --- QNames ---
@property (nullable, readonly, copy) NSString *localName;
@property (nullable, readonly, copy) NSString *prefix;
@property (nullable, copy) NSString *URI; //primitive
+ (NSString *)localNameForName:(NSString *)name;
+ (nullable NSString *)prefixForName:(NSString *)name;
//+ (DDXMLNode *)predefinedNamespaceForPrefix:(NSString *)name;
#pragma mark --- Output ---
@property (readonly, copy) NSString *description;
@property (readonly, copy) NSString *XMLString;
- (nonnull NSString *)XMLStringWithOptions:(NSUInteger)options;
//- (NSString *)canonicalXMLStringPreservingComments:(BOOL)comments;
#pragma mark --- XPath/XQuery ---
- (nullable NSArray<__kindof DDXMLNode *> *)nodesForXPath:(NSString *)xpath error:(NSError **)error;
//- (NSArray *)objectsForXQuery:(NSString *)xquery constants:(NSDictionary *)constants error:(NSError **)error;
//- (NSArray *)objectsForXQuery:(NSString *)xquery error:(NSError **)error;
@end
NS_ASSUME_NONNULL_END