Reactos
at master 433 lines 12 kB view raw
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 25extern "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 */ 34typedef 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 */ 48typedef 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 */ 64typedef 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 */ 76typedef 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 */ 102typedef struct _xmlTextReader xmlTextReader; 103 104/** 105 * xmlTextReaderPtr: 106 * 107 * Pointer to an xmlReader context. 108 */ 109typedef xmlTextReader *xmlTextReaderPtr; 110 111/* 112 * Constructors & Destructor 113 */ 114XMLPUBFUN xmlTextReaderPtr 115 xmlNewTextReader (xmlParserInputBufferPtr input, 116 const char *URI); 117XMLPUBFUN xmlTextReaderPtr 118 xmlNewTextReaderFilename(const char *URI); 119 120XMLPUBFUN void 121 xmlFreeTextReader (xmlTextReaderPtr reader); 122 123XMLPUBFUN int 124 xmlTextReaderSetup(xmlTextReaderPtr reader, 125 xmlParserInputBufferPtr input, const char *URL, 126 const char *encoding, int options); 127XMLPUBFUN void 128 xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader, 129 unsigned maxAmpl); 130 131/* 132 * Iterators 133 */ 134XMLPUBFUN int 135 xmlTextReaderRead (xmlTextReaderPtr reader); 136 137#ifdef LIBXML_WRITER_ENABLED 138XMLPUBFUN xmlChar * 139 xmlTextReaderReadInnerXml(xmlTextReaderPtr reader); 140 141XMLPUBFUN xmlChar * 142 xmlTextReaderReadOuterXml(xmlTextReaderPtr reader); 143#endif 144 145XMLPUBFUN xmlChar * 146 xmlTextReaderReadString (xmlTextReaderPtr reader); 147XMLPUBFUN int 148 xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader); 149 150/* 151 * Attributes of the node 152 */ 153XMLPUBFUN int 154 xmlTextReaderAttributeCount(xmlTextReaderPtr reader); 155XMLPUBFUN int 156 xmlTextReaderDepth (xmlTextReaderPtr reader); 157XMLPUBFUN int 158 xmlTextReaderHasAttributes(xmlTextReaderPtr reader); 159XMLPUBFUN int 160 xmlTextReaderHasValue(xmlTextReaderPtr reader); 161XMLPUBFUN int 162 xmlTextReaderIsDefault (xmlTextReaderPtr reader); 163XMLPUBFUN int 164 xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); 165XMLPUBFUN int 166 xmlTextReaderNodeType (xmlTextReaderPtr reader); 167XMLPUBFUN int 168 xmlTextReaderQuoteChar (xmlTextReaderPtr reader); 169XMLPUBFUN int 170 xmlTextReaderReadState (xmlTextReaderPtr reader); 171XMLPUBFUN int 172 xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); 173 174XMLPUBFUN const xmlChar * 175 xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); 176XMLPUBFUN const xmlChar * 177 xmlTextReaderConstLocalName (xmlTextReaderPtr reader); 178XMLPUBFUN const xmlChar * 179 xmlTextReaderConstName (xmlTextReaderPtr reader); 180XMLPUBFUN const xmlChar * 181 xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); 182XMLPUBFUN const xmlChar * 183 xmlTextReaderConstPrefix (xmlTextReaderPtr reader); 184XMLPUBFUN const xmlChar * 185 xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); 186XMLPUBFUN const xmlChar * 187 xmlTextReaderConstString (xmlTextReaderPtr reader, 188 const xmlChar *str); 189XMLPUBFUN const xmlChar * 190 xmlTextReaderConstValue (xmlTextReaderPtr reader); 191 192/* 193 * use the Const version of the routine for 194 * better performance and simpler code 195 */ 196XMLPUBFUN xmlChar * 197 xmlTextReaderBaseUri (xmlTextReaderPtr reader); 198XMLPUBFUN xmlChar * 199 xmlTextReaderLocalName (xmlTextReaderPtr reader); 200XMLPUBFUN xmlChar * 201 xmlTextReaderName (xmlTextReaderPtr reader); 202XMLPUBFUN xmlChar * 203 xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); 204XMLPUBFUN xmlChar * 205 xmlTextReaderPrefix (xmlTextReaderPtr reader); 206XMLPUBFUN xmlChar * 207 xmlTextReaderXmlLang (xmlTextReaderPtr reader); 208XMLPUBFUN xmlChar * 209 xmlTextReaderValue (xmlTextReaderPtr reader); 210 211/* 212 * Methods of the XmlTextReader 213 */ 214XMLPUBFUN int 215 xmlTextReaderClose (xmlTextReaderPtr reader); 216XMLPUBFUN xmlChar * 217 xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, 218 int no); 219XMLPUBFUN xmlChar * 220 xmlTextReaderGetAttribute (xmlTextReaderPtr reader, 221 const xmlChar *name); 222XMLPUBFUN xmlChar * 223 xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, 224 const xmlChar *localName, 225 const xmlChar *namespaceURI); 226XMLPUBFUN xmlParserInputBufferPtr 227 xmlTextReaderGetRemainder (xmlTextReaderPtr reader); 228XMLPUBFUN xmlChar * 229 xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, 230 const xmlChar *prefix); 231XMLPUBFUN int 232 xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, 233 int no); 234XMLPUBFUN int 235 xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, 236 const xmlChar *name); 237XMLPUBFUN int 238 xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, 239 const xmlChar *localName, 240 const xmlChar *namespaceURI); 241XMLPUBFUN int 242 xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); 243XMLPUBFUN int 244 xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); 245XMLPUBFUN int 246 xmlTextReaderMoveToElement (xmlTextReaderPtr reader); 247XMLPUBFUN int 248 xmlTextReaderNormalization (xmlTextReaderPtr reader); 249XMLPUBFUN const xmlChar * 250 xmlTextReaderConstEncoding (xmlTextReaderPtr reader); 251 252/* 253 * Extensions 254 */ 255XMLPUBFUN int 256 xmlTextReaderSetParserProp (xmlTextReaderPtr reader, 257 int prop, 258 int value); 259XMLPUBFUN int 260 xmlTextReaderGetParserProp (xmlTextReaderPtr reader, 261 int prop); 262XMLPUBFUN xmlNodePtr 263 xmlTextReaderCurrentNode (xmlTextReaderPtr reader); 264 265XMLPUBFUN int 266 xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader); 267 268XMLPUBFUN int 269 xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader); 270 271XMLPUBFUN xmlNodePtr 272 xmlTextReaderPreserve (xmlTextReaderPtr reader); 273#ifdef LIBXML_PATTERN_ENABLED 274XMLPUBFUN int 275 xmlTextReaderPreservePattern(xmlTextReaderPtr reader, 276 const xmlChar *pattern, 277 const xmlChar **namespaces); 278#endif /* LIBXML_PATTERN_ENABLED */ 279XMLPUBFUN xmlDocPtr 280 xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); 281XMLPUBFUN xmlNodePtr 282 xmlTextReaderExpand (xmlTextReaderPtr reader); 283XMLPUBFUN int 284 xmlTextReaderNext (xmlTextReaderPtr reader); 285XMLPUBFUN int 286 xmlTextReaderNextSibling (xmlTextReaderPtr reader); 287XMLPUBFUN int 288 xmlTextReaderIsValid (xmlTextReaderPtr reader); 289#ifdef LIBXML_SCHEMAS_ENABLED 290XMLPUBFUN int 291 xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, 292 const char *rng); 293XMLPUBFUN int 294 xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader, 295 xmlRelaxNGValidCtxtPtr ctxt, 296 int options); 297 298XMLPUBFUN int 299 xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, 300 xmlRelaxNGPtr schema); 301XMLPUBFUN int 302 xmlTextReaderSchemaValidate (xmlTextReaderPtr reader, 303 const char *xsd); 304XMLPUBFUN int 305 xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader, 306 xmlSchemaValidCtxtPtr ctxt, 307 int options); 308XMLPUBFUN int 309 xmlTextReaderSetSchema (xmlTextReaderPtr reader, 310 xmlSchemaPtr schema); 311#endif 312XMLPUBFUN const xmlChar * 313 xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); 314XMLPUBFUN int 315 xmlTextReaderStandalone (xmlTextReaderPtr reader); 316 317 318/* 319 * Index lookup 320 */ 321XMLPUBFUN long 322 xmlTextReaderByteConsumed (xmlTextReaderPtr reader); 323 324/* 325 * New more complete APIs for simpler creation and reuse of readers 326 */ 327XMLPUBFUN xmlTextReaderPtr 328 xmlReaderWalker (xmlDocPtr doc); 329XMLPUBFUN xmlTextReaderPtr 330 xmlReaderForDoc (const xmlChar * cur, 331 const char *URL, 332 const char *encoding, 333 int options); 334XMLPUBFUN xmlTextReaderPtr 335 xmlReaderForFile (const char *filename, 336 const char *encoding, 337 int options); 338XMLPUBFUN xmlTextReaderPtr 339 xmlReaderForMemory (const char *buffer, 340 int size, 341 const char *URL, 342 const char *encoding, 343 int options); 344XMLPUBFUN xmlTextReaderPtr 345 xmlReaderForFd (int fd, 346 const char *URL, 347 const char *encoding, 348 int options); 349XMLPUBFUN xmlTextReaderPtr 350 xmlReaderForIO (xmlInputReadCallback ioread, 351 xmlInputCloseCallback ioclose, 352 void *ioctx, 353 const char *URL, 354 const char *encoding, 355 int options); 356 357XMLPUBFUN int 358 xmlReaderNewWalker (xmlTextReaderPtr reader, 359 xmlDocPtr doc); 360XMLPUBFUN int 361 xmlReaderNewDoc (xmlTextReaderPtr reader, 362 const xmlChar * cur, 363 const char *URL, 364 const char *encoding, 365 int options); 366XMLPUBFUN int 367 xmlReaderNewFile (xmlTextReaderPtr reader, 368 const char *filename, 369 const char *encoding, 370 int options); 371XMLPUBFUN int 372 xmlReaderNewMemory (xmlTextReaderPtr reader, 373 const char *buffer, 374 int size, 375 const char *URL, 376 const char *encoding, 377 int options); 378XMLPUBFUN int 379 xmlReaderNewFd (xmlTextReaderPtr reader, 380 int fd, 381 const char *URL, 382 const char *encoding, 383 int options); 384XMLPUBFUN int 385 xmlReaderNewIO (xmlTextReaderPtr reader, 386 xmlInputReadCallback ioread, 387 xmlInputCloseCallback ioclose, 388 void *ioctx, 389 const char *URL, 390 const char *encoding, 391 int options); 392/* 393 * Error handling extensions 394 */ 395typedef void * xmlTextReaderLocatorPtr; 396 397/** 398 * xmlTextReaderErrorFunc: 399 * @arg: the user argument 400 * @msg: the message 401 * @severity: the severity of the error 402 * @locator: a locator indicating where the error occurred 403 * 404 * Signature of an error callback from a reader parser 405 */ 406typedef void (*xmlTextReaderErrorFunc)(void *arg, 407 const char *msg, 408 xmlParserSeverities severity, 409 xmlTextReaderLocatorPtr locator); 410XMLPUBFUN int 411 xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); 412XMLPUBFUN xmlChar * 413 xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); 414XMLPUBFUN void 415 xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, 416 xmlTextReaderErrorFunc f, 417 void *arg); 418XMLPUBFUN void 419 xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, 420 xmlStructuredErrorFunc f, 421 void *arg); 422XMLPUBFUN void 423 xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, 424 xmlTextReaderErrorFunc *f, 425 void **arg); 426 427#endif /* LIBXML_READER_ENABLED */ 428 429#ifdef __cplusplus 430} 431#endif 432 433#endif /* __XML_XMLREADER_H__ */