Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 252 lines (200 sloc) 8.889 kB
05eedb5 @itod initial add
authored
1 // Copyright 2010 Todd Ditchendorf
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #import <Foundation/Foundation.h>
16 //#import <libxml2/libxml/xmlreader.h>
17 #import <libxml/xmlreader.h>
18
19 /**
20 * XMLReaderMode:
21 *
22 * Internal state values for the reader.
23 */
24 typedef enum {
25 XMLReaderReadStateInitial = 0,
26 XMLReaderReadStateInteractive = 1,
27 XMLReaderReadStateError = 2,
28 XMLReaderReadStateEOF = 3,
29 XMLReaderReadStateClosed = 4,
30 XMLReaderReadStateReading = 5
31 } XMLReaderReadState;
32
33 /**
34 * xmlParserProperties:
35 *
36 * Some common options to use with xmlTextReaderSetParserProp, but it
37 * is better to use xmlParserOption and the xmlReaderNewxxx and
38 * xmlReaderForxxx APIs now.
39 *
40 typedef enum {
41 XML_PARSER_LOADDTD = 1,
42 XML_PARSER_DEFAULTATTRS = 2,
43 XML_PARSER_VALIDATE = 3,
44 XML_PARSER_SUBST_ENTITIES = 4
45 } xmlParserProperties;
46 */
47
48 /**
49 * xmlParserSeverities:
50 *
51 * How severe an error callback is when the per-reader error callback API
52 * is used.
53 */
54 typedef enum {
55 XMLReaderSeverityValidityWarning = 1,
56 XMLReaderSeverityValidityError = 2,
57 XMLReaderSeverityWarning = 3,
58 XMLReaderSeverityError = 4
59 } XMLReaderSeverity;
60
61 /**
62 * XMLReaderNodeType:
63 *
64 * Predefined constants for the different types of nodes.
65 */
66 typedef enum {
67 XMLReaderNodeTypeNone = 0,
68 XMLReaderNodeTypeElement = 1,
69 XMLReaderNodeTypeAttribute = 2,
70 XMLReaderNodeTypeText = 3,
71 XMLReaderNodeTypeCDATA = 4,
72 XMLReaderNodeTypeEntityReference = 5,
73 XMLReaderNodeTypeEntity = 6,
74 XMLReaderNodeTypeProcessingInstruction = 7,
75 XMLReaderNodeTypeComment = 8,
76 XMLReaderNodeTypeDocument = 9,
77 XMLReaderNodeTypeDocumentType = 10,
78 XMLReaderNodeTypeDocumentFragment = 11,
79 XMLReaderNodeTypeNotation = 12,
80 XMLReaderNodeTypeWhitespace = 13,
81 XMLReaderNodeTypeSignificantWhitespace = 14,
82 XMLReaderNodeTypeEndElement = 15,
83 XMLReaderNodeTypeEndEntity = 16,
84 XMLReaderNodeTypeXmlDeclaration = 17
85 } XMLReaderNodeType;
86
87
88 @interface NSObject (XMLReaderErrorHandler)
89 - (void)validityWarning:(NSString *)msg lineNumber:(NSInteger)n;
90 - (void)validityError:(NSString *)msg lineNumber:(NSInteger)n;
91 - (void)warning:(NSString *)msg lineNumber:(NSInteger)n;
92 - (void)error:(NSString *)msg lineNumber:(NSInteger)n;
93 - (void)fatalError:(NSString *)msg lineNumber:(NSInteger)n;
94 @end
95
96 @interface XMLReader : NSObject {
97 xmlTextReaderPtr _reader;
98 xmlRelaxNGPtr _schema;
99 NSString *path;
100 id errorHandler;
101 NSString *relaxNGSchemaPath;
102 }
103
104 + (id)parserWithContentsOfFile:(NSString *)newPath;
105 //+ (id)parserWithXMLString:(NSString *)XMLString;
106
107 - (id)initWithContentsOfFile:(NSString *)path;
108 //- (id)initWithXMLString:(NSString *)XMLString;
109
110 // Gets the number of attributes on the current node.
111 @property (nonatomic, readonly) NSInteger attributeCount;
112 //- (NSInteger)attributeCount;
113
114 // Gets the base Uniform Resource Identifier (URI) of the current node.
115 @property (nonatomic, readonly, copy) NSString *baseURI;
116 //- (NSString *)baseURI;
117
118 // Gets a value indicating whether this reader can parse and resolve entities.
119 //@property (nonatomic, readonly) BOOL canResolveEntity;
120 //- (BOOL)canResolveEntity;
121
122 // Gets the depth of the current node in the XML document.
123 @property (nonatomic, readonly) NSInteger depth;
124 //- (NSInteger)depth;
125
126 // Gets a value indicating whether the XMLReader.ReadState is ReadState.EndOfFile, signifying the reader is positioned at the end of the stream.
127 @property (nonatomic, readonly) BOOL isEOF;
128 //- (BOOL)isEOF;
129
130 // Gets a value indicating whether the current node has any attributes.
131 @property (nonatomic, readonly) BOOL hasAttributes;
132 //- (BOOL)hasAttributes;
133
134 // Gets a value indicating whether the current node can have an associated text value.
135 @property (nonatomic, readonly) BOOL hasValue;
136 //- (BOOL)hasValue;
137
138 // Gets a value indicating whether the current node is an attribute that was generated from the default value defined in the DTD or schema.
139 @property (nonatomic, readonly) BOOL isDefault;
140 //- (BOOL)isDefault;
141
142 // Gets a value indicating whether the current node is an empty element (for example, <MyElement />).
143 @property (nonatomic, readonly) BOOL isEmptyElement;
144 //- (BOOL)isEmptyElement;
145
146 // Gets the local name of the current node.
147 @property (nonatomic, readonly, copy) NSString *localName;
148 //- (NSString *)localName;
149
150 // Gets the qualified name of the current node.
151 @property (nonatomic, readonly, copy) NSString *name;
152 //- (NSString *)name;
153
154 // Gets the namespace URI associated with the node on which the reader is positioned.
155 @property (nonatomic, readonly, copy) NSString *namespaceURI;
156 //- (NSString *)namespaceURI;
157
158 // Gets the name table used by the current instance to store and look up element and attribute names, prefixes, and namespaces.
159 //- (XmlNameTable)NameTable;
160
161 // Gets the type of the current node.
162 @property (nonatomic, readonly) XMLReaderNodeType nodeType;
163 //- (XMLReaderNodeType)nodeType;
164
165 // Gets the namespace prefix associated with the current node.
166 @property (nonatomic, readonly, copy) NSString *prefix;
167 //- (NSString *)prefix;
168
169 // Gets the quotation mark character used to enclose the value of an attribute.
170 @property (nonatomic, readonly) char quoteChar;
171 //- (char)quoteChar;
172
173 // Gets the read state of the reader.
174 @property (nonatomic, readonly) XMLReaderReadState readState;
175 //- (XMLReaderReadState)readState;
176
177 // Gets the text value of the current node.
178 @property (nonatomic, readonly, copy) NSString *value;
179 //- (NSString *)value;
180
181 // Gets the current xml:lang scope.
182 @property (nonatomic, readonly, copy) NSString *XMLLang;
183 //- (NSString *)XMLLang;
184
185 // Gets the current xml:space scope.
186 //- (XMLSpace)XMLSpace;
187
188 // Changes the XMLReader.ReadState to XMLReaderReadState.Closed.
189 - (void)close;
190
191 // Returns the value of the attribute with the specified index relative to the containing element.
192 - (NSString *)attributeAtIndex:(NSInteger)index;
193
194 // Returns the value of the attribute with the specified qualified name.
195 - (NSString *)attributeWithQName:(NSString *)qName;
196
197 // Returns the value of the attribute with the specified local name and namespace URI.
198 - (NSString *)attributeWithLocalName:(NSString *)localName namespaceURI:(NSString *)nsURI;
199
200 // Determines whether the specified string is a valid XML name.
201 + (BOOL)isName:(NSString *)str;
202
203 // Determines whether the specified string is a valid XML name token (Nmtoken).
204 + (BOOL)isNameToken:(NSString *)str;
205
206 // Resolves a namespace prefix in the scope of the current element.
207 - (NSString *)lookupNamespace:(NSString *)prefix;
208
209 // Moves the position of the current instance to the attribute with the specified index relative to the containing element.
210 - (void)moveToAttributeAtIndex:(NSInteger)index;
211
212 // Moves the position of the current instance to the attribute with the specified qualified name.
213 - (BOOL)moveToAttributeWithQName:(NSString *)qName;
214
215 // Moves the position of the current instance to the attribute with the specified local name and namespace URI.
216 - (BOOL)moveToAttributeWithLocalName:(NSString *)localName namespaceURI:(NSString *)nsURI;
217
218 // Moves the position of the current instance to the node that contains the current Attribute node.
219 - (BOOL)moveToElement;
220
221 // Moves the position of the current instance to the first attribute associated with the current node.
222 - (BOOL)moveToFirstAttribute;
223
224 // Moves the position of the current instance to the next attribute associated with the current node.
225 - (BOOL)moveToNextAttribute;
226
227 // Moves the position of the current instance to the next node in the stream, exposing its properties.
228 - (BOOL)read;
229
230 // Parses an attribute value into one or more Text, EntityReference, and EndEntity nodes.
231 - (BOOL)readAttributeValue;
232
233 // Reads the contents of a text-only element.
234 - (NSString *)readElementString;
235
236 // Reads the contents of the current node, including child nodes and markup.
237 - (NSString *)readInnerXML;
238
239 // Reads the current node and its contents, including child nodes and markup.
240 - (NSString *)readOuterXML;
241
242 // Reads the contents of an element or text node as a string.
243 - (NSString *)readString;
244
245 // Skips over the current element and moves the position of the current instance to the next node in the stream.
246 - (void)skip;
247
248 @property (nonatomic, copy) NSString *relaxNGSchemaPath;
249 @property (nonatomic, readonly) BOOL isValid;
250 @property (nonatomic, retain) id errorHandler;
251 @end
Something went wrong with that request. Please try again.