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