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{$IFDEF POINTER} 11 xmlParserInputPtr = ^xmlParserInput; 12 xmlParserInputPtrPtr = ^xmlParserInputPtr; 13 xmlParserNodeInfoPtr = ^xmlParserNodeInfo; 14 xmlParserNodeInfoSeqPtr = ^xmlParserNodeInfoSeq; 15 xmlParserCtxtPtr = ^xmlParserCtxt; 16 xmlSAXLocatorPtr = ^xmlSAXLocator; 17 xmlSAXHandlerPtr = ^xmlSAXHandler; 18 xmlSAXHandlerV1Ptr = ^xmlSAXHandlerV1; 19{$ENDIF} 20 21{$IFDEF CONST} 22(** 23 * XML_DEFAULT_VERSION: 24 * 25 * The default version of XML used: 1.0 26 *) 27 XML_DEFAULT_VERSION = '1.0'; 28{$ENDIF} 29 30{$IFDEF TYPE} 31(** 32 * xmlParserInput: 33 * 34 * An xmlParserInput is an input flow for the XML processor. 35 * Each entity parsed is associated an xmlParserInput (except the 36 * few predefined ones). This is the case both for internal entities 37 * - in which case the flow is already completely in memory - or 38 * external entities - in which case we use the buf structure for 39 * progressive reading and I18N conversions to the internal UTF-8 format. 40 *) 41 42(** 43 * xmlParserInputDeallocate: 44 * @str: the string to deallocate 45 * 46 * Callback for freeing some parser input allocations. 47 *) 48 xmlParserInputDeallocate = procedure(str: xmlCharPtr); EXTDECL; 49 50 xmlParserInput = record 51 (* Input buffer *) 52 buf : xmlParserInputBufferPtr; (* UTF-8 encoded buffer *) 53 54 filename : pchar; (* The file analyzed, if any *) 55 directory : pchar; (* the directory/base of the file *) 56 base : xmlCharPtr; (* Base of the array to parse *) 57 cur : xmlCharPtr; (* Current char being parsed *) 58 _end : xmlCharPtr; (* end of the array to parse *) 59 length : cint; (* length if known *) 60 line : cint; (* Current line *) 61 col : cint; (* Current column *) 62 (* 63 * NOTE: consumed is only tested for equality in the parser code, 64 * so even if there is an overflow this should not give troubles 65 * for parsing very large instances. 66 *) 67 consumed : culong; (* How many xmlChars already consumed *) 68 free : xmlParserInputDeallocate; (* function to deallocate the base *) 69 encoding : xmlCharPtr; (* the encoding string for entity *) 70 version : xmlCharPtr; (* the version string for entity *) 71 standalone : cint; (* Was that entity marked standalone *) 72 id : cint; (* an unique identifier for the entity *) 73 end; 74 75(** 76 * xmlParserNodeInfo: 77 * 78 * The parser can be asked to collect Node informations, i.e. at what 79 * place in the file they were detected. 80 * NOTE: This is off by default and not very well tested. 81 *) 82 xmlParserNodeInfo = record 83 node : xmlNodePtr; 84 (* Position & line # that text that created the node begins & ends on *) 85 begin_pos : culong; 86 begin_line : culong; 87 end_pos : culong; 88 end_line : culong; 89 end; 90 91 xmlParserNodeInfoSeq = record 92 maximum : culong; 93 length : culong; 94 buffer : xmlParserNodeInfoPtr; 95 end; 96 97(** 98 * xmlParserInputState: 99 * 100 * The parser is now working also as a state based parser. 101 * The recursive one use the state info for entities processing. 102 *) 103 xmlParserInputState = ( 104 XML_PARSER_EOF = -1, (* nothing is to be parsed *) 105 XML_PARSER_START = 0, (* nothing has been parsed *) 106 XML_PARSER_MISC, (* Misc* before int subset *) 107 XML_PARSER_PI, (* Within a processing instruction *) 108 XML_PARSER_DTD, (* within some DTD content *) 109 XML_PARSER_PROLOG, (* Misc* after internal subset *) 110 XML_PARSER_COMMENT, (* within a comment *) 111 XML_PARSER_START_TAG, (* within a start tag *) 112 XML_PARSER_CONTENT, (* within the content *) 113 XML_PARSER_CDATA_SECTION, (* within a CDATA section *) 114 XML_PARSER_END_TAG, (* within a closing tag *) 115 XML_PARSER_ENTITY_DECL, (* within an entity declaration *) 116 XML_PARSER_ENTITY_VALUE, (* within an entity value in a decl *) 117 XML_PARSER_ATTRIBUTE_VALUE, (* within an attribute value *) 118 XML_PARSER_SYSTEM_LITERAL, (* within a SYSTEM value *) 119 XML_PARSER_EPILOG, (* the Misc* after the last end tag *) 120 XML_PARSER_IGNORE, (* within an IGNORED section *) 121 XML_PARSER_PUBLIC_LITERAL (* within a PUBLIC value *) 122 ); 123{$ENDIF} 124 125{$IFDEF CONST} 126(** 127 * XML_DETECT_IDS: 128 * 129 * Bit in the loadsubset context field to tell to do ID/REFs lookups. 130 * Use it to initialize xmlLoadExtDtdDefaultValue. 131 *) 132 XML_DETECT_IDS = 2; 133 134(** 135 * XML_COMPLETE_ATTRS: 136 * 137 * Bit in the loadsubset context field to tell to do complete the 138 * elements attributes lists with the ones defaulted from the DTDs. 139 * Use it to initialize xmlLoadExtDtdDefaultValue. 140 *) 141 XML_COMPLETE_ATTRS = 4; 142 143(** 144 * XML_SKIP_IDS: 145 * 146 * Bit in the loadsubset context field to tell to not do ID/REFs registration. 147 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. 148 *) 149 XML_SKIP_IDS = 8; 150{$ENDIF} 151 152{$IFDEF TYPE} 153(** 154 * xmlParserMode: 155 * 156 * A parser can operate in various modes 157 *) 158 xmlParserMode = ( 159 XML_PARSE_UNKNOWN = 0, 160 XML_PARSE_DOM = 1, 161 XML_PARSE_SAX = 2, 162 XML_PARSE_PUSH_DOM = 3, 163 XML_PARSE_PUSH_SAX = 4, 164 XML_PARSE_READER = 5 165 ); 166 167(** 168 * xmlParserCtxt: 169 * 170 * The parser context. 171 * NOTE This doesn't completely define the parser state, the (current ?) 172 * design of the parser uses recursive function calls since this allow 173 * and easy mapping from the production rules of the specification 174 * to the actual code. The drawback is that the actual function call 175 * also reflect the parser state. However most of the parsing routines 176 * takes as the only argument the parser context pointer, so migrating 177 * to a state based parser for progressive parsing shouldn't be too hard. 178 *) 179 xmlParserCtxt = record 180 sax : xmlSAXHandlerPtr; (* The SAX handler *) 181 userData : pointer; (* For SAX interface only, used by DOM build *) 182 myDoc : xmlDocPtr; (* the document being built *) 183 wellFormed : cint; (* is the document well formed *) 184 replaceEntities : cint; (* shall we replace entities ? *) 185 version : xmlCharPtr; (* the XML version string *) 186 encoding : xmlCharPtr; (* the declared encoding, if any *) 187 standalone : cint; (* standalone document *) 188 html : cint; (* an HTML(1)/Docbook(2) document *) 189 190 (* Input stream stack *) 191 input : xmlParserInputPtr; (* Current input stream *) 192 inputNr : cint; (* Number of current input streams *) 193 inputMax : cint; (* Max number of input streams *) 194 inputTab : xmlParserInputPtrPtr; (* stack of inputs *) 195 196 (* Node analysis stack only used for DOM building *) 197 node : xmlNodePtr; (* Current parsed Node *) 198 nodeNr : cint; (* Depth of the parsing stack *) 199 nodeMax : cint; (* Max depth of the parsing stack *) 200 nodeTab : xmlNodePtrPtr; (* array of nodes *) 201 202 record_info : cint; (* Whether node info should be kept *) 203 node_seq : xmlParserNodeInfoSeq; (* info about each node parsed *) 204 205 errNo : cint; (* error code *) 206 207 hasExternalSubset : cint; (* reference and external subset *) 208 hasPErefs : cint; (* the internal subset has PE refs *) 209 external : cint; (* are we parsing an external entity *) 210 211 valid : cint; (* is the document valid *) 212 validate : cint; (* shall we try to validate ? *) 213 vctxt : xmlValidCtxt; (* The validity context *) 214 215 instate : xmlParserInputState; (* current type of input *) 216 token : cint; (* next char look-ahead *) 217 218 directory : pchar; (* the data directory *) 219 220 (* Node name stack *) 221 name : xmlCharPtr; (* Current parsed Node *) 222 nameNr : cint; (* Depth of the parsing stack *) 223 nameMax : cint; (* Max depth of the parsing stack *) 224 nameTab : xmlCharPtrPtr; (* array of nodes *) 225 226 nbChars : culong; (* number of xmlChar processed *) 227 checkIndex : culong; (* used by progressive parsing lookup *) 228 keepBlanks : cint; (* ugly but ... *) 229 disableSAX : cint; (* SAX callbacks are disabled *) 230 inSubset : cint; (* Parsing is in int 1/ext 2 subset *) 231 intSubName : xmlCharPtr; (* name of subset *) 232 extSubURI : xmlCharPtr; (* URI of external subset *) 233 extSubSystem : xmlCharPtr; (* SYSTEM ID of external subset *) 234 235 (* xml:space values *) 236 space : pcint; (* Should the parser preserve spaces *) 237 spaceNr : cint; (* Depth of the parsing stack *) 238 spaceMax : cint; (* Max depth of the parsing stack *) 239 spaceTab : pcint; (* array of space infos *) 240 241 depth : cint; (* to prevent entity substitution loops *) 242 entity : xmlParserInputPtr; (* used to check entities boundaries *) 243 charset : cint; (* encoding of the in-memory content 244 actually an xmlCharEncoding *) 245 nodelen : cint; (* Those two fields are there to *) 246 nodemem : cint; (* Speed up large node parsing *) 247 pedantic : cint; (* signal pedantic warnings *) 248 _private : pointer; (* For user data, libxml won't touch it *) 249 250 loadsubset : cint; (* should the external subset be loaded *) 251 linenumbers : cint; (* set line number in element content *) 252 catalogs : pointer; (* document's own catalog *) 253 recovery : cint; (* run in recovery mode *) 254 progressive : cint; (* is this a progressive parsing *) 255 dict : xmlDictPtr; (* dictionnary for the parser *) 256 atts : xmlCharPtrPtr; (* array for the attributes callbacks *) 257 maxatts : cint; (* the size of the array *) 258 docdict : cint; (* use strings from dict to build tree *) 259 260 (* 261 * pre-interned strings 262 *) 263 str_xml : xmlCharPtr; 264 str_xmlns : xmlCharPtr; 265 str_xml_ns : xmlCharPtr; 266 267 (* 268 * Everything below is used only by the new SAX mode 269 *) 270 sax2 : cint; (* operating in the new SAX mode *) 271 nsNr : cint; (* the number of inherited namespaces *) 272 nsMax : cint; (* the size of the arrays *) 273 nsTab : xmlCharPtrPtr; (* the array of prefix/namespace name *) 274 attallocs : pcint; (* which attribute were allocated *) 275 pushTab : ppointer; (* array of data for push *) 276 attsDefault : xmlHashTablePtr; (* defaulted attributes if any *) 277 attsSpecial : xmlHashTablePtr; (* non-CDATA attributes if any *) 278 nsWellFormed : cint; (* is the document XML Nanespace okay *) 279 options : cint; (* Extra options *) 280 281 (* 282 * Those fields are needed only for treaming parsing so far 283 *) 284 dictNames : cint; (* Use dictionary names for the tree *) 285 freeElemsNr : cint; (* number of freed element nodes *) 286 freeElems : xmlNodePtr; (* List of freed element nodes *) 287 freeAttrsNr : cint; (* number of freed attributes nodes *) 288 freeAttrs : xmlAttrPtr; (* List of freed attributes nodes *) 289 290 (* 291 * the complete error informations for the last error. 292 *) 293 lastError : xmlError; 294 parseMode : xmlParserMode; (* the parser mode *) 295 end; 296 297(** 298 * xmlSAXLocator: 299 * 300 * A SAX Locator. 301 *) 302 getPublicIdFunc = function(ctx: pointer): xmlCharPtr; EXTDECL; 303 getSystemIdFunc = function(ctx: pointer): xmlCharPtr; EXTDECL; 304 getLineNumberFunc = function(ctx: pointer): cint; EXTDECL; 305 getColumnNumberFunc = function(ctx: pointer): cint; EXTDECL; 306 307 xmlSAXLocator = record 308 getPublicId : getPublicIdFunc; 309 getSystemId : getSystemIdFunc; 310 getLineNumber : getLineNumberFunc; 311 getColumnNumber : getColumnNumberFunc; 312 end; 313 314(** 315 * xmlSAXHandler: 316 * 317 * A SAX handler is bunch of callbacks called by the parser when processing 318 * of the input generate data or structure informations. 319 *) 320 321(** 322 * resolveEntitySAXFunc: 323 * @ctx: the user data (XML parser context) 324 * @publicId: The public ID of the entity 325 * @systemId: The system ID of the entity 326 * 327 * Callback: 328 * The entity loader, to control the loading of external entities, 329 * the application can either: 330 * - override this resolveEntity() callback in the SAX block 331 * - or better use the xmlSetExternalEntityLoader() function to 332 * set up it's own entity resolution routine 333 * 334 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. 335 *) 336 resolveEntitySAXFunc = function(ctx: pointer; publicID, systemID: xmlCharPtr): xmlParserInputPtr; EXTDECL; 337 338(** 339 * internalSubsetSAXFunc: 340 * @ctx: the user data (XML parser context) 341 * @name: the root element name 342 * @ExternalID: the external ID 343 * @SystemID: the SYSTEM ID (e.g. filename or URL) 344 * 345 * Callback on internal subset declaration. 346 *) 347 internalSubsetSAXFunc = procedure(ctx: pointer; name, ExternalID, SystemID: xmlCharPtr); EXTDECL; 348 349(** 350 * externalSubsetSAXFunc: 351 * @ctx: the user data (XML parser context) 352 * @name: the root element name 353 * @ExternalID: the external ID 354 * @SystemID: the SYSTEM ID (e.g. filename or URL) 355 * 356 * Callback on external subset declaration. 357 *) 358 externalSubsetSAXFunc = procedure(ctx: pointer; name, ExternalID, SystemID: xmlCharPtr); EXTDECL; 359 360(** 361 * getEntitySAXFunc: 362 * @ctx: the user data (XML parser context) 363 * @name: The entity name 364 * 365 * Get an entity by name. 366 * 367 * Returns the xmlEntityPtr if found. 368 *) 369 getEntitySAXFunc = function(ctx: pointer; name: xmlCharPtr): xmlEntityPtr; EXTDECL; 370 371(** 372 * getParameterEntitySAXFunc: 373 * @ctx: the user data (XML parser context) 374 * @name: The entity name 375 * 376 * Get a parameter entity by name. 377 * 378 * Returns the xmlEntityPtr if found. 379 *) 380 getParameterEntitySAXFunc = function(ctx: pointer; name: xmlCharPtr): xmlEntityPtr; EXTDECL; 381 382(** 383 * entityDeclSAXFunc: 384 * @ctx: the user data (XML parser context) 385 * @name: the entity name 386 * @type: the entity type 387 * @publicId: The public ID of the entity 388 * @systemId: The system ID of the entity 389 * @content: the entity value (without processing). 390 * 391 * An entity definition has been parsed. 392 *) 393 entityDeclSAXFunc = procedure(ctx: pointer; name: xmlCharPtr; _type: cint; publicId, systemId, content: xmlCharPtr); EXTDECL; 394 395(** 396 * notationDeclSAXFunc: 397 * @ctx: the user data (XML parser context) 398 * @name: The name of the notation 399 * @publicId: The public ID of the entity 400 * @systemId: The system ID of the entity 401 * 402 * What to do when a notation declaration has been parsed. 403 *) 404 notationDeclSAXFunc = procedure(ctx: pointer; name, publicId, systemId: xmlCharPtr); EXTDECL; 405 406(** 407 * attributeDeclSAXFunc: 408 * @ctx: the user data (XML parser context) 409 * @elem: the name of the element 410 * @fullname: the attribute name 411 * @type: the attribute type 412 * @def: the type of default value 413 * @defaultValue: the attribute default value 414 * @tree: the tree of enumerated value set 415 * 416 * An attribute definition has been parsed. 417 *) 418 attributeDeclSAXFunc = procedure(ctx: pointer; elem, fullname: xmlCharPtr; _type, def: cint; defaultValue: xmlCharPtr; tree: xmlEnumerationPtr); EXTDECL; 419 420(** 421 * elementDeclSAXFunc: 422 * @ctx: the user data (XML parser context) 423 * @name: the element name 424 * @type: the element type 425 * @content: the element value tree 426 * 427 * An element definition has been parsed. 428 *) 429 elementDeclSAXFunc = procedure(ctx: pointer; name: xmlCharPtr; _type: cint; content: xmlElementContentPtr); EXTDECL; 430 431(** 432 * unparsedEntityDeclSAXFunc: 433 * @ctx: the user data (XML parser context) 434 * @name: The name of the entity 435 * @publicId: The public ID of the entity 436 * @systemId: The system ID of the entity 437 * @notationName: the name of the notation 438 * 439 * What to do when an unparsed entity declaration is parsed. 440 *) 441 unparsedEntityDeclSAXFunc = procedure(ctx: pointer; name, publicId, systemId, notationName: xmlCharPtr); EXTDECL; 442 443(** 444 * setDocumentLocatorSAXFunc: 445 * @ctx: the user data (XML parser context) 446 * @loc: A SAX Locator 447 * 448 * Receive the document locator at startup, actually xmlDefaultSAXLocator. 449 * Everything is available on the context, so this is useless in our case. 450 *) 451 setDocumentLocatorSAXFunc = procedure(ctx: pointer; loc: xmlSAXLocatorPtr); EXTDECL; 452 453(** 454 * startDocumentSAXFunc: 455 * @ctx: the user data (XML parser context) 456 * 457 * Called when the document start being processed. 458 *) 459 startDocumentSAXFunc = procedure(ctx: pointer); EXTDECL; 460 461(** 462 * endDocumentSAXFunc: 463 * @ctx: the user data (XML parser context) 464 * 465 * Called when the document end has been detected. 466 *) 467 endDocumentSAXFunc = procedure(ctx: pointer); EXTDECL; 468 469(** 470 * startElementSAXFunc: 471 * @ctx: the user data (XML parser context) 472 * @name: The element name, including namespace prefix 473 * @atts: An array of name/value attributes pairs, NULL terminated 474 * 475 * Called when an opening tag has been processed. 476 *) 477 startElementSAXFunc = procedure(ctx: pointer; name: xmlCharPtr; atts: xmlCharPtrPtr); EXTDECL; 478 479(** 480 * endElementSAXFunc: 481 * @ctx: the user data (XML parser context) 482 * @name: The element name 483 * 484 * Called when the end of an element has been detected. 485 *) 486 endElementSAXFunc = procedure(ctx: pointer; name: xmlCharPtr); EXTDECL; 487 488(** 489 * attributeSAXFunc: 490 * @ctx: the user data (XML parser context) 491 * @name: The attribute name, including namespace prefix 492 * @value: The attribute value 493 * 494 * Handle an attribute that has been read by the parser. 495 * The default handling is to convert the attribute into an 496 * DOM subtree and past it in a new xmlAttr element added to 497 * the element. 498 *) 499 attributeSAXFunc = procedure(ctx: pointer; name, value: xmlCharPtr); EXTDECL; 500 501(** 502 * referenceSAXFunc: 503 * @ctx: the user data (XML parser context) 504 * @name: The entity name 505 * 506 * Called when an entity reference is detected. 507 *) 508 referenceSAXFunc = procedure(ctx: pointer; name: xmlCharPtr); EXTDECL; 509 510(** 511 * charactersSAXFunc: 512 * @ctx: the user data (XML parser context) 513 * @ch: a xmlChar string 514 * @len: the number of xmlChar 515 * 516 * Receiving some chars from the parser. 517 *) 518 charactersSAXFunc = procedure(ctx: pointer; ch: xmlCharPtr; len: cint); EXTDECL; 519 520(** 521 * ignorableWhitespaceSAXFunc: 522 * @ctx: the user data (XML parser context) 523 * @ch: a xmlChar string 524 * @len: the number of xmlChar 525 * 526 * Receiving some ignorable whitespaces from the parser. 527 * UNUSED: by default the DOM building will use characters. 528 *) 529 ignorableWhitespaceSAXFunc = procedure(ctx: pointer; ch: xmlCharPtr; len: cint); EXTDECL; 530 531(** 532 * processingInstructionSAXFunc: 533 * @ctx: the user data (XML parser context) 534 * @target: the target name 535 * @data: the PI data's 536 * 537 * A processing instruction has been parsed. 538 *) 539 processingInstructionSAXFunc = procedure(ctx: pointer; target, data: xmlCharPtr); EXTDECL; 540 541(** 542 * commentSAXFunc: 543 * @ctx: the user data (XML parser context) 544 * @value: the comment content 545 * 546 * A comment has been parsed. 547 *) 548 commentSAXFunc = procedure(ctx: pointer; value: xmlCharPtr); EXTDECL; 549 550(** 551 * cdataBlockSAXFunc: 552 * @ctx: the user data (XML parser context) 553 * @value: The pcdata content 554 * @len: the block length 555 * 556 * Called when a pcdata block has been parsed. 557 *) 558 cdataBlockSAXFunc = procedure(ctx: pointer; value: xmlCharPtr; len: cint); EXTDECL; 559 560(** 561 * warningSAXFunc: 562 * @ctx: an XML parser context 563 * @msg: the message to display/transmit 564 * @...: extra parameters for the message display 565 * 566 * Display and format a warning messages, callback. 567 *) 568 warningSAXFunc = procedure(ctx: pointer; msg: pchar); cdecl; varargs; 569 570(** 571 * errorSAXFunc: 572 * @ctx: an XML parser context 573 * @msg: the message to display/transmit 574 * @...: extra parameters for the message display 575 * 576 * Display and format an error messages, callback. 577 *) 578 errorSAXFunc = procedure(ctx: pointer; msg: pchar); cdecl; varargs; 579 580(** 581 * fatalErrorSAXFunc: 582 * @ctx: an XML parser context 583 * @msg: the message to display/transmit 584 * @...: extra parameters for the message display 585 * 586 * Display and format fatal error messages, callback. 587 * Note: so far fatalError() SAX callbacks are not used, error() 588 * get all the callbacks for errors. 589 *) 590 fatalErrorSAXFunc = procedure(ctx: pointer; msg: pchar); cdecl; varargs; 591 592(** 593 * isStandaloneSAXFunc: 594 * @ctx: the user data (XML parser context) 595 * 596 * Is this document tagged standalone? 597 * 598 * Returns 1 if true 599 *) 600 isStandaloneSAXFunc = function(ctx: pointer): cint; EXTDECL; 601 602(** 603 * hasInternalSubsetSAXFunc: 604 * @ctx: the user data (XML parser context) 605 * 606 * Does this document has an internal subset. 607 * 608 * Returns 1 if true 609 *) 610 hasInternalSubsetSAXFunc = function(ctx: pointer): cint; EXTDECL; 611 612(** 613 * hasExternalSubsetSAXFunc: 614 * @ctx: the user data (XML parser context) 615 * 616 * Does this document has an external subset? 617 * 618 * Returns 1 if true 619 *) 620 hasExternalSubsetSAXFunc = function(ctx: pointer): cint; EXTDECL; 621{$ENDIF} 622 623(************************************************************************ 624 * * 625 * The SAX version 2 API extensions * 626 * * 627 ************************************************************************) 628(** 629 * XML_SAX2_MAGIC: 630 * 631 * Special constant found in SAX2 blocks initialized fields 632 *) 633{$IFDEF CONST} 634 XML_SAX2_MAGIC = $DEEDBEAF; 635{$ENDIF} 636 637{$IFDEF TYPE} 638(** 639 * startElementNsSAX2Func: 640 * @ctx: the user data (XML parser context) 641 * @localname: the local name of the element 642 * @prefix: the element namespace prefix if available 643 * @URI: the element namespace name if available 644 * @nb_namespaces: number of namespace definitions on that node 645 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions 646 * @nb_attributes: the number of attributes on that node 647 * @nb_defaulted: the number of defaulted attributes. The defaulted 648 * ones are at the end of the array 649 * @attributes: pointer to the array of (localname/prefix/URI/value/end) 650 * attribute values. 651 * 652 * SAX2 callback when an element start has been detected by the parser. 653 * It provides the namespace informations for the element, as well as 654 * the new namespace declarations on the element. 655 *) 656 startElementNsSAX2Func = procedure(ctx: pointer; localname, prefix, URI: xmlCharPtr; nb_namespaces: cint; 657 namespaces: xmlCharPtrPtr; nb_attributes, nb_defaulted: cint; attributes: xmlCharPtrPtr); EXTDECL; 658 659(** 660 * endElementNsSAX2Func: 661 * @ctx: the user data (XML parser context) 662 * @localname: the local name of the element 663 * @prefix: the element namespace prefix if available 664 * @URI: the element namespace name if available 665 * 666 * SAX2 callback when an element end has been detected by the parser. 667 * It provides the namespace informations for the element. 668 *) 669 endElementNsSAX2Func = procedure(ctx: pointer; localname, prefix, URI: xmlCharPtr); EXTDECL; 670 671 xmlSAXHandler = record 672 internalSubset: internalSubsetSAXFunc; 673 isStandalone: isStandaloneSAXFunc; 674 hasInternalSubset: hasInternalSubsetSAXFunc; 675 hasExternalSubset: hasExternalSubsetSAXFunc; 676 resolveEntity: resolveEntitySAXFunc; 677 getEntity: getEntitySAXFunc; 678 entityDecl: entityDeclSAXFunc; 679 notationDecl: notationDeclSAXFunc; 680 attributeDecl: attributeDeclSAXFunc; 681 elementDecl: elementDeclSAXFunc; 682 unparsedEntityDecl: unparsedEntityDeclSAXFunc; 683 setDocumentLocator: setDocumentLocatorSAXFunc; 684 startDocument: startDocumentSAXFunc; 685 endDocument: endDocumentSAXFunc; 686 startElement: startElementSAXFunc; 687 endElement: endElementSAXFunc; 688 reference: referenceSAXFunc; 689 characters: charactersSAXFunc; 690 ignorableWhitespace: ignorableWhitespaceSAXFunc; 691 processingInstruction: processingInstructionSAXFunc; 692 comment: commentSAXFunc; 693 warning: warningSAXFunc; 694 error: errorSAXFunc; 695 fatalError: fatalErrorSAXFunc; (* unused error() get all the errors *) 696 getParameterEntity: getParameterEntitySAXFunc; 697 cdataBlock: cdataBlockSAXFunc; 698 externalSubset: externalSubsetSAXFunc; 699 initialized: cuint; 700 (* The following fields are extensions available only on version 2 *) 701 _private: pointer; 702 startElementNs: startElementNsSAX2Func; 703 endElementNs: endElementNsSAX2Func; 704 serror: xmlStructuredErrorFunc; 705 end; 706 707(* 708 * SAX Version 1 709 *) 710 xmlSAXHandlerV1 = record 711 internalSubset: internalSubsetSAXFunc; 712 isStandalone: isStandaloneSAXFunc; 713 hasInternalSubset: hasInternalSubsetSAXFunc; 714 hasExternalSubset: hasExternalSubsetSAXFunc; 715 resolveEntity: resolveEntitySAXFunc; 716 getEntity: getEntitySAXFunc; 717 entityDecl: entityDeclSAXFunc; 718 notationDecl: notationDeclSAXFunc; 719 attributeDecl: attributeDeclSAXFunc; 720 elementDecl: elementDeclSAXFunc; 721 unparsedEntityDecl: unparsedEntityDeclSAXFunc; 722 setDocumentLocator: setDocumentLocatorSAXFunc; 723 startDocument: startDocumentSAXFunc; 724 endDocument: endDocumentSAXFunc; 725 startElement: startElementSAXFunc; 726 endElement: endElementSAXFunc; 727 reference: referenceSAXFunc; 728 characters: charactersSAXFunc; 729 ignorableWhitespace: ignorableWhitespaceSAXFunc; 730 processingInstruction: processingInstructionSAXFunc; 731 comment: commentSAXFunc; 732 warning: warningSAXFunc; 733 error: errorSAXFunc; 734 fatalError: fatalErrorSAXFunc; (* unused error() get all the errors *) 735 getParameterEntity: getParameterEntitySAXFunc; 736 cdataBlock: cdataBlockSAXFunc; 737 externalSubset: externalSubsetSAXFunc; 738 initialized: cuint; 739 end; 740 741 742(** 743 * xmlExternalEntityLoader: 744 * @URL: The System ID of the resource requested 745 * @ID: The Public ID of the resource requested 746 * @context: the XML parser context 747 * 748 * External entity loaders types. 749 * 750 * Returns the entity input parser. 751 *) 752 xmlExternalEntityLoader = function(URL, ID: pchar; context: xmlParserCtxtPtr): xmlParserInputPtr; EXTDECL; 753 754(** 755 * xmlParserOption: 756 * 757 * This is the set of XML parser options that can be passed down 758 * to the xmlReadDoc() and similar calls. 759 *) 760 xmlParserOption = type cint; 761{$ENDIF} 762{$IFDEF CONST} 763 XML_PARSE_RECOVER = (1 shl 0); (* recover on errors *) 764 XML_PARSE_NOENT = (1 shl 1); (* substitute entities *) 765 XML_PARSE_DTDLOAD = (1 shl 2); (* load the external subset *) 766 XML_PARSE_DTDATTR = (1 shl 3); (* default DTD attributes *) 767 XML_PARSE_DTDVALID = (1 shl 4); (* validate with the DTD *) 768 XML_PARSE_NOERROR = (1 shl 5); (* suppress error reports *) 769 XML_PARSE_NOWARNING = (1 shl 6); (* suppress warning reports *) 770 XML_PARSE_PEDANTIC = (1 shl 7); (* pedantic error reporting *) 771 XML_PARSE_NOBLANKS = (1 shl 8); (* remove blank nodes *) 772 XML_PARSE_SAX1 = (1 shl 9); (* use the SAX1 interface internally *) 773 XML_PARSE_XINCLUDE = (1 shl 10);(* Implement XInclude substitition *) 774 XML_PARSE_NONET = (1 shl 11);(* Forbid network access *) 775 XML_PARSE_NODICT = (1 shl 12);(* Do not reuse the context dictionnary *) 776 XML_PARSE_NSCLEAN = (1 shl 13);(* remove redundant namespaces declarations *) 777 XML_PARSE_NOCDATA = (1 shl 14);(* merge CDATA as text nodes *) 778 XML_PARSE_NOXINCNODE = (1 shl 15);(* do not generate XINCLUDE START/END nodes *) 779 XML_PARSE_COMPACT = (1 shl 16); (* compact small text nodes); no modification of 780 the tree allowed afterwards (will possibly 781 crash if you try to modify the tree) *) 782{$ENDIF} 783 784{$IFDEF TYPE} 785 xmlFeature = ( 786 XML_WITH_THREAD = 1, 787 XML_WITH_TREE = 2, 788 XML_WITH_OUTPUT = 3, 789 XML_WITH_PUSH = 4, 790 XML_WITH_READER = 5, 791 XML_WITH_PATTERN = 6, 792 XML_WITH_WRITER = 7, 793 XML_WITH_SAX1 = 8, 794 XML_WITH_FTP = 9, 795 XML_WITH_HTTP = 10, 796 XML_WITH_VALID = 11, 797 XML_WITH_HTML = 12, 798 XML_WITH_LEGACY = 13, 799 XML_WITH_C14N = 14, 800 XML_WITH_CATALOG = 15, 801 XML_WITH_XPATH = 16, 802 XML_WITH_XPTR = 17, 803 XML_WITH_XINCLUDE = 18, 804 XML_WITH_ICONV = 19, 805 XML_WITH_ISO8859X = 20, 806 XML_WITH_UNICODE = 21, 807 XML_WITH_REGEXP = 22, 808 XML_WITH_AUTOMATA = 23, 809 XML_WITH_EXPR = 24, 810 XML_WITH_SCHEMAS = 25, 811 XML_WITH_SCHEMATRON = 26, 812 XML_WITH_MODULES = 27, 813 XML_WITH_DEBUG = 28, 814 XML_WITH_DEBUG_MEM = 29, 815 XML_WITH_DEBUG_RUN = 30, 816 XML_WITH_ZLIB = 31, 817 XML_WITH_NONE = 99999 (* just to be sure of allocation size *) 818 ); 819 820{$ENDIF} 821 822{$IFDEF FUNCTION} 823(* 824 * Init/Cleanup 825 *) 826procedure xmlInitParser; EXTDECL; external xml2lib; 827procedure xmlCleanupParser; EXTDECL; external xml2lib; 828 829(* 830 * Input functions 831 *) 832function xmlParserInputRead(_in: xmlParserInputPtr; len: cint): cint; EXTDECL; external xml2lib; 833function xmlParserInputGrow(_in: xmlParserInputPtr; len: cint): cint; EXTDECL; external xml2lib; 834 835(* 836 * Basic parsing Interfaces 837 *) 838{$IFDEF LIBXML_SAX1_ENABLED} 839function xmlParseDoc(cur: xmlCharPtr): xmlDocPtr; EXTDECL; external xml2lib; 840function xmlParseFile(filename: pchar): xmlDocPtr; EXTDECL; external xml2lib; 841function xmlParseMemory(buffer: pchar; size: cint): xmlDocPtr; EXTDECL; external xml2lib; 842{$ENDIF} (* LIBXML_SAX1_ENABLED *) 843function xmlSubstituteEntitiesDefault(val: cint): cint; EXTDECL; external xml2lib; 844function xmlKeepBlanksDefault(val: cint): cint; EXTDECL; external xml2lib; 845procedure xmlStopParser(ctxt: xmlParserCtxtPtr); EXTDECL; external xml2lib; 846function xmlPedanticParserDefault(val: cint): cint; EXTDECL; external xml2lib; 847function xmlLineNumbersDefault(val: cint): cint; EXTDECL; external xml2lib; 848 849{$IFDEF LIBXML_SAX1_ENABLED} 850(* 851 * Recovery mode 852 *) 853function xmlRecoverDoc(cur: xmlCharPtr): xmlDocPtr; EXTDECL; external xml2lib; 854function xmlRecoverMemory(buffer: pchar; size: cint): xmlDocPtr; EXTDECL; external xml2lib; 855function xmlRecoverFile(filename: pchar): xmlDocPtr; EXTDECL; external xml2lib; 856{$ENDIF} (* LIBXML_SAX1_ENABLED *) 857 858(* 859 * Less common routines and SAX interfaces 860 *) 861function xmlParseDocument(ctxt: xmlParserCtxtPtr): cint; EXTDECL; external xml2lib; 862function xmlParseExtParsedEnt(ctxt: xmlParserCtxtPtr): cint; EXTDECL; external xml2lib; 863{$IFDEF LIBXML_SAX1_ENABLED} 864function xmlSAXUserParseFile(sax: xmlSAXHandlerPtr; user_data: pointer; filename: pchar): cint; EXTDECL; external xml2lib; 865function xmlSAXUserParseMemory(sax: xmlSAXHandlerPtr; user_data: pointer; buffer: pchar; size: cint): cint; EXTDECL; external xml2lib; 866function xmlSAXParseDoc(sax: xmlSAXHandlerPtr; cur: xmlCharPtr; recovery: cint): xmlDocPtr; EXTDECL; external xml2lib; 867function xmlSAXParseMemory(sax: xmlSAXHandlerPtr; buffer: pchar; size: cint; recovery: cint): xmlDocPtr; EXTDECL; external xml2lib; 868function xmlSAXParseMemoryWithData(sax: xmlSAXHandlerPtr; buffer: pchar; size: cint; recovery: cint; data: pointer): xmlDocPtr; EXTDECL; external xml2lib; 869function xmlSAXParseFile(sax: xmlSAXHandlerPtr; filename: pchar; recovery: cint): xmlDocPtr; EXTDECL; external xml2lib; 870function xmlSAXParseFileWithData(sax: xmlSAXHandlerPtr; filename: pchar; recovery: cint; data: pointer): xmlDocPtr; EXTDECL; external xml2lib; 871function xmlSAXParseEntity(sax: xmlSAXHandlerPtr; filename: pchar): xmlDocPtr; EXTDECL; external xml2lib; 872function xmlParseEntity(filename: pchar): xmlDocPtr; EXTDECL; external xml2lib; 873{$ENDIF} (* LIBXML_SAX1_ENABLED *) 874 875{$IFDEF LIBXML_VALID_ENABLED} 876function xmlSAXParseDTD(sax: xmlSAXHandlerPtr; ExternalID, SystemID: xmlCharPtr): xmlDtdPtr; EXTDECL; external xml2lib; 877function xmlParseDTD(ExternalID, SystemID: xmlCharPtr): xmlDtdPtr; EXTDECL; external xml2lib; 878function xmlIOParseDTD(sax: xmlSAXHandlerPtr; input: xmlParserInputBufferPtr; enc: xmlCharEncoding): xmlDtdPtr; EXTDECL; external xml2lib; 879{$ENDIF} (* LIBXML_VALID_ENABLE *) 880{$IFDEF LIBXML_SAX1_ENABLED} 881function xmlParseBalancedChunkMemory(doc: xmlDocPtr; sax: xmlSAXHandlerPtr; user_data: pointer; depth: cint; _string: xmlCharPtr; lst: xmlNodePtrPtr): cint; EXTDECL; external xml2lib; 882{$ENDIF} (* LIBXML_SAX1_ENABLED *) 883function xmlParseInNodeContext(node: xmlNodePtr; data: pchar; datalen, options: cint; lst: xmlNodePtrPtr): xmlParserErrors; EXTDECL; external xml2lib; 884{$IFDEF LIBXML_SAX1_ENABLED} 885function xmlParseBalancedChunkMemoryRecover(doc: xmlDocPtr; sax: xmlSAXHandlerPtr; user_data: pointer; 886 depth: cint; _string: xmlCharPtr; lst: xmlNodePtrPtr; recover: cint): cint; EXTDECL; external xml2lib; 887function xmlParseExternalEntity(doc: xmlDocPtr; sax: xmlSAXHandlerPtr; user_data: pointer; 888 depth: cint; URL, ID: xmlCharPtr; lst: xmlNodePtrPtr): cint; EXTDECL; external xml2lib; 889 890{$ENDIF} (* LIBXML_SAX1_ENABLED *) 891function xmlParseCtxtExternalEntity(ctx: xmlParserCtxtPtr; URL, ID: xmlCharPtr; lst: xmlNodePtrPtr): cint; EXTDECL; external xml2lib; 892 893(* 894 * Parser contexts handling. 895 *) 896function xmlNewParserCtxt: xmlParserCtxtPtr; EXTDECL; external xml2lib; 897function xmlInitParserCtxt(ctxt: xmlParserCtxtPtr): cint; EXTDECL; external xml2lib; 898procedure xmlClearParserCtxt(ctxt: xmlParserCtxtPtr); EXTDECL; external xml2lib; 899procedure xmlFreeParserCtxt(ctxt: xmlParserCtxtPtr); EXTDECL; external xml2lib; 900{$IFDEF LIBXML_SAX1_ENABLED} 901procedure xmlSetupParserForBuffer(ctxt: xmlParserCtxtPtr; buffer: xmlCharPtr; filename: pchar); EXTDECL; external xml2lib; 902{$ENDIF} (* LIBXML_SAX1_ENABLED *) 903function xmlCreateDocParserCtxt(cur: xmlCharPtr): xmlParserCtxtPtr; EXTDECL; external xml2lib; 904 905{$IFDEF LIBXML_LEGACY_ENABLED} 906(* 907 * Reading/setting optional parsing features. 908 *) 909function xmlGetFeaturesList(var len: cint; var result: pchar): cint; EXTDECL; external xml2lib; 910function xmlGetFeature(ctxt: xmlParserCtxtPtr; name: pchar; result: pointer): cint; EXTDECL; external xml2lib; 911function xmlSetFeature(ctxt: xmlParserCtxtPtr; name: pchar; value: pointer): cint; EXTDECL; external xml2lib; 912{$ENDIF} (* LIBXML_LEGACY_ENABLED *) 913 914{$IFDEF LIBXML_PUSH_ENABLED} 915(* 916 * Interfaces for the Push mode. 917 *) 918function xmlCreatePushParserCtxt(sax: xmlSAXHandlerPtr; user_data: pointer; chunk: pchar; size: cint; filename: pchar): xmlParserCtxtPtr; EXTDECL; external xml2lib; 919function xmlParseChunk(ctxt: xmlParserCtxtPtr; chunk: pchar; size, terminate: cint): cint; EXTDECL; external xml2lib; 920{$ENDIF} (* LIBXML_PUSH_ENABLED *) 921 922(* 923 * Special I/O mode. 924 *) 925function xmlCreateIOParserCtxt(sax: xmlSAXHandlerPtr; user_data: pointer; ioread: xmlInputReadCallback; 926 ioclose: xmlInputCloseCallback; ioctx: pointer; enc: xmlCharEncoding): xmlParserCtxtPtr; EXTDECL; external xml2lib; 927function xmlNewIOInputStream(ctxt: xmlParserCtxtPtr; input: xmlParserInputBufferPtr; enc: xmlCharEncoding): xmlParserInputPtr; EXTDECL; external xml2lib; 928 929(* 930 * Node infos. 931 *) 932function xmlParserFindNodeInfo(ctxt: xmlParserCtxtPtr; node: xmlNodePtr): xmlParserNodeInfoPtr; EXTDECL; external xml2lib; 933procedure xmlInitNodeInfoSeq(seq: xmlParserNodeInfoSeqPtr); EXTDECL; external xml2lib; 934procedure xmlClearNodeInfoSeq(seq: xmlParserNodeInfoSeqPtr); EXTDECL; external xml2lib; 935function xmlParserFindNodeInfoIndex(seq: xmlParserNodeInfoSeqPtr; node: xmlNodePtr): culong; EXTDECL; external xml2lib; 936procedure xmlParserAddNodeInfo(ctxt: xmlParserCtxtPtr; info: xmlParserNodeInfoPtr); EXTDECL; external xml2lib; 937 938(* 939 * External entities handling actually implemented in xmlIO. 940 *) 941procedure xmlSetExternalEntityLoader(f: xmlExternalEntityLoader); EXTDECL; external xml2lib; 942function xmlGetExternalEntityLoader(): xmlExternalEntityLoader; EXTDECL; external xml2lib; 943function xmlLoadExternalEntity(URL, ID: pchar; ctxt: xmlParserCtxtPtr): xmlParserInputPtr; EXTDECL; external xml2lib; 944 945(* 946 * Index lookup, actually implemented in the encoding module 947 *) 948function xmlByteConsumed(ctxt: xmlParserCtxtPtr): culong; EXTDECL; external xml2lib; 949 950(* 951 * New set of simpler/more flexible APIs 952 *) 953procedure xmlCtxtReset(ctxt: xmlParserCtxtPtr); EXTDECL; external xml2lib; 954function xmlCtxtResetPush(ctxt: xmlParserCtxtPtr; chunk: pchar; size: cint; filename, encoding: pchar): cint; EXTDECL; external xml2lib; 955function xmlCtxtUseOptions(ctxt: xmlParserCtxtPtr; options: cint): cint; EXTDECL; external xml2lib; 956function xmlReadDoc(cur: xmlCharPtr; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 957function xmlReadFile(filename, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 958function xmlReadMemory(buffer: pchar; size: cint; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 959function xmlReadFd(fd: cint; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 960function xmlReadIO(ioread: xmlInputReadCallback; ioclose: xmlInputCloseCallback; ioctx: pointer; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 961function xmlCtxtReadDoc(ctxt: xmlParserCtxtPtr; cur: xmlCharPtr; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 962function xmlCtxtReadFile(ctxt: xmlParserCtxtPtr; filename, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 963function xmlCtxtReadMemory(ctxt: xmlParserCtxtPtr; buffer: pchar; size: cint; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 964function xmlCtxtReadFd(ctxt: xmlParserCtxtPtr; fd: cint; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 965function xmlCtxtReadIO(ctxt: xmlParserCtxtPtr; ioread: xmlInputReadCallback; ioclose: xmlInputCloseCallback; ioctx: pchar; URL, encoding: pchar; options: cint): xmlDocPtr; EXTDECL; external xml2lib; 966 967(* 968 * Library wide options 969 *) 970(** 971 * xmlFeature: 972 * 973 * Used to examine the existance of features that can be enabled 974 * or disabled at compile-time. 975 * They used to be called XML_FEATURE_xxx but this clashed with Expat 976 *) 977function xmlHasFeature(feature: xmlFeature): cint; EXTDECL; external xml2lib; 978{$ENDIF} 979 980