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