1 | /* |
---|
2 | * Summary: the XMLReader implementation |
---|
3 | * Description: API of the XML streaming API based on C# interfaces. |
---|
4 | * |
---|
5 | * Copy: See Copyright for the status of this software. |
---|
6 | * |
---|
7 | * Author: Daniel Veillard |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef __XML_XMLREADER_H__ |
---|
11 | #define __XML_XMLREADER_H__ |
---|
12 | |
---|
13 | #include <libxml/xmlversion.h> |
---|
14 | #include <libxml/tree.h> |
---|
15 | #include <libxml/xmlIO.h> |
---|
16 | #ifdef LIBXML_SCHEMAS_ENABLED |
---|
17 | #include <libxml/relaxng.h> |
---|
18 | #endif |
---|
19 | |
---|
20 | #ifdef LIBXML_READER_ENABLED |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | /** |
---|
27 | * xmlTextReaderMode: |
---|
28 | * |
---|
29 | * Internal state values for the reader. |
---|
30 | */ |
---|
31 | typedef enum { |
---|
32 | XML_TEXTREADER_MODE_INITIAL = 0, |
---|
33 | XML_TEXTREADER_MODE_INTERACTIVE = 1, |
---|
34 | XML_TEXTREADER_MODE_ERROR = 2, |
---|
35 | XML_TEXTREADER_MODE_EOF =3, |
---|
36 | XML_TEXTREADER_MODE_CLOSED = 4, |
---|
37 | XML_TEXTREADER_MODE_READING = 5 |
---|
38 | } xmlTextReaderMode; |
---|
39 | |
---|
40 | /** |
---|
41 | * xmlParserProperties: |
---|
42 | * |
---|
43 | * Some common options to use with xmlTextReaderSetParserProp, but it |
---|
44 | * is better to use xmlParserOption and the xmlReaderNewxxx and |
---|
45 | * xmlReaderForxxx APIs now. |
---|
46 | */ |
---|
47 | typedef enum { |
---|
48 | XML_PARSER_LOADDTD = 1, |
---|
49 | XML_PARSER_DEFAULTATTRS = 2, |
---|
50 | XML_PARSER_VALIDATE = 3, |
---|
51 | XML_PARSER_SUBST_ENTITIES = 4 |
---|
52 | } xmlParserProperties; |
---|
53 | |
---|
54 | /** |
---|
55 | * xmlParserSeverities: |
---|
56 | * |
---|
57 | * How severe an error callback is when the per-reader error callback API |
---|
58 | * is used. |
---|
59 | */ |
---|
60 | typedef enum { |
---|
61 | XML_PARSER_SEVERITY_VALIDITY_WARNING = 1, |
---|
62 | XML_PARSER_SEVERITY_VALIDITY_ERROR = 2, |
---|
63 | XML_PARSER_SEVERITY_WARNING = 3, |
---|
64 | XML_PARSER_SEVERITY_ERROR = 4 |
---|
65 | } xmlParserSeverities; |
---|
66 | |
---|
67 | /** |
---|
68 | * xmlReaderTypes: |
---|
69 | * |
---|
70 | * Predefined constants for the different types of nodes. |
---|
71 | */ |
---|
72 | typedef enum { |
---|
73 | XML_READER_TYPE_NONE = 0, |
---|
74 | XML_READER_TYPE_ELEMENT = 1, |
---|
75 | XML_READER_TYPE_ATTRIBUTE = 2, |
---|
76 | XML_READER_TYPE_TEXT = 3, |
---|
77 | XML_READER_TYPE_CDATA = 4, |
---|
78 | XML_READER_TYPE_ENTITY_REFERENCE = 5, |
---|
79 | XML_READER_TYPE_ENTITY = 6, |
---|
80 | XML_READER_TYPE_PROCESSING_INSTRUCTION = 7, |
---|
81 | XML_READER_TYPE_COMMENT = 8, |
---|
82 | XML_READER_TYPE_DOCUMENT = 9, |
---|
83 | XML_READER_TYPE_DOCUMENT_TYPE = 10, |
---|
84 | XML_READER_TYPE_DOCUMENT_FRAGMENT = 11, |
---|
85 | XML_READER_TYPE_NOTATION = 12, |
---|
86 | XML_READER_TYPE_WHITESPACE = 13, |
---|
87 | XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14, |
---|
88 | XML_READER_TYPE_END_ELEMENT = 15, |
---|
89 | XML_READER_TYPE_END_ENTITY = 16, |
---|
90 | XML_READER_TYPE_XML_DECLARATION = 17 |
---|
91 | } xmlReaderTypes; |
---|
92 | |
---|
93 | /** |
---|
94 | * xmlTextReader: |
---|
95 | * |
---|
96 | * Structure for an xmlReader context. |
---|
97 | */ |
---|
98 | typedef struct _xmlTextReader xmlTextReader; |
---|
99 | |
---|
100 | /** |
---|
101 | * xmlTextReaderPtr: |
---|
102 | * |
---|
103 | * Pointer to an xmlReader context. |
---|
104 | */ |
---|
105 | typedef xmlTextReader *xmlTextReaderPtr; |
---|
106 | |
---|
107 | /* |
---|
108 | * Constructors & Destructor |
---|
109 | */ |
---|
110 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
111 | xmlNewTextReader (xmlParserInputBufferPtr input, |
---|
112 | const char *URI); |
---|
113 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
114 | xmlNewTextReaderFilename(const char *URI); |
---|
115 | XMLPUBFUN void XMLCALL |
---|
116 | xmlFreeTextReader (xmlTextReaderPtr reader); |
---|
117 | |
---|
118 | /* |
---|
119 | * Iterators |
---|
120 | */ |
---|
121 | XMLPUBFUN int XMLCALL |
---|
122 | xmlTextReaderRead (xmlTextReaderPtr reader); |
---|
123 | XMLPUBFUN xmlChar * XMLCALL |
---|
124 | xmlTextReaderReadInnerXml (xmlTextReaderPtr reader); |
---|
125 | XMLPUBFUN xmlChar * XMLCALL |
---|
126 | xmlTextReaderReadOuterXml (xmlTextReaderPtr reader); |
---|
127 | XMLPUBFUN xmlChar * XMLCALL |
---|
128 | xmlTextReaderReadString (xmlTextReaderPtr reader); |
---|
129 | XMLPUBFUN int XMLCALL |
---|
130 | xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader); |
---|
131 | |
---|
132 | /* |
---|
133 | * Attributes of the node |
---|
134 | */ |
---|
135 | XMLPUBFUN int XMLCALL |
---|
136 | xmlTextReaderAttributeCount(xmlTextReaderPtr reader); |
---|
137 | XMLPUBFUN int XMLCALL |
---|
138 | xmlTextReaderDepth (xmlTextReaderPtr reader); |
---|
139 | XMLPUBFUN int XMLCALL |
---|
140 | xmlTextReaderHasAttributes(xmlTextReaderPtr reader); |
---|
141 | XMLPUBFUN int XMLCALL |
---|
142 | xmlTextReaderHasValue(xmlTextReaderPtr reader); |
---|
143 | XMLPUBFUN int XMLCALL |
---|
144 | xmlTextReaderIsDefault (xmlTextReaderPtr reader); |
---|
145 | XMLPUBFUN int XMLCALL |
---|
146 | xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); |
---|
147 | XMLPUBFUN int XMLCALL |
---|
148 | xmlTextReaderNodeType (xmlTextReaderPtr reader); |
---|
149 | XMLPUBFUN int XMLCALL |
---|
150 | xmlTextReaderQuoteChar (xmlTextReaderPtr reader); |
---|
151 | XMLPUBFUN int XMLCALL |
---|
152 | xmlTextReaderReadState (xmlTextReaderPtr reader); |
---|
153 | XMLPUBFUN int XMLCALL |
---|
154 | xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); |
---|
155 | |
---|
156 | XMLPUBFUN const xmlChar * XMLCALL |
---|
157 | xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); |
---|
158 | XMLPUBFUN const xmlChar * XMLCALL |
---|
159 | xmlTextReaderConstLocalName (xmlTextReaderPtr reader); |
---|
160 | XMLPUBFUN const xmlChar * XMLCALL |
---|
161 | xmlTextReaderConstName (xmlTextReaderPtr reader); |
---|
162 | XMLPUBFUN const xmlChar * XMLCALL |
---|
163 | xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); |
---|
164 | XMLPUBFUN const xmlChar * XMLCALL |
---|
165 | xmlTextReaderConstPrefix (xmlTextReaderPtr reader); |
---|
166 | XMLPUBFUN const xmlChar * XMLCALL |
---|
167 | xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); |
---|
168 | XMLPUBFUN const xmlChar * XMLCALL |
---|
169 | xmlTextReaderConstString (xmlTextReaderPtr reader, |
---|
170 | const xmlChar *str); |
---|
171 | XMLPUBFUN const xmlChar * XMLCALL |
---|
172 | xmlTextReaderConstValue (xmlTextReaderPtr reader); |
---|
173 | |
---|
174 | /* |
---|
175 | * use the Const version of the routine for |
---|
176 | * better performance and simpler code |
---|
177 | */ |
---|
178 | XMLPUBFUN xmlChar * XMLCALL |
---|
179 | xmlTextReaderBaseUri (xmlTextReaderPtr reader); |
---|
180 | XMLPUBFUN xmlChar * XMLCALL |
---|
181 | xmlTextReaderLocalName (xmlTextReaderPtr reader); |
---|
182 | XMLPUBFUN xmlChar * XMLCALL |
---|
183 | xmlTextReaderName (xmlTextReaderPtr reader); |
---|
184 | XMLPUBFUN xmlChar * XMLCALL |
---|
185 | xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); |
---|
186 | XMLPUBFUN xmlChar * XMLCALL |
---|
187 | xmlTextReaderPrefix (xmlTextReaderPtr reader); |
---|
188 | XMLPUBFUN xmlChar * XMLCALL |
---|
189 | xmlTextReaderXmlLang (xmlTextReaderPtr reader); |
---|
190 | XMLPUBFUN xmlChar * XMLCALL |
---|
191 | xmlTextReaderValue (xmlTextReaderPtr reader); |
---|
192 | |
---|
193 | /* |
---|
194 | * Methods of the XmlTextReader |
---|
195 | */ |
---|
196 | XMLPUBFUN int XMLCALL |
---|
197 | xmlTextReaderClose (xmlTextReaderPtr reader); |
---|
198 | XMLPUBFUN xmlChar * XMLCALL |
---|
199 | xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, |
---|
200 | int no); |
---|
201 | XMLPUBFUN xmlChar * XMLCALL |
---|
202 | xmlTextReaderGetAttribute (xmlTextReaderPtr reader, |
---|
203 | const xmlChar *name); |
---|
204 | XMLPUBFUN xmlChar * XMLCALL |
---|
205 | xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, |
---|
206 | const xmlChar *localName, |
---|
207 | const xmlChar *namespaceURI); |
---|
208 | XMLPUBFUN xmlParserInputBufferPtr XMLCALL |
---|
209 | xmlTextReaderGetRemainder (xmlTextReaderPtr reader); |
---|
210 | XMLPUBFUN xmlChar * XMLCALL |
---|
211 | xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, |
---|
212 | const xmlChar *prefix); |
---|
213 | XMLPUBFUN int XMLCALL |
---|
214 | xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, |
---|
215 | int no); |
---|
216 | XMLPUBFUN int XMLCALL |
---|
217 | xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, |
---|
218 | const xmlChar *name); |
---|
219 | XMLPUBFUN int XMLCALL |
---|
220 | xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, |
---|
221 | const xmlChar *localName, |
---|
222 | const xmlChar *namespaceURI); |
---|
223 | XMLPUBFUN int XMLCALL |
---|
224 | xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); |
---|
225 | XMLPUBFUN int XMLCALL |
---|
226 | xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); |
---|
227 | XMLPUBFUN int XMLCALL |
---|
228 | xmlTextReaderMoveToElement (xmlTextReaderPtr reader); |
---|
229 | XMLPUBFUN int XMLCALL |
---|
230 | xmlTextReaderNormalization (xmlTextReaderPtr reader); |
---|
231 | XMLPUBFUN const xmlChar * XMLCALL |
---|
232 | xmlTextReaderConstEncoding (xmlTextReaderPtr reader); |
---|
233 | |
---|
234 | /* |
---|
235 | * Extensions |
---|
236 | */ |
---|
237 | XMLPUBFUN int XMLCALL |
---|
238 | xmlTextReaderSetParserProp (xmlTextReaderPtr reader, |
---|
239 | int prop, |
---|
240 | int value); |
---|
241 | XMLPUBFUN int XMLCALL |
---|
242 | xmlTextReaderGetParserProp (xmlTextReaderPtr reader, |
---|
243 | int prop); |
---|
244 | XMLPUBFUN xmlNodePtr XMLCALL |
---|
245 | xmlTextReaderCurrentNode (xmlTextReaderPtr reader); |
---|
246 | |
---|
247 | XMLPUBFUN int XMLCALL |
---|
248 | xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader); |
---|
249 | |
---|
250 | XMLPUBFUN intptr_t XMLCALL |
---|
251 | xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader); |
---|
252 | |
---|
253 | XMLPUBFUN xmlNodePtr XMLCALL |
---|
254 | xmlTextReaderPreserve (xmlTextReaderPtr reader); |
---|
255 | #ifdef LIBXML_PATTERN_ENABLED |
---|
256 | XMLPUBFUN int XMLCALL |
---|
257 | xmlTextReaderPreservePattern(xmlTextReaderPtr reader, |
---|
258 | const xmlChar *pattern, |
---|
259 | const xmlChar **namespaces); |
---|
260 | #endif /* LIBXML_PATTERN_ENABLED */ |
---|
261 | XMLPUBFUN xmlDocPtr XMLCALL |
---|
262 | xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); |
---|
263 | XMLPUBFUN xmlNodePtr XMLCALL |
---|
264 | xmlTextReaderExpand (xmlTextReaderPtr reader); |
---|
265 | XMLPUBFUN int XMLCALL |
---|
266 | xmlTextReaderNext (xmlTextReaderPtr reader); |
---|
267 | XMLPUBFUN int XMLCALL |
---|
268 | xmlTextReaderNextSibling (xmlTextReaderPtr reader); |
---|
269 | XMLPUBFUN int XMLCALL |
---|
270 | xmlTextReaderIsValid (xmlTextReaderPtr reader); |
---|
271 | #ifdef LIBXML_SCHEMAS_ENABLED |
---|
272 | XMLPUBFUN int XMLCALL |
---|
273 | xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, |
---|
274 | const char *rng); |
---|
275 | XMLPUBFUN int XMLCALL |
---|
276 | xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, |
---|
277 | xmlRelaxNGPtr schema); |
---|
278 | #endif |
---|
279 | XMLPUBFUN const xmlChar * XMLCALL |
---|
280 | xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); |
---|
281 | XMLPUBFUN int XMLCALL |
---|
282 | xmlTextReaderStandalone (xmlTextReaderPtr reader); |
---|
283 | |
---|
284 | |
---|
285 | /* |
---|
286 | * Index lookup |
---|
287 | */ |
---|
288 | XMLPUBFUN intptr_t XMLCALL |
---|
289 | xmlTextReaderByteConsumed (xmlTextReaderPtr reader); |
---|
290 | |
---|
291 | /* |
---|
292 | * New more complete APIs for simpler creation and reuse of readers |
---|
293 | */ |
---|
294 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
295 | xmlReaderWalker (xmlDocPtr doc); |
---|
296 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
297 | xmlReaderForDoc (const xmlChar * cur, |
---|
298 | const char *URL, |
---|
299 | const char *encoding, |
---|
300 | int options); |
---|
301 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
302 | xmlReaderForFile (const char *filename, |
---|
303 | const char *encoding, |
---|
304 | int options); |
---|
305 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
306 | xmlReaderForMemory (const char *buffer, |
---|
307 | intptr_t size, |
---|
308 | const char *URL, |
---|
309 | const char *encoding, |
---|
310 | int options); |
---|
311 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
312 | xmlReaderForFd (int fd, |
---|
313 | const char *URL, |
---|
314 | const char *encoding, |
---|
315 | int options); |
---|
316 | XMLPUBFUN xmlTextReaderPtr XMLCALL |
---|
317 | xmlReaderForIO (xmlInputReadCallback ioread, |
---|
318 | xmlInputCloseCallback ioclose, |
---|
319 | void *ioctx, |
---|
320 | const char *URL, |
---|
321 | const char *encoding, |
---|
322 | int options); |
---|
323 | |
---|
324 | XMLPUBFUN int XMLCALL |
---|
325 | xmlReaderNewWalker (xmlTextReaderPtr reader, |
---|
326 | xmlDocPtr doc); |
---|
327 | XMLPUBFUN int XMLCALL |
---|
328 | xmlReaderNewDoc (xmlTextReaderPtr reader, |
---|
329 | const xmlChar * cur, |
---|
330 | const char *URL, |
---|
331 | const char *encoding, |
---|
332 | int options); |
---|
333 | XMLPUBFUN int XMLCALL |
---|
334 | xmlReaderNewFile (xmlTextReaderPtr reader, |
---|
335 | const char *filename, |
---|
336 | const char *encoding, |
---|
337 | int options); |
---|
338 | XMLPUBFUN int XMLCALL |
---|
339 | xmlReaderNewMemory (xmlTextReaderPtr reader, |
---|
340 | const char *buffer, |
---|
341 | intptr_t size, |
---|
342 | const char *URL, |
---|
343 | const char *encoding, |
---|
344 | int options); |
---|
345 | XMLPUBFUN int XMLCALL |
---|
346 | xmlReaderNewFd (xmlTextReaderPtr reader, |
---|
347 | int fd, |
---|
348 | const char *URL, |
---|
349 | const char *encoding, |
---|
350 | int options); |
---|
351 | XMLPUBFUN int XMLCALL |
---|
352 | xmlReaderNewIO (xmlTextReaderPtr reader, |
---|
353 | xmlInputReadCallback ioread, |
---|
354 | xmlInputCloseCallback ioclose, |
---|
355 | void *ioctx, |
---|
356 | const char *URL, |
---|
357 | const char *encoding, |
---|
358 | int options); |
---|
359 | /* |
---|
360 | * Error handling extensions |
---|
361 | */ |
---|
362 | typedef void * xmlTextReaderLocatorPtr; |
---|
363 | typedef void (XMLCALL *xmlTextReaderErrorFunc) (void *arg, |
---|
364 | const char *msg, |
---|
365 | xmlParserSeverities severity, |
---|
366 | xmlTextReaderLocatorPtr locator); |
---|
367 | XMLPUBFUN int XMLCALL |
---|
368 | xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); |
---|
369 | /*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/ |
---|
370 | XMLPUBFUN xmlChar * XMLCALL |
---|
371 | xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); |
---|
372 | XMLPUBFUN void XMLCALL |
---|
373 | xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, |
---|
374 | xmlTextReaderErrorFunc f, |
---|
375 | void *arg); |
---|
376 | XMLPUBFUN void XMLCALL |
---|
377 | xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, |
---|
378 | xmlStructuredErrorFunc f, |
---|
379 | void *arg); |
---|
380 | XMLPUBFUN void XMLCALL |
---|
381 | xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, |
---|
382 | xmlTextReaderErrorFunc *f, |
---|
383 | void **arg); |
---|
384 | |
---|
385 | #ifdef __cplusplus |
---|
386 | } |
---|
387 | #endif |
---|
388 | |
---|
389 | #endif /* LIBXML_READER_ENABLED */ |
---|
390 | |
---|
391 | #endif /* __XML_XMLREADER_H__ */ |
---|
392 | |
---|