1 /* 2 * Summary: the core parser module 3 * Description: Interfaces, constants and types related to the XML parser 4 * 5 * Copy: See Copyright for the status of this software. 6 * 7 * Author: Daniel Veillard 8 */ 9 10 #ifndef __XML_PARSER_H__ 11 #define __XML_PARSER_H__ 12 13 #include <libxml/xmlversion.h> 14 #include <libxml/tree.h> 15 #include <libxml/dict.h> 16 #include <libxml/hash.h> 17 #include <libxml/valid.h> 18 #include <libxml/entities.h> 19 #include <libxml/xmlerror.h> 20 #include <libxml/xmlstring.h> 21 #include <libxml/xmlmemory.h> 22 #include <libxml/encoding.h> 23 #include <libxml/xmlIO.h> 24 /* for compatibility */ 25 #include <libxml/SAX2.h> 26 #include <libxml/threads.h> 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /** 33 * XML_DEFAULT_VERSION: 34 * 35 * The default version of XML used: 1.0 36 */ 37 #define XML_DEFAULT_VERSION "1.0" 38 39 /** 40 * xmlParserInput: 41 * 42 * An xmlParserInput is an input flow for the XML processor. 43 * Each entity parsed is associated an xmlParserInput (except the 44 * few predefined ones). This is the case both for internal entities 45 * - in which case the flow is already completely in memory - or 46 * external entities - in which case we use the buf structure for 47 * progressive reading and I18N conversions to the internal UTF-8 format. 48 */ 49 50 /** 51 * xmlParserInputDeallocate: 52 * @str: the string to deallocate 53 * 54 * Callback for freeing some parser input allocations. 55 */ 56 typedef void (* xmlParserInputDeallocate)(xmlChar *str); 57 58 struct _xmlParserInput { 59 /* Input buffer */ 60 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ 61 62 const char *filename; /* The file analyzed, if any */ 63 const char *directory; /* unused */ 64 const xmlChar *base; /* Base of the array to parse */ 65 const xmlChar *cur; /* Current char being parsed */ 66 const xmlChar *end; /* end of the array to parse */ 67 int length; /* unused */ 68 int line; /* Current line */ 69 int col; /* Current column */ 70 unsigned long consumed; /* How many xmlChars already consumed */ 71 xmlParserInputDeallocate free; /* function to deallocate the base */ 72 const xmlChar *encoding; /* unused */ 73 const xmlChar *version; /* the version string for entity */ 74 int flags; /* Flags */ 75 int id; /* an unique identifier for the entity */ 76 unsigned long parentConsumed; /* unused */ 77 xmlEntityPtr entity; /* entity, if any */ 78 }; 79 80 /** 81 * xmlParserNodeInfo: 82 * 83 * The parser can be asked to collect Node information, i.e. at what 84 * place in the file they were detected. 85 * NOTE: This is off by default and not very well tested. 86 */ 87 typedef struct _xmlParserNodeInfo xmlParserNodeInfo; 88 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; 89 90 struct _xmlParserNodeInfo { 91 const struct _xmlNode* node; 92 /* Position & line # that text that created the node begins & ends on */ 93 unsigned long begin_pos; 94 unsigned long begin_line; 95 unsigned long end_pos; 96 unsigned long end_line; 97 }; 98 99 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; 100 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; 101 struct _xmlParserNodeInfoSeq { 102 unsigned long maximum; 103 unsigned long length; 104 xmlParserNodeInfo* buffer; 105 }; 106 107 /** 108 * xmlParserInputState: 109 * 110 * The parser is now working also as a state based parser. 111 * The recursive one use the state info for entities processing. 112 */ 113 typedef enum { 114 XML_PARSER_EOF = -1, /* nothing is to be parsed */ 115 XML_PARSER_START = 0, /* nothing has been parsed */ 116 XML_PARSER_MISC, /* Misc* before int subset */ 117 XML_PARSER_PI, /* Within a processing instruction */ 118 XML_PARSER_DTD, /* within some DTD content */ 119 XML_PARSER_PROLOG, /* Misc* after internal subset */ 120 XML_PARSER_COMMENT, /* within a comment */ 121 XML_PARSER_START_TAG, /* within a start tag */ 122 XML_PARSER_CONTENT, /* within the content */ 123 XML_PARSER_CDATA_SECTION, /* within a CDATA section */ 124 XML_PARSER_END_TAG, /* within a closing tag */ 125 XML_PARSER_ENTITY_DECL, /* within an entity declaration */ 126 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ 127 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ 128 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ 129 XML_PARSER_EPILOG, /* the Misc* after the last end tag */ 130 XML_PARSER_IGNORE, /* within an IGNORED section */ 131 XML_PARSER_PUBLIC_LITERAL, /* within a PUBLIC value */ 132 XML_PARSER_XML_DECL /* before XML decl (but after BOM) */ 133 } xmlParserInputState; 134 135 /** DOC_DISABLE */ 136 /* 137 * Internal bits in the 'loadsubset' context member 138 */ 139 #define XML_DETECT_IDS 2 140 #define XML_COMPLETE_ATTRS 4 141 #define XML_SKIP_IDS 8 142 /** DOC_ENABLE */ 143 144 /** 145 * xmlParserMode: 146 * 147 * A parser can operate in various modes 148 */ 149 typedef enum { 150 XML_PARSE_UNKNOWN = 0, 151 XML_PARSE_DOM = 1, 152 XML_PARSE_SAX = 2, 153 XML_PARSE_PUSH_DOM = 3, 154 XML_PARSE_PUSH_SAX = 4, 155 XML_PARSE_READER = 5 156 } xmlParserMode; 157 158 typedef struct _xmlStartTag xmlStartTag; 159 typedef struct _xmlParserNsData xmlParserNsData; 160 typedef struct _xmlAttrHashBucket xmlAttrHashBucket; 161 162 /** 163 * xmlParserCtxt: 164 * 165 * The parser context. 166 * NOTE This doesn't completely define the parser state, the (current ?) 167 * design of the parser uses recursive function calls since this allow 168 * and easy mapping from the production rules of the specification 169 * to the actual code. The drawback is that the actual function call 170 * also reflect the parser state. However most of the parsing routines 171 * takes as the only argument the parser context pointer, so migrating 172 * to a state based parser for progressive parsing shouldn't be too hard. 173 */ 174 struct _xmlParserCtxt { 175 struct _xmlSAXHandler *sax; /* The SAX handler */ 176 void *userData; /* For SAX interface only, used by DOM build */ 177 xmlDocPtr myDoc; /* the document being built */ 178 int wellFormed; /* is the document well formed */ 179 int replaceEntities; /* shall we replace entities ? */ 180 const xmlChar *version; /* the XML version string */ 181 const xmlChar *encoding; /* the declared encoding, if any */ 182 int standalone; /* standalone document */ 183 int html; /* an HTML(1) document 184 * 3 is HTML after <head> 185 * 10 is HTML after <body> 186 */ 187 188 /* Input stream stack */ 189 xmlParserInputPtr input; /* Current input stream */ 190 int inputNr; /* Number of current input streams */ 191 int inputMax; /* Max number of input streams */ 192 xmlParserInputPtr *inputTab; /* stack of inputs */ 193 194 /* Node analysis stack only used for DOM building */ 195 xmlNodePtr node; /* Current parsed Node */ 196 int nodeNr; /* Depth of the parsing stack */ 197 int nodeMax; /* Max depth of the parsing stack */ 198 xmlNodePtr *nodeTab; /* array of nodes */ 199 200 int record_info; /* Whether node info should be kept */ 201 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ 202 203 int errNo; /* error code */ 204 205 int hasExternalSubset; /* reference and external subset */ 206 int hasPErefs; /* the internal subset has PE refs */ 207 int external; /* unused */ 208 209 int valid; /* is the document valid */ 210 int validate; /* shall we try to validate ? */ 211 xmlValidCtxt vctxt; /* The validity context */ 212 213 xmlParserInputState instate; /* push parser state */ 214 int token; /* unused */ 215 216 char *directory; /* unused */ 217 218 /* Node name stack */ 219 const xmlChar *name; /* Current parsed Node */ 220 int nameNr; /* Depth of the parsing stack */ 221 int nameMax; /* Max depth of the parsing stack */ 222 const xmlChar * *nameTab; /* array of nodes */ 223 224 long nbChars; /* unused */ 225 long checkIndex; /* used by progressive parsing lookup */ 226 int keepBlanks; /* ugly but ... */ 227 int disableSAX; /* SAX callbacks are disabled */ 228 int inSubset; /* Parsing is in int 1/ext 2 subset */ 229 const xmlChar * intSubName; /* name of subset */ 230 xmlChar * extSubURI; /* URI of external subset */ 231 xmlChar * extSubSystem; /* SYSTEM ID of external subset */ 232 233 /* xml:space values */ 234 int * space; /* Should the parser preserve spaces */ 235 int spaceNr; /* Depth of the parsing stack */ 236 int spaceMax; /* Max depth of the parsing stack */ 237 int * spaceTab; /* array of space infos */ 238 239 int depth; /* to prevent entity substitution loops */ 240 xmlParserInputPtr entity; /* unused */ 241 int charset; /* unused */ 242 int nodelen; /* Those two fields are there to */ 243 int nodemem; /* Speed up large node parsing */ 244 int pedantic; /* signal pedantic warnings */ 245 void *_private; /* For user data, libxml won't touch it */ 246 247 int loadsubset; /* should the external subset be loaded */ 248 int linenumbers; /* set line number in element content */ 249 void *catalogs; /* document's own catalog */ 250 int recovery; /* run in recovery mode */ 251 int progressive; /* unused */ 252 xmlDictPtr dict; /* dictionary for the parser */ 253 const xmlChar * *atts; /* array for the attributes callbacks */ 254 int maxatts; /* the size of the array */ 255 int docdict; /* unused */ 256 257 /* 258 * pre-interned strings 259 */ 260 const xmlChar *str_xml; 261 const xmlChar *str_xmlns; 262 const xmlChar *str_xml_ns; 263 264 /* 265 * Everything below is used only by the new SAX mode 266 */ 267 int sax2; /* operating in the new SAX mode */ 268 int nsNr; /* the number of inherited namespaces */ 269 int nsMax; /* the size of the arrays */ 270 const xmlChar * *nsTab; /* the array of prefix/namespace name */ 271 unsigned *attallocs; /* which attribute were allocated */ 272 xmlStartTag *pushTab; /* array of data for push */ 273 xmlHashTablePtr attsDefault; /* defaulted attributes if any */ 274 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ 275 int nsWellFormed; /* is the document XML Namespace okay */ 276 int options; /* Extra options */ 277 278 /* 279 * Those fields are needed only for streaming parsing so far 280 */ 281 int dictNames; /* Use dictionary names for the tree */ 282 int freeElemsNr; /* number of freed element nodes */ 283 xmlNodePtr freeElems; /* List of freed element nodes */ 284 int freeAttrsNr; /* number of freed attributes nodes */ 285 xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ 286 287 /* 288 * the complete error information for the last error. 289 */ 290 xmlError lastError; 291 xmlParserMode parseMode; /* the parser mode */ 292 unsigned long nbentities; /* unused */ 293 unsigned long sizeentities; /* size of external entities */ 294 295 /* for use by HTML non-recursive parser */ 296 xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */ 297 int nodeInfoNr; /* Depth of the parsing stack */ 298 int nodeInfoMax; /* Max depth of the parsing stack */ 299 xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */ 300 301 int input_id; /* we need to label inputs */ 302 unsigned long sizeentcopy; /* volume of entity copy */ 303 304 int endCheckState; /* quote state for push parser */ 305 unsigned short nbErrors; /* number of errors */ 306 unsigned short nbWarnings; /* number of warnings */ 307 unsigned maxAmpl; /* maximum amplification factor */ 308 309 xmlParserNsData *nsdb; /* namespace database */ 310 unsigned attrHashMax; /* allocated size */ 311 xmlAttrHashBucket *attrHash; /* atttribute hash table */ 312 313 xmlStructuredErrorFunc errorHandler; 314 void *errorCtxt; 315 }; 316 317 /** 318 * xmlSAXLocator: 319 * 320 * A SAX Locator. 321 */ 322 struct _xmlSAXLocator { 323 const xmlChar *(*getPublicId)(void *ctx); 324 const xmlChar *(*getSystemId)(void *ctx); 325 int (*getLineNumber)(void *ctx); 326 int (*getColumnNumber)(void *ctx); 327 }; 328 329 /** 330 * xmlSAXHandler: 331 * 332 * A SAX handler is bunch of callbacks called by the parser when processing 333 * of the input generate data or structure information. 334 */ 335 336 /** 337 * resolveEntitySAXFunc: 338 * @ctx: the user data (XML parser context) 339 * @publicId: The public ID of the entity 340 * @systemId: The system ID of the entity 341 * 342 * Callback: 343 * The entity loader, to control the loading of external entities, 344 * the application can either: 345 * - override this resolveEntity() callback in the SAX block 346 * - or better use the xmlSetExternalEntityLoader() function to 347 * set up it's own entity resolution routine 348 * 349 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. 350 */ 351 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, 352 const xmlChar *publicId, 353 const xmlChar *systemId); 354 /** 355 * internalSubsetSAXFunc: 356 * @ctx: the user data (XML parser context) 357 * @name: the root element name 358 * @ExternalID: the external ID 359 * @SystemID: the SYSTEM ID (e.g. filename or URL) 360 * 361 * Callback on internal subset declaration. 362 */ 363 typedef void (*internalSubsetSAXFunc) (void *ctx, 364 const xmlChar *name, 365 const xmlChar *ExternalID, 366 const xmlChar *SystemID); 367 /** 368 * externalSubsetSAXFunc: 369 * @ctx: the user data (XML parser context) 370 * @name: the root element name 371 * @ExternalID: the external ID 372 * @SystemID: the SYSTEM ID (e.g. filename or URL) 373 * 374 * Callback on external subset declaration. 375 */ 376 typedef void (*externalSubsetSAXFunc) (void *ctx, 377 const xmlChar *name, 378 const xmlChar *ExternalID, 379 const xmlChar *SystemID); 380 /** 381 * getEntitySAXFunc: 382 * @ctx: the user data (XML parser context) 383 * @name: The entity name 384 * 385 * Get an entity by name. 386 * 387 * Returns the xmlEntityPtr if found. 388 */ 389 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, 390 const xmlChar *name); 391 /** 392 * getParameterEntitySAXFunc: 393 * @ctx: the user data (XML parser context) 394 * @name: The entity name 395 * 396 * Get a parameter entity by name. 397 * 398 * Returns the xmlEntityPtr if found. 399 */ 400 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, 401 const xmlChar *name); 402 /** 403 * entityDeclSAXFunc: 404 * @ctx: the user data (XML parser context) 405 * @name: the entity name 406 * @type: the entity type 407 * @publicId: The public ID of the entity 408 * @systemId: The system ID of the entity 409 * @content: the entity value (without processing). 410 * 411 * An entity definition has been parsed. 412 */ 413 typedef void (*entityDeclSAXFunc) (void *ctx, 414 const xmlChar *name, 415 int type, 416 const xmlChar *publicId, 417 const xmlChar *systemId, 418 xmlChar *content); 419 /** 420 * notationDeclSAXFunc: 421 * @ctx: the user data (XML parser context) 422 * @name: The name of the notation 423 * @publicId: The public ID of the entity 424 * @systemId: The system ID of the entity 425 * 426 * What to do when a notation declaration has been parsed. 427 */ 428 typedef void (*notationDeclSAXFunc)(void *ctx, 429 const xmlChar *name, 430 const xmlChar *publicId, 431 const xmlChar *systemId); 432 /** 433 * attributeDeclSAXFunc: 434 * @ctx: the user data (XML parser context) 435 * @elem: the name of the element 436 * @fullname: the attribute name 437 * @type: the attribute type 438 * @def: the type of default value 439 * @defaultValue: the attribute default value 440 * @tree: the tree of enumerated value set 441 * 442 * An attribute definition has been parsed. 443 */ 444 typedef void (*attributeDeclSAXFunc)(void *ctx, 445 const xmlChar *elem, 446 const xmlChar *fullname, 447 int type, 448 int def, 449 const xmlChar *defaultValue, 450 xmlEnumerationPtr tree); 451 /** 452 * elementDeclSAXFunc: 453 * @ctx: the user data (XML parser context) 454 * @name: the element name 455 * @type: the element type 456 * @content: the element value tree 457 * 458 * An element definition has been parsed. 459 */ 460 typedef void (*elementDeclSAXFunc)(void *ctx, 461 const xmlChar *name, 462 int type, 463 xmlElementContentPtr content); 464 /** 465 * unparsedEntityDeclSAXFunc: 466 * @ctx: the user data (XML parser context) 467 * @name: The name of the entity 468 * @publicId: The public ID of the entity 469 * @systemId: The system ID of the entity 470 * @notationName: the name of the notation 471 * 472 * What to do when an unparsed entity declaration is parsed. 473 */ 474 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, 475 const xmlChar *name, 476 const xmlChar *publicId, 477 const xmlChar *systemId, 478 const xmlChar *notationName); 479 /** 480 * setDocumentLocatorSAXFunc: 481 * @ctx: the user data (XML parser context) 482 * @loc: A SAX Locator 483 * 484 * Receive the document locator at startup, actually xmlDefaultSAXLocator. 485 * Everything is available on the context, so this is useless in our case. 486 */ 487 typedef void (*setDocumentLocatorSAXFunc) (void *ctx, 488 xmlSAXLocatorPtr loc); 489 /** 490 * startDocumentSAXFunc: 491 * @ctx: the user data (XML parser context) 492 * 493 * Called when the document start being processed. 494 */ 495 typedef void (*startDocumentSAXFunc) (void *ctx); 496 /** 497 * endDocumentSAXFunc: 498 * @ctx: the user data (XML parser context) 499 * 500 * Called when the document end has been detected. 501 */ 502 typedef void (*endDocumentSAXFunc) (void *ctx); 503 /** 504 * startElementSAXFunc: 505 * @ctx: the user data (XML parser context) 506 * @name: The element name, including namespace prefix 507 * @atts: An array of name/value attributes pairs, NULL terminated 508 * 509 * Called when an opening tag has been processed. 510 */ 511 typedef void (*startElementSAXFunc) (void *ctx, 512 const xmlChar *name, 513 const xmlChar **atts); 514 /** 515 * endElementSAXFunc: 516 * @ctx: the user data (XML parser context) 517 * @name: The element name 518 * 519 * Called when the end of an element has been detected. 520 */ 521 typedef void (*endElementSAXFunc) (void *ctx, 522 const xmlChar *name); 523 /** 524 * attributeSAXFunc: 525 * @ctx: the user data (XML parser context) 526 * @name: The attribute name, including namespace prefix 527 * @value: The attribute value 528 * 529 * Handle an attribute that has been read by the parser. 530 * The default handling is to convert the attribute into an 531 * DOM subtree and past it in a new xmlAttr element added to 532 * the element. 533 */ 534 typedef void (*attributeSAXFunc) (void *ctx, 535 const xmlChar *name, 536 const xmlChar *value); 537 /** 538 * referenceSAXFunc: 539 * @ctx: the user data (XML parser context) 540 * @name: The entity name 541 * 542 * Called when an entity reference is detected. 543 */ 544 typedef void (*referenceSAXFunc) (void *ctx, 545 const xmlChar *name); 546 /** 547 * charactersSAXFunc: 548 * @ctx: the user data (XML parser context) 549 * @ch: a xmlChar string 550 * @len: the number of xmlChar 551 * 552 * Receiving some chars from the parser. 553 */ 554 typedef void (*charactersSAXFunc) (void *ctx, 555 const xmlChar *ch, 556 int len); 557 /** 558 * ignorableWhitespaceSAXFunc: 559 * @ctx: the user data (XML parser context) 560 * @ch: a xmlChar string 561 * @len: the number of xmlChar 562 * 563 * Receiving some ignorable whitespaces from the parser. 564 * UNUSED: by default the DOM building will use characters. 565 */ 566 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, 567 const xmlChar *ch, 568 int len); 569 /** 570 * processingInstructionSAXFunc: 571 * @ctx: the user data (XML parser context) 572 * @target: the target name 573 * @data: the PI data's 574 * 575 * A processing instruction has been parsed. 576 */ 577 typedef void (*processingInstructionSAXFunc) (void *ctx, 578 const xmlChar *target, 579 const xmlChar *data); 580 /** 581 * commentSAXFunc: 582 * @ctx: the user data (XML parser context) 583 * @value: the comment content 584 * 585 * A comment has been parsed. 586 */ 587 typedef void (*commentSAXFunc) (void *ctx, 588 const xmlChar *value); 589 /** 590 * cdataBlockSAXFunc: 591 * @ctx: the user data (XML parser context) 592 * @value: The pcdata content 593 * @len: the block length 594 * 595 * Called when a pcdata block has been parsed. 596 */ 597 typedef void (*cdataBlockSAXFunc) ( 598 void *ctx, 599 const xmlChar *value, 600 int len); 601 /** 602 * warningSAXFunc: 603 * @ctx: an XML parser context 604 * @msg: the message to display/transmit 605 * @...: extra parameters for the message display 606 * 607 * Display and format a warning messages, callback. 608 */ 609 typedef void (*warningSAXFunc) (void *ctx, 610 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); 611 /** 612 * errorSAXFunc: 613 * @ctx: an XML parser context 614 * @msg: the message to display/transmit 615 * @...: extra parameters for the message display 616 * 617 * Display and format an error messages, callback. 618 */ 619 typedef void (*errorSAXFunc) (void *ctx, 620 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); 621 /** 622 * fatalErrorSAXFunc: 623 * @ctx: an XML parser context 624 * @msg: the message to display/transmit 625 * @...: extra parameters for the message display 626 * 627 * Display and format fatal error messages, callback. 628 * Note: so far fatalError() SAX callbacks are not used, error() 629 * get all the callbacks for errors. 630 */ 631 typedef void (*fatalErrorSAXFunc) (void *ctx, 632 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); 633 /** 634 * isStandaloneSAXFunc: 635 * @ctx: the user data (XML parser context) 636 * 637 * Is this document tagged standalone? 638 * 639 * Returns 1 if true 640 */ 641 typedef int (*isStandaloneSAXFunc) (void *ctx); 642 /** 643 * hasInternalSubsetSAXFunc: 644 * @ctx: the user data (XML parser context) 645 * 646 * Does this document has an internal subset. 647 * 648 * Returns 1 if true 649 */ 650 typedef int (*hasInternalSubsetSAXFunc) (void *ctx); 651 652 /** 653 * hasExternalSubsetSAXFunc: 654 * @ctx: the user data (XML parser context) 655 * 656 * Does this document has an external subset? 657 * 658 * Returns 1 if true 659 */ 660 typedef int (*hasExternalSubsetSAXFunc) (void *ctx); 661 662 /************************************************************************ 663 * * 664 * The SAX version 2 API extensions * 665 * * 666 ************************************************************************/ 667 /** 668 * XML_SAX2_MAGIC: 669 * 670 * Special constant found in SAX2 blocks initialized fields 671 */ 672 #define XML_SAX2_MAGIC 0xDEEDBEAF 673 674 /** 675 * startElementNsSAX2Func: 676 * @ctx: the user data (XML parser context) 677 * @localname: the local name of the element 678 * @prefix: the element namespace prefix if available 679 * @URI: the element namespace name if available 680 * @nb_namespaces: number of namespace definitions on that node 681 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions 682 * @nb_attributes: the number of attributes on that node 683 * @nb_defaulted: the number of defaulted attributes. The defaulted 684 * ones are at the end of the array 685 * @attributes: pointer to the array of (localname/prefix/URI/value/end) 686 * attribute values. 687 * 688 * SAX2 callback when an element start has been detected by the parser. 689 * It provides the namespace information for the element, as well as 690 * the new namespace declarations on the element. 691 */ 692 693 typedef void (*startElementNsSAX2Func) (void *ctx, 694 const xmlChar *localname, 695 const xmlChar *prefix, 696 const xmlChar *URI, 697 int nb_namespaces, 698 const xmlChar **namespaces, 699 int nb_attributes, 700 int nb_defaulted, 701 const xmlChar **attributes); 702 703 /** 704 * endElementNsSAX2Func: 705 * @ctx: the user data (XML parser context) 706 * @localname: the local name of the element 707 * @prefix: the element namespace prefix if available 708 * @URI: the element namespace name if available 709 * 710 * SAX2 callback when an element end has been detected by the parser. 711 * It provides the namespace information for the element. 712 */ 713 714 typedef void (*endElementNsSAX2Func) (void *ctx, 715 const xmlChar *localname, 716 const xmlChar *prefix, 717 const xmlChar *URI); 718 719 720 struct _xmlSAXHandler { 721 internalSubsetSAXFunc internalSubset; 722 isStandaloneSAXFunc isStandalone; 723 hasInternalSubsetSAXFunc hasInternalSubset; 724 hasExternalSubsetSAXFunc hasExternalSubset; 725 resolveEntitySAXFunc resolveEntity; 726 getEntitySAXFunc getEntity; 727 entityDeclSAXFunc entityDecl; 728 notationDeclSAXFunc notationDecl; 729 attributeDeclSAXFunc attributeDecl; 730 elementDeclSAXFunc elementDecl; 731 unparsedEntityDeclSAXFunc unparsedEntityDecl; 732 setDocumentLocatorSAXFunc setDocumentLocator; 733 startDocumentSAXFunc startDocument; 734 endDocumentSAXFunc endDocument; 735 /* 736 * `startElement` and `endElement` are only used by the legacy SAX1 737 * interface and should not be used in new software. If you really 738 * have to enable SAX1, the preferred way is set the `initialized` 739 * member to 1 instead of XML_SAX2_MAGIC. 740 * 741 * For backward compatibility, it's also possible to set the 742 * `startElementNs` and `endElementNs` handlers to NULL. 743 * 744 * You can also set the XML_PARSE_SAX1 parser option, but versions 745 * older than 2.12.0 will probably crash if this option is provided 746 * together with custom SAX callbacks. 747 */ 748 startElementSAXFunc startElement; 749 endElementSAXFunc endElement; 750 referenceSAXFunc reference; 751 charactersSAXFunc characters; 752 ignorableWhitespaceSAXFunc ignorableWhitespace; 753 processingInstructionSAXFunc processingInstruction; 754 commentSAXFunc comment; 755 warningSAXFunc warning; 756 errorSAXFunc error; 757 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ 758 getParameterEntitySAXFunc getParameterEntity; 759 cdataBlockSAXFunc cdataBlock; 760 externalSubsetSAXFunc externalSubset; 761 /* 762 * `initialized` should always be set to XML_SAX2_MAGIC to enable the 763 * modern SAX2 interface. 764 */ 765 unsigned int initialized; 766 /* 767 * The following members are only used by the SAX2 interface. 768 */ 769 void *_private; 770 startElementNsSAX2Func startElementNs; 771 endElementNsSAX2Func endElementNs; 772 xmlStructuredErrorFunc serror; 773 }; 774 775 /* 776 * SAX Version 1 777 */ 778 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; 779 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; 780 struct _xmlSAXHandlerV1 { 781 internalSubsetSAXFunc internalSubset; 782 isStandaloneSAXFunc isStandalone; 783 hasInternalSubsetSAXFunc hasInternalSubset; 784 hasExternalSubsetSAXFunc hasExternalSubset; 785 resolveEntitySAXFunc resolveEntity; 786 getEntitySAXFunc getEntity; 787 entityDeclSAXFunc entityDecl; 788 notationDeclSAXFunc notationDecl; 789 attributeDeclSAXFunc attributeDecl; 790 elementDeclSAXFunc elementDecl; 791 unparsedEntityDeclSAXFunc unparsedEntityDecl; 792 setDocumentLocatorSAXFunc setDocumentLocator; 793 startDocumentSAXFunc startDocument; 794 endDocumentSAXFunc endDocument; 795 startElementSAXFunc startElement; 796 endElementSAXFunc endElement; 797 referenceSAXFunc reference; 798 charactersSAXFunc characters; 799 ignorableWhitespaceSAXFunc ignorableWhitespace; 800 processingInstructionSAXFunc processingInstruction; 801 commentSAXFunc comment; 802 warningSAXFunc warning; 803 errorSAXFunc error; 804 fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ 805 getParameterEntitySAXFunc getParameterEntity; 806 cdataBlockSAXFunc cdataBlock; 807 externalSubsetSAXFunc externalSubset; 808 unsigned int initialized; 809 }; 810 811 812 /** 813 * xmlExternalEntityLoader: 814 * @URL: The System ID of the resource requested 815 * @ID: The Public ID of the resource requested 816 * @context: the XML parser context 817 * 818 * External entity loaders types. 819 * 820 * Returns the entity input parser. 821 */ 822 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, 823 const char *ID, 824 xmlParserCtxtPtr context); 825 826 /* 827 * Variables 828 */ 829 830 XMLPUBVAR const char *const xmlParserVersion; 831 XML_DEPRECATED 832 XMLPUBVAR const int oldXMLWDcompatibility; 833 XML_DEPRECATED 834 XMLPUBVAR const int xmlParserDebugEntities; 835 XML_DEPRECATED 836 XMLPUBVAR const xmlSAXLocator xmlDefaultSAXLocator; 837 #ifdef LIBXML_SAX1_ENABLED 838 XML_DEPRECATED 839 XMLPUBVAR const xmlSAXHandlerV1 xmlDefaultSAXHandler; 840 #endif 841 842 #ifdef LIBXML_THREAD_ENABLED 843 /* backward compatibility */ 844 XMLPUBFUN const char *const *__xmlParserVersion(void); 845 XML_DEPRECATED 846 XMLPUBFUN const int *__oldXMLWDcompatibility(void); 847 XML_DEPRECATED 848 XMLPUBFUN const int *__xmlParserDebugEntities(void); 849 XML_DEPRECATED 850 XMLPUBFUN const xmlSAXLocator *__xmlDefaultSAXLocator(void); 851 #ifdef LIBXML_SAX1_ENABLED 852 XML_DEPRECATED 853 XMLPUBFUN const xmlSAXHandlerV1 *__xmlDefaultSAXHandler(void); 854 #endif 855 #endif 856 857 /** DOC_DISABLE */ 858 #define XML_GLOBALS_PARSER_CORE \ 859 XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \ 860 XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \ 861 XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \ 862 XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \ 863 XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \ 864 XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \ 865 XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED) 866 867 #ifdef LIBXML_OUTPUT_ENABLED 868 #define XML_GLOBALS_PARSER_OUTPUT \ 869 XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \ 870 XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \ 871 XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR) 872 #else 873 #define XML_GLOBALS_PARSER_OUTPUT 874 #endif 875 876 #define XML_GLOBALS_PARSER \ 877 XML_GLOBALS_PARSER_CORE \ 878 XML_GLOBALS_PARSER_OUTPUT 879 880 #define XML_OP XML_DECLARE_GLOBAL 881 XML_GLOBALS_PARSER 882 #undef XML_OP 883 884 #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION) 885 #define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility) 886 #define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler) 887 #define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator) 888 #define xmlDoValidityCheckingDefaultValue \ 889 XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue) 890 #define xmlGetWarningsDefaultValue \ 891 XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue) 892 #define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue) 893 #define xmlLineNumbersDefaultValue \ 894 XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue) 895 #define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue) 896 #define xmlPedanticParserDefaultValue \ 897 XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue) 898 #define xmlSubstituteEntitiesDefaultValue \ 899 XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue) 900 #ifdef LIBXML_OUTPUT_ENABLED 901 #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput) 902 #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString) 903 #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags) 904 #endif 905 #endif 906 /** DOC_ENABLE */ 907 908 /* 909 * Init/Cleanup 910 */ 911 XMLPUBFUN void 912 xmlInitParser (void); 913 XMLPUBFUN void 914 xmlCleanupParser (void); 915 XML_DEPRECATED 916 XMLPUBFUN void 917 xmlInitGlobals (void); 918 XML_DEPRECATED 919 XMLPUBFUN void 920 xmlCleanupGlobals (void); 921 922 /* 923 * Input functions 924 */ 925 XML_DEPRECATED 926 XMLPUBFUN int 927 xmlParserInputRead (xmlParserInputPtr in, 928 int len); 929 XML_DEPRECATED 930 XMLPUBFUN int 931 xmlParserInputGrow (xmlParserInputPtr in, 932 int len); 933 934 /* 935 * Basic parsing Interfaces 936 */ 937 #ifdef LIBXML_SAX1_ENABLED 938 XMLPUBFUN xmlDocPtr 939 xmlParseDoc (const xmlChar *cur); 940 XMLPUBFUN xmlDocPtr 941 xmlParseFile (const char *filename); 942 XMLPUBFUN xmlDocPtr 943 xmlParseMemory (const char *buffer, 944 int size); 945 #endif /* LIBXML_SAX1_ENABLED */ 946 XML_DEPRECATED XMLPUBFUN int 947 xmlSubstituteEntitiesDefault(int val); 948 XML_DEPRECATED XMLPUBFUN int 949 xmlThrDefSubstituteEntitiesDefaultValue(int v); 950 XML_DEPRECATED XMLPUBFUN int 951 xmlKeepBlanksDefault (int val); 952 XML_DEPRECATED XMLPUBFUN int 953 xmlThrDefKeepBlanksDefaultValue(int v); 954 XMLPUBFUN void 955 xmlStopParser (xmlParserCtxtPtr ctxt); 956 XML_DEPRECATED XMLPUBFUN int 957 xmlPedanticParserDefault(int val); 958 XML_DEPRECATED XMLPUBFUN int 959 xmlThrDefPedanticParserDefaultValue(int v); 960 XML_DEPRECATED XMLPUBFUN int 961 xmlLineNumbersDefault (int val); 962 XML_DEPRECATED XMLPUBFUN int 963 xmlThrDefLineNumbersDefaultValue(int v); 964 XML_DEPRECATED XMLPUBFUN int 965 xmlThrDefDoValidityCheckingDefaultValue(int v); 966 XML_DEPRECATED XMLPUBFUN int 967 xmlThrDefGetWarningsDefaultValue(int v); 968 XML_DEPRECATED XMLPUBFUN int 969 xmlThrDefLoadExtDtdDefaultValue(int v); 970 XML_DEPRECATED XMLPUBFUN int 971 xmlThrDefParserDebugEntities(int v); 972 973 #ifdef LIBXML_SAX1_ENABLED 974 /* 975 * Recovery mode 976 */ 977 XML_DEPRECATED 978 XMLPUBFUN xmlDocPtr 979 xmlRecoverDoc (const xmlChar *cur); 980 XML_DEPRECATED 981 XMLPUBFUN xmlDocPtr 982 xmlRecoverMemory (const char *buffer, 983 int size); 984 XML_DEPRECATED 985 XMLPUBFUN xmlDocPtr 986 xmlRecoverFile (const char *filename); 987 #endif /* LIBXML_SAX1_ENABLED */ 988 989 /* 990 * Less common routines and SAX interfaces 991 */ 992 XMLPUBFUN int 993 xmlParseDocument (xmlParserCtxtPtr ctxt); 994 XMLPUBFUN int 995 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); 996 #ifdef LIBXML_SAX1_ENABLED 997 XML_DEPRECATED 998 XMLPUBFUN int 999 xmlSAXUserParseFile (xmlSAXHandlerPtr sax, 1000 void *user_data, 1001 const char *filename); 1002 XML_DEPRECATED 1003 XMLPUBFUN int 1004 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, 1005 void *user_data, 1006 const char *buffer, 1007 int size); 1008 XML_DEPRECATED 1009 XMLPUBFUN xmlDocPtr 1010 xmlSAXParseDoc (xmlSAXHandlerPtr sax, 1011 const xmlChar *cur, 1012 int recovery); 1013 // TODO(https://github.com/google/maldoca/issues/87): Re-Deprecate this when 1014 // maldoca stops using xmlSAXParseMemory. 1015 //XML_DEPRECATED 1016 XMLPUBFUN xmlDocPtr 1017 xmlSAXParseMemory (xmlSAXHandlerPtr sax, 1018 const char *buffer, 1019 int size, 1020 int recovery); 1021 XML_DEPRECATED 1022 XMLPUBFUN xmlDocPtr 1023 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, 1024 const char *buffer, 1025 int size, 1026 int recovery, 1027 void *data); 1028 XML_DEPRECATED 1029 XMLPUBFUN xmlDocPtr 1030 xmlSAXParseFile (xmlSAXHandlerPtr sax, 1031 const char *filename, 1032 int recovery); 1033 XML_DEPRECATED 1034 XMLPUBFUN xmlDocPtr 1035 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, 1036 const char *filename, 1037 int recovery, 1038 void *data); 1039 XML_DEPRECATED 1040 XMLPUBFUN xmlDocPtr 1041 xmlSAXParseEntity (xmlSAXHandlerPtr sax, 1042 const char *filename); 1043 XML_DEPRECATED 1044 XMLPUBFUN xmlDocPtr 1045 xmlParseEntity (const char *filename); 1046 #endif /* LIBXML_SAX1_ENABLED */ 1047 1048 #ifdef LIBXML_VALID_ENABLED 1049 XML_DEPRECATED 1050 XMLPUBFUN xmlDtdPtr 1051 xmlSAXParseDTD (xmlSAXHandlerPtr sax, 1052 const xmlChar *ExternalID, 1053 const xmlChar *SystemID); 1054 XMLPUBFUN xmlDtdPtr 1055 xmlParseDTD (const xmlChar *ExternalID, 1056 const xmlChar *SystemID); 1057 XMLPUBFUN xmlDtdPtr 1058 xmlIOParseDTD (xmlSAXHandlerPtr sax, 1059 xmlParserInputBufferPtr input, 1060 xmlCharEncoding enc); 1061 #endif /* LIBXML_VALID_ENABLE */ 1062 #ifdef LIBXML_SAX1_ENABLED 1063 XMLPUBFUN int 1064 xmlParseBalancedChunkMemory(xmlDocPtr doc, 1065 xmlSAXHandlerPtr sax, 1066 void *user_data, 1067 int depth, 1068 const xmlChar *string, 1069 xmlNodePtr *lst); 1070 #endif /* LIBXML_SAX1_ENABLED */ 1071 XMLPUBFUN xmlParserErrors 1072 xmlParseInNodeContext (xmlNodePtr node, 1073 const char *data, 1074 int datalen, 1075 int options, 1076 xmlNodePtr *lst); 1077 #ifdef LIBXML_SAX1_ENABLED 1078 XMLPUBFUN int 1079 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, 1080 xmlSAXHandlerPtr sax, 1081 void *user_data, 1082 int depth, 1083 const xmlChar *string, 1084 xmlNodePtr *lst, 1085 int recover); 1086 XML_DEPRECATED 1087 XMLPUBFUN int 1088 xmlParseExternalEntity (xmlDocPtr doc, 1089 xmlSAXHandlerPtr sax, 1090 void *user_data, 1091 int depth, 1092 const xmlChar *URL, 1093 const xmlChar *ID, 1094 xmlNodePtr *lst); 1095 #endif /* LIBXML_SAX1_ENABLED */ 1096 XMLPUBFUN int 1097 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, 1098 const xmlChar *URL, 1099 const xmlChar *ID, 1100 xmlNodePtr *lst); 1101 1102 /* 1103 * Parser contexts handling. 1104 */ 1105 XMLPUBFUN xmlParserCtxtPtr 1106 xmlNewParserCtxt (void); 1107 XMLPUBFUN xmlParserCtxtPtr 1108 xmlNewSAXParserCtxt (const xmlSAXHandler *sax, 1109 void *userData); 1110 XMLPUBFUN int 1111 xmlInitParserCtxt (xmlParserCtxtPtr ctxt); 1112 XMLPUBFUN void 1113 xmlClearParserCtxt (xmlParserCtxtPtr ctxt); 1114 XMLPUBFUN void 1115 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); 1116 #ifdef LIBXML_SAX1_ENABLED 1117 XML_DEPRECATED 1118 XMLPUBFUN void 1119 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, 1120 const xmlChar* buffer, 1121 const char *filename); 1122 #endif /* LIBXML_SAX1_ENABLED */ 1123 XMLPUBFUN xmlParserCtxtPtr 1124 xmlCreateDocParserCtxt (const xmlChar *cur); 1125 1126 #ifdef LIBXML_LEGACY_ENABLED 1127 /* 1128 * Reading/setting optional parsing features. 1129 */ 1130 XML_DEPRECATED 1131 XMLPUBFUN int 1132 xmlGetFeaturesList (int *len, 1133 const char **result); 1134 XML_DEPRECATED 1135 XMLPUBFUN int 1136 xmlGetFeature (xmlParserCtxtPtr ctxt, 1137 const char *name, 1138 void *result); 1139 XML_DEPRECATED 1140 XMLPUBFUN int 1141 xmlSetFeature (xmlParserCtxtPtr ctxt, 1142 const char *name, 1143 void *value); 1144 #endif /* LIBXML_LEGACY_ENABLED */ 1145 1146 #ifdef LIBXML_PUSH_ENABLED 1147 /* 1148 * Interfaces for the Push mode. 1149 */ 1150 XMLPUBFUN xmlParserCtxtPtr 1151 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, 1152 void *user_data, 1153 const char *chunk, 1154 int size, 1155 const char *filename); 1156 XMLPUBFUN int 1157 xmlParseChunk (xmlParserCtxtPtr ctxt, 1158 const char *chunk, 1159 int size, 1160 int terminate); 1161 #endif /* LIBXML_PUSH_ENABLED */ 1162 1163 /* 1164 * Special I/O mode. 1165 */ 1166 1167 XMLPUBFUN xmlParserCtxtPtr 1168 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, 1169 void *user_data, 1170 xmlInputReadCallback ioread, 1171 xmlInputCloseCallback ioclose, 1172 void *ioctx, 1173 xmlCharEncoding enc); 1174 1175 XMLPUBFUN xmlParserInputPtr 1176 xmlNewIOInputStream (xmlParserCtxtPtr ctxt, 1177 xmlParserInputBufferPtr input, 1178 xmlCharEncoding enc); 1179 1180 /* 1181 * Node infos. 1182 */ 1183 XMLPUBFUN const xmlParserNodeInfo* 1184 xmlParserFindNodeInfo (xmlParserCtxtPtr ctxt, 1185 xmlNodePtr node); 1186 XMLPUBFUN void 1187 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); 1188 XMLPUBFUN void 1189 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); 1190 XMLPUBFUN unsigned long 1191 xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq, 1192 xmlNodePtr node); 1193 XMLPUBFUN void 1194 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, 1195 xmlParserNodeInfoPtr info); 1196 1197 /* 1198 * External entities handling actually implemented in xmlIO. 1199 */ 1200 1201 XMLPUBFUN void 1202 xmlSetExternalEntityLoader(xmlExternalEntityLoader f); 1203 XMLPUBFUN xmlExternalEntityLoader 1204 xmlGetExternalEntityLoader(void); 1205 XMLPUBFUN xmlParserInputPtr 1206 xmlLoadExternalEntity (const char *URL, 1207 const char *ID, 1208 xmlParserCtxtPtr ctxt); 1209 1210 /* 1211 * Index lookup, actually implemented in the encoding module 1212 */ 1213 XMLPUBFUN long 1214 xmlByteConsumed (xmlParserCtxtPtr ctxt); 1215 1216 /* 1217 * New set of simpler/more flexible APIs 1218 */ 1219 /** 1220 * xmlParserOption: 1221 * 1222 * This is the set of XML parser options that can be passed down 1223 * to the xmlReadDoc() and similar calls. 1224 */ 1225 typedef enum { 1226 XML_PARSE_RECOVER = 1<<0, /* recover on errors */ 1227 XML_PARSE_NOENT = 1<<1, /* substitute entities */ 1228 XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ 1229 XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ 1230 XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ 1231 XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ 1232 XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ 1233 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ 1234 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ 1235 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ 1236 XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */ 1237 XML_PARSE_NONET = 1<<11,/* Forbid network access */ 1238 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */ 1239 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ 1240 XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ 1241 XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ 1242 XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of 1243 the tree allowed afterwards (will possibly 1244 crash if you try to modify the tree) */ 1245 XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */ 1246 XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */ 1247 XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */ 1248 XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */ 1249 XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */ 1250 XML_PARSE_BIG_LINES = 1<<22,/* Store big lines numbers in text PSVI field */ 1251 XML_PARSE_NO_XXE = 1<<23 /* disable loading of external content */ 1252 } xmlParserOption; 1253 1254 XMLPUBFUN void 1255 xmlCtxtReset (xmlParserCtxtPtr ctxt); 1256 XMLPUBFUN int 1257 xmlCtxtResetPush (xmlParserCtxtPtr ctxt, 1258 const char *chunk, 1259 int size, 1260 const char *filename, 1261 const char *encoding); 1262 XMLPUBFUN int 1263 xmlCtxtSetOptions (xmlParserCtxtPtr ctxt, 1264 int options); 1265 XMLPUBFUN int 1266 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, 1267 int options); 1268 XMLPUBFUN void 1269 xmlCtxtSetErrorHandler (xmlParserCtxtPtr ctxt, 1270 xmlStructuredErrorFunc handler, 1271 void *data); 1272 XMLPUBFUN void 1273 xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt, 1274 unsigned maxAmpl); 1275 XMLPUBFUN xmlDocPtr 1276 xmlReadDoc (const xmlChar *cur, 1277 const char *URL, 1278 const char *encoding, 1279 int options); 1280 XMLPUBFUN xmlDocPtr 1281 xmlReadFile (const char *URL, 1282 const char *encoding, 1283 int options); 1284 XMLPUBFUN xmlDocPtr 1285 xmlReadMemory (const char *buffer, 1286 int size, 1287 const char *URL, 1288 const char *encoding, 1289 int options); 1290 XMLPUBFUN xmlDocPtr 1291 xmlReadFd (int fd, 1292 const char *URL, 1293 const char *encoding, 1294 int options); 1295 XMLPUBFUN xmlDocPtr 1296 xmlReadIO (xmlInputReadCallback ioread, 1297 xmlInputCloseCallback ioclose, 1298 void *ioctx, 1299 const char *URL, 1300 const char *encoding, 1301 int options); 1302 XMLPUBFUN xmlDocPtr 1303 xmlCtxtParseDocument (xmlParserCtxtPtr ctxt, 1304 xmlParserInputPtr input); 1305 XMLPUBFUN xmlDocPtr 1306 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, 1307 const xmlChar *cur, 1308 const char *URL, 1309 const char *encoding, 1310 int options); 1311 XMLPUBFUN xmlDocPtr 1312 xmlCtxtReadFile (xmlParserCtxtPtr ctxt, 1313 const char *filename, 1314 const char *encoding, 1315 int options); 1316 XMLPUBFUN xmlDocPtr 1317 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, 1318 const char *buffer, 1319 int size, 1320 const char *URL, 1321 const char *encoding, 1322 int options); 1323 XMLPUBFUN xmlDocPtr 1324 xmlCtxtReadFd (xmlParserCtxtPtr ctxt, 1325 int fd, 1326 const char *URL, 1327 const char *encoding, 1328 int options); 1329 XMLPUBFUN xmlDocPtr 1330 xmlCtxtReadIO (xmlParserCtxtPtr ctxt, 1331 xmlInputReadCallback ioread, 1332 xmlInputCloseCallback ioclose, 1333 void *ioctx, 1334 const char *URL, 1335 const char *encoding, 1336 int options); 1337 1338 /* 1339 * Library wide options 1340 */ 1341 /** 1342 * xmlFeature: 1343 * 1344 * Used to examine the existence of features that can be enabled 1345 * or disabled at compile-time. 1346 * They used to be called XML_FEATURE_xxx but this clashed with Expat 1347 */ 1348 typedef enum { 1349 XML_WITH_THREAD = 1, 1350 XML_WITH_TREE = 2, 1351 XML_WITH_OUTPUT = 3, 1352 XML_WITH_PUSH = 4, 1353 XML_WITH_READER = 5, 1354 XML_WITH_PATTERN = 6, 1355 XML_WITH_WRITER = 7, 1356 XML_WITH_SAX1 = 8, 1357 XML_WITH_FTP = 9, 1358 XML_WITH_HTTP = 10, 1359 XML_WITH_VALID = 11, 1360 XML_WITH_HTML = 12, 1361 XML_WITH_LEGACY = 13, 1362 XML_WITH_C14N = 14, 1363 XML_WITH_CATALOG = 15, 1364 XML_WITH_XPATH = 16, 1365 XML_WITH_XPTR = 17, 1366 XML_WITH_XINCLUDE = 18, 1367 XML_WITH_ICONV = 19, 1368 XML_WITH_ISO8859X = 20, 1369 XML_WITH_UNICODE = 21, 1370 XML_WITH_REGEXP = 22, 1371 XML_WITH_AUTOMATA = 23, 1372 XML_WITH_EXPR = 24, 1373 XML_WITH_SCHEMAS = 25, 1374 XML_WITH_SCHEMATRON = 26, 1375 XML_WITH_MODULES = 27, 1376 XML_WITH_DEBUG = 28, 1377 XML_WITH_DEBUG_MEM = 29, 1378 XML_WITH_DEBUG_RUN = 30, /* unused */ 1379 XML_WITH_ZLIB = 31, 1380 XML_WITH_ICU = 32, 1381 XML_WITH_LZMA = 33, 1382 XML_WITH_NONE = 99999 /* just to be sure of allocation size */ 1383 } xmlFeature; 1384 1385 XMLPUBFUN int 1386 xmlHasFeature (xmlFeature feature); 1387 1388 #ifdef __cplusplus 1389 } 1390 #endif 1391 #endif /* __XML_PARSER_H__ */ 1392