1/* 2 * Summary: interfaces for tree manipulation 3 * Description: this module describes the structures found in an tree resulting 4 * from an XML or HTML parsing, as well as the API provided for 5 * various processing on that tree 6 * 7 * Copy: See Copyright for the status of this software. 8 * 9 * Author: Daniel Veillard 10 */ 11 12#ifndef __XML_TREE_H__ 13#define __XML_TREE_H__ 14 15#include <stdio.h> 16#include <libxml/xmlversion.h> 17#include <libxml/xmlstring.h> 18 19#ifdef __cplusplus 20extern "C" { 21#endif 22 23/* 24 * Some of the basic types pointer to structures: 25 */ 26/* xmlIO.h */ 27typedef struct _xmlParserInputBuffer xmlParserInputBuffer; 28typedef xmlParserInputBuffer *xmlParserInputBufferPtr; 29 30typedef struct _xmlOutputBuffer xmlOutputBuffer; 31typedef xmlOutputBuffer *xmlOutputBufferPtr; 32 33/* parser.h */ 34typedef struct _xmlParserInput xmlParserInput; 35typedef xmlParserInput *xmlParserInputPtr; 36 37typedef struct _xmlParserCtxt xmlParserCtxt; 38typedef xmlParserCtxt *xmlParserCtxtPtr; 39 40typedef struct _xmlSAXLocator xmlSAXLocator; 41typedef xmlSAXLocator *xmlSAXLocatorPtr; 42 43typedef struct _xmlSAXHandler xmlSAXHandler; 44typedef xmlSAXHandler *xmlSAXHandlerPtr; 45 46/* entities.h */ 47typedef struct _xmlEntity xmlEntity; 48typedef xmlEntity *xmlEntityPtr; 49 50/** 51 * BASE_BUFFER_SIZE: 52 * 53 * default buffer size 4000. 54 */ 55#define BASE_BUFFER_SIZE 4096 56 57/** 58 * LIBXML_NAMESPACE_DICT: 59 * 60 * Defines experimental behaviour: 61 * 1) xmlNs gets an additional field @context (a xmlDoc) 62 * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc. 63 */ 64/* #define LIBXML_NAMESPACE_DICT */ 65 66/** 67 * xmlBufferAllocationScheme: 68 * 69 * A buffer allocation scheme can be defined to either match exactly the 70 * need or double it's allocated size each time it is found too small. 71 */ 72 73typedef enum { 74 XML_BUFFER_ALLOC_DOUBLEIT, 75 XML_BUFFER_ALLOC_EXACT, 76 XML_BUFFER_ALLOC_IMMUTABLE 77} xmlBufferAllocationScheme; 78 79/** 80 * xmlBuffer: 81 * 82 * A buffer structure. 83 */ 84typedef struct _xmlBuffer xmlBuffer; 85typedef xmlBuffer *xmlBufferPtr; 86struct _xmlBuffer { 87 xmlChar *content; /* The buffer content UTF8 */ 88 unsigned int use; /* The buffer size used */ 89 unsigned int size; /* The buffer size */ 90 xmlBufferAllocationScheme alloc; /* The realloc method */ 91}; 92 93/** 94 * XML_XML_NAMESPACE: 95 * 96 * This is the namespace for the special xml: prefix predefined in the 97 * XML Namespace specification. 98 */ 99#define XML_XML_NAMESPACE \ 100 (const xmlChar *) "http://www.w3.org/XML/1998/namespace" 101 102/** 103 * XML_XML_ID: 104 * 105 * This is the name for the special xml:id attribute 106 */ 107#define XML_XML_ID (const xmlChar *) "xml:id" 108 109/* 110 * The different element types carried by an XML tree. 111 * 112 * NOTE: This is synchronized with DOM Level1 values 113 * See http://www.w3.org/TR/REC-DOM-Level-1/ 114 * 115 * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should 116 * be deprecated to use an XML_DTD_NODE. 117 */ 118typedef enum { 119 XML_ELEMENT_NODE= 1, 120 XML_ATTRIBUTE_NODE= 2, 121 XML_TEXT_NODE= 3, 122 XML_CDATA_SECTION_NODE= 4, 123 XML_ENTITY_REF_NODE= 5, 124 XML_ENTITY_NODE= 6, 125 XML_PI_NODE= 7, 126 XML_COMMENT_NODE= 8, 127 XML_DOCUMENT_NODE= 9, 128 XML_DOCUMENT_TYPE_NODE= 10, 129 XML_DOCUMENT_FRAG_NODE= 11, 130 XML_NOTATION_NODE= 12, 131 XML_HTML_DOCUMENT_NODE= 13, 132 XML_DTD_NODE= 14, 133 XML_ELEMENT_DECL= 15, 134 XML_ATTRIBUTE_DECL= 16, 135 XML_ENTITY_DECL= 17, 136 XML_NAMESPACE_DECL= 18, 137 XML_XINCLUDE_START= 19, 138 XML_XINCLUDE_END= 20 139#ifdef LIBXML_DOCB_ENABLED 140 ,XML_DOCB_DOCUMENT_NODE= 21 141#endif 142} xmlElementType; 143 144 145/** 146 * xmlNotation: 147 * 148 * A DTD Notation definition. 149 */ 150 151typedef struct _xmlNotation xmlNotation; 152typedef xmlNotation *xmlNotationPtr; 153struct _xmlNotation { 154 const xmlChar *name; /* Notation name */ 155 const xmlChar *PublicID; /* Public identifier, if any */ 156 const xmlChar *SystemID; /* System identifier, if any */ 157}; 158 159/** 160 * xmlAttributeType: 161 * 162 * A DTD Attribute type definition. 163 */ 164 165typedef enum { 166 XML_ATTRIBUTE_CDATA = 1, 167 XML_ATTRIBUTE_ID, 168 XML_ATTRIBUTE_IDREF , 169 XML_ATTRIBUTE_IDREFS, 170 XML_ATTRIBUTE_ENTITY, 171 XML_ATTRIBUTE_ENTITIES, 172 XML_ATTRIBUTE_NMTOKEN, 173 XML_ATTRIBUTE_NMTOKENS, 174 XML_ATTRIBUTE_ENUMERATION, 175 XML_ATTRIBUTE_NOTATION 176} xmlAttributeType; 177 178/** 179 * xmlAttributeDefault: 180 * 181 * A DTD Attribute default definition. 182 */ 183 184typedef enum { 185 XML_ATTRIBUTE_NONE = 1, 186 XML_ATTRIBUTE_REQUIRED, 187 XML_ATTRIBUTE_IMPLIED, 188 XML_ATTRIBUTE_FIXED 189} xmlAttributeDefault; 190 191/** 192 * xmlEnumeration: 193 * 194 * List structure used when there is an enumeration in DTDs. 195 */ 196 197typedef struct _xmlEnumeration xmlEnumeration; 198typedef xmlEnumeration *xmlEnumerationPtr; 199struct _xmlEnumeration { 200 struct _xmlEnumeration *next; /* next one */ 201 const xmlChar *name; /* Enumeration name */ 202}; 203 204/** 205 * xmlAttribute: 206 * 207 * An Attribute declaration in a DTD. 208 */ 209 210typedef struct _xmlAttribute xmlAttribute; 211typedef xmlAttribute *xmlAttributePtr; 212struct _xmlAttribute { 213 void *_private; /* application data */ 214 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ 215 const xmlChar *name; /* Attribute name */ 216 struct _xmlNode *children; /* NULL */ 217 struct _xmlNode *last; /* NULL */ 218 struct _xmlDtd *parent; /* -> DTD */ 219 struct _xmlNode *next; /* next sibling link */ 220 struct _xmlNode *prev; /* previous sibling link */ 221 struct _xmlDoc *doc; /* the containing document */ 222 223 struct _xmlAttribute *nexth; /* next in hash table */ 224 xmlAttributeType atype; /* The attribute type */ 225 xmlAttributeDefault def; /* the default */ 226 const xmlChar *defaultValue; /* or the default value */ 227 xmlEnumerationPtr tree; /* or the enumeration tree if any */ 228 const xmlChar *prefix; /* the namespace prefix if any */ 229 const xmlChar *elem; /* Element holding the attribute */ 230}; 231 232/** 233 * xmlElementContentType: 234 * 235 * Possible definitions of element content types. 236 */ 237typedef enum { 238 XML_ELEMENT_CONTENT_PCDATA = 1, 239 XML_ELEMENT_CONTENT_ELEMENT, 240 XML_ELEMENT_CONTENT_SEQ, 241 XML_ELEMENT_CONTENT_OR 242} xmlElementContentType; 243 244/** 245 * xmlElementContentOccur: 246 * 247 * Possible definitions of element content occurrences. 248 */ 249typedef enum { 250 XML_ELEMENT_CONTENT_ONCE = 1, 251 XML_ELEMENT_CONTENT_OPT, 252 XML_ELEMENT_CONTENT_MULT, 253 XML_ELEMENT_CONTENT_PLUS 254} xmlElementContentOccur; 255 256/** 257 * xmlElementContent: 258 * 259 * An XML Element content as stored after parsing an element definition 260 * in a DTD. 261 */ 262 263typedef struct _xmlElementContent xmlElementContent; 264typedef xmlElementContent *xmlElementContentPtr; 265struct _xmlElementContent { 266 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ 267 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ 268 const xmlChar *name; /* Element name */ 269 struct _xmlElementContent *c1; /* first child */ 270 struct _xmlElementContent *c2; /* second child */ 271 struct _xmlElementContent *parent; /* parent */ 272 const xmlChar *prefix; /* Namespace prefix */ 273}; 274 275/** 276 * xmlElementTypeVal: 277 * 278 * The different possibilities for an element content type. 279 */ 280 281typedef enum { 282 XML_ELEMENT_TYPE_UNDEFINED = 0, 283 XML_ELEMENT_TYPE_EMPTY = 1, 284 XML_ELEMENT_TYPE_ANY, 285 XML_ELEMENT_TYPE_MIXED, 286 XML_ELEMENT_TYPE_ELEMENT 287} xmlElementTypeVal; 288 289#ifdef __cplusplus 290} 291#endif 292#include <libxml/xmlregexp.h> 293#ifdef __cplusplus 294extern "C" { 295#endif 296 297/** 298 * xmlElement: 299 * 300 * An XML Element declaration from a DTD. 301 */ 302 303typedef struct _xmlElement xmlElement; 304typedef xmlElement *xmlElementPtr; 305struct _xmlElement { 306 void *_private; /* application data */ 307 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ 308 const xmlChar *name; /* Element name */ 309 struct _xmlNode *children; /* NULL */ 310 struct _xmlNode *last; /* NULL */ 311 struct _xmlDtd *parent; /* -> DTD */ 312 struct _xmlNode *next; /* next sibling link */ 313 struct _xmlNode *prev; /* previous sibling link */ 314 struct _xmlDoc *doc; /* the containing document */ 315 316 xmlElementTypeVal etype; /* The type */ 317 xmlElementContentPtr content; /* the allowed element content */ 318 xmlAttributePtr attributes; /* List of the declared attributes */ 319 const xmlChar *prefix; /* the namespace prefix if any */ 320#ifdef LIBXML_REGEXP_ENABLED 321 xmlRegexpPtr contModel; /* the validating regexp */ 322#else 323 void *contModel; 324#endif 325}; 326 327 328/** 329 * XML_LOCAL_NAMESPACE: 330 * 331 * A namespace declaration node. 332 */ 333#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL 334typedef xmlElementType xmlNsType; 335 336/** 337 * xmlNs: 338 * 339 * An XML namespace. 340 * Note that prefix == NULL is valid, it defines the default namespace 341 * within the subtree (until overridden). 342 * 343 * xmlNsType is unified with xmlElementType. 344 */ 345 346typedef struct _xmlNs xmlNs; 347typedef xmlNs *xmlNsPtr; 348struct _xmlNs { 349 struct _xmlNs *next; /* next Ns link for this node */ 350 xmlNsType type; /* global or local */ 351 const xmlChar *href; /* URL for the namespace */ 352 const xmlChar *prefix; /* prefix for the namespace */ 353 void *_private; /* application data */ 354 struct _xmlDoc *context; /* normally an xmlDoc */ 355}; 356 357/** 358 * xmlDtd: 359 * 360 * An XML DTD, as defined by <!DOCTYPE ... There is actually one for 361 * the internal subset and for the external subset. 362 */ 363typedef struct _xmlDtd xmlDtd; 364typedef xmlDtd *xmlDtdPtr; 365struct _xmlDtd { 366 void *_private; /* application data */ 367 xmlElementType type; /* XML_DTD_NODE, must be second ! */ 368 const xmlChar *name; /* Name of the DTD */ 369 struct _xmlNode *children; /* the value of the property link */ 370 struct _xmlNode *last; /* last child link */ 371 struct _xmlDoc *parent; /* child->parent link */ 372 struct _xmlNode *next; /* next sibling link */ 373 struct _xmlNode *prev; /* previous sibling link */ 374 struct _xmlDoc *doc; /* the containing document */ 375 376 /* End of common part */ 377 void *notations; /* Hash table for notations if any */ 378 void *elements; /* Hash table for elements if any */ 379 void *attributes; /* Hash table for attributes if any */ 380 void *entities; /* Hash table for entities if any */ 381 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ 382 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ 383 void *pentities; /* Hash table for param entities if any */ 384}; 385 386/** 387 * xmlAttr: 388 * 389 * An attribute on an XML node. 390 */ 391typedef struct _xmlAttr xmlAttr; 392typedef xmlAttr *xmlAttrPtr; 393struct _xmlAttr { 394 void *_private; /* application data */ 395 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ 396 const xmlChar *name; /* the name of the property */ 397 struct _xmlNode *children; /* the value of the property */ 398 struct _xmlNode *last; /* NULL */ 399 struct _xmlNode *parent; /* child->parent link */ 400 struct _xmlAttr *next; /* next sibling link */ 401 struct _xmlAttr *prev; /* previous sibling link */ 402 struct _xmlDoc *doc; /* the containing document */ 403 xmlNs *ns; /* pointer to the associated namespace */ 404 xmlAttributeType atype; /* the attribute type if validating */ 405 void *psvi; /* for type/PSVI informations */ 406}; 407 408/** 409 * xmlID: 410 * 411 * An XML ID instance. 412 */ 413 414typedef struct _xmlID xmlID; 415typedef xmlID *xmlIDPtr; 416struct _xmlID { 417 struct _xmlID *next; /* next ID */ 418 const xmlChar *value; /* The ID name */ 419 xmlAttrPtr attr; /* The attribute holding it */ 420 const xmlChar *name; /* The attribute if attr is not available */ 421 int lineno; /* The line number if attr is not available */ 422 struct _xmlDoc *doc; /* The document holding the ID */ 423}; 424 425/** 426 * xmlRef: 427 * 428 * An XML IDREF instance. 429 */ 430 431typedef struct _xmlRef xmlRef; 432typedef xmlRef *xmlRefPtr; 433struct _xmlRef { 434 struct _xmlRef *next; /* next Ref */ 435 const xmlChar *value; /* The Ref name */ 436 xmlAttrPtr attr; /* The attribute holding it */ 437 const xmlChar *name; /* The attribute if attr is not available */ 438 int lineno; /* The line number if attr is not available */ 439}; 440 441/** 442 * xmlNode: 443 * 444 * A node in an XML tree. 445 */ 446typedef struct _xmlNode xmlNode; 447typedef xmlNode *xmlNodePtr; 448struct _xmlNode { 449 void *_private; /* application data */ 450 xmlElementType type; /* type number, must be second ! */ 451 const xmlChar *name; /* the name of the node, or the entity */ 452 struct _xmlNode *children; /* parent->childs link */ 453 struct _xmlNode *last; /* last child link */ 454 struct _xmlNode *parent; /* child->parent link */ 455 struct _xmlNode *next; /* next sibling link */ 456 struct _xmlNode *prev; /* previous sibling link */ 457 struct _xmlDoc *doc; /* the containing document */ 458 459 /* End of common part */ 460 xmlNs *ns; /* pointer to the associated namespace */ 461 xmlChar *content; /* the content */ 462 struct _xmlAttr *properties;/* properties list */ 463 xmlNs *nsDef; /* namespace definitions on this node */ 464 void *psvi; /* for type/PSVI informations */ 465 unsigned short line; /* line number */ 466 unsigned short extra; /* extra data for XPath/XSLT */ 467}; 468 469/** 470 * XML_GET_CONTENT: 471 * 472 * Macro to extract the content pointer of a node. 473 */ 474#define XML_GET_CONTENT(n) \ 475 ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content) 476 477/** 478 * XML_GET_LINE: 479 * 480 * Macro to extract the line number of an element node. 481 */ 482#define XML_GET_LINE(n) \ 483 (xmlGetLineNo(n)) 484 485 486/** 487 * xmlDoc: 488 * 489 * An XML document. 490 */ 491typedef struct _xmlDoc xmlDoc; 492typedef xmlDoc *xmlDocPtr; 493struct _xmlDoc { 494 void *_private; /* application data */ 495 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ 496 char *name; /* name/filename/URI of the document */ 497 struct _xmlNode *children; /* the document tree */ 498 struct _xmlNode *last; /* last child link */ 499 struct _xmlNode *parent; /* child->parent link */ 500 struct _xmlNode *next; /* next sibling link */ 501 struct _xmlNode *prev; /* previous sibling link */ 502 struct _xmlDoc *doc; /* autoreference to itself */ 503 504 /* End of common part */ 505 int compression;/* level of zlib compression */ 506 int standalone; /* standalone document (no external refs) */ 507 struct _xmlDtd *intSubset; /* the document internal subset */ 508 struct _xmlDtd *extSubset; /* the document external subset */ 509 struct _xmlNs *oldNs; /* Global namespace, the old way */ 510 const xmlChar *version; /* the XML version string */ 511 const xmlChar *encoding; /* external initial encoding, if any */ 512 void *ids; /* Hash table for ID attributes if any */ 513 void *refs; /* Hash table for IDREFs attributes if any */ 514 const xmlChar *URL; /* The URI for that document */ 515 int charset; /* encoding of the in-memory content 516 actually an xmlCharEncoding */ 517 struct _xmlDict *dict; /* dict used to allocate names or NULL */ 518 void *psvi; /* for type/PSVI informations */ 519}; 520 521 522typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt; 523typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr; 524 525/** 526 * xmlDOMWrapAcquireNsFunction: 527 * @ctxt: a DOM wrapper context 528 * @node: the context node (element or attribute) 529 * @nsName: the requested namespace name 530 * @nsPrefix: the requested namespace prefix 531 * 532 * A function called to acquire namespaces (xmlNs) from the wrapper. 533 * 534 * Returns an xmlNsPtr or NULL in case of an error. 535 */ 536typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt, 537 xmlNodePtr node, 538 const xmlChar *nsName, 539 const xmlChar *nsPrefix); 540 541/** 542 * xmlDOMWrapCtxt: 543 * 544 * Context for DOM wrapper-operations. 545 */ 546struct _xmlDOMWrapCtxt { 547 void * _private; 548 /* 549 * The type of this context, just in case we need specialized 550 * contexts in the future. 551 */ 552 int type; 553 /* 554 * Internal namespace map used for various operations. 555 */ 556 void * namespaceMap; 557 /* 558 * Use this one to acquire an xmlNsPtr intended for node->ns. 559 * (Note that this is not intended for elem->nsDef). 560 */ 561 xmlDOMWrapAcquireNsFunction getNsForNodeFunc; 562}; 563 564/** 565 * xmlChildrenNode: 566 * 567 * Macro for compatibility naming layer with libxml1. Maps 568 * to "children." 569 */ 570#ifndef xmlChildrenNode 571#define xmlChildrenNode children 572#endif 573 574/** 575 * xmlRootNode: 576 * 577 * Macro for compatibility naming layer with libxml1. Maps 578 * to "children". 579 */ 580#ifndef xmlRootNode 581#define xmlRootNode children 582#endif 583 584/* 585 * Variables. 586 */ 587 588/* 589 * Some helper functions 590 */ 591#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) 592XMLPUBFUN int XMLCALL 593 xmlValidateNCName (const xmlChar *value, 594 int space); 595#endif 596 597#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) 598XMLPUBFUN int XMLCALL 599 xmlValidateQName (const xmlChar *value, 600 int space); 601XMLPUBFUN int XMLCALL 602 xmlValidateName (const xmlChar *value, 603 int space); 604XMLPUBFUN int XMLCALL 605 xmlValidateNMToken (const xmlChar *value, 606 int space); 607#endif 608 609XMLPUBFUN xmlChar * XMLCALL 610 xmlBuildQName (const xmlChar *ncname, 611 const xmlChar *prefix, 612 xmlChar *memory, 613 int len); 614XMLPUBFUN xmlChar * XMLCALL 615 xmlSplitQName2 (const xmlChar *name, 616 xmlChar **prefix); 617XMLPUBFUN const xmlChar * XMLCALL 618 xmlSplitQName3 (const xmlChar *name, 619 int *len); 620 621/* 622 * Handling Buffers. 623 */ 624 625XMLPUBFUN void XMLCALL 626 xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); 627XMLPUBFUN xmlBufferAllocationScheme XMLCALL 628 xmlGetBufferAllocationScheme(void); 629 630XMLPUBFUN xmlBufferPtr XMLCALL 631 xmlBufferCreate (void); 632XMLPUBFUN xmlBufferPtr XMLCALL 633 xmlBufferCreateSize (size_t size); 634XMLPUBFUN xmlBufferPtr XMLCALL 635 xmlBufferCreateStatic (void *mem, 636 size_t size); 637XMLPUBFUN int XMLCALL 638 xmlBufferResize (xmlBufferPtr buf, 639 unsigned int size); 640XMLPUBFUN void XMLCALL 641 xmlBufferFree (xmlBufferPtr buf); 642XMLPUBFUN int XMLCALL 643 xmlBufferDump (FILE *file, 644 xmlBufferPtr buf); 645XMLPUBFUN int XMLCALL 646 xmlBufferAdd (xmlBufferPtr buf, 647 const xmlChar *str, 648 int len); 649XMLPUBFUN int XMLCALL 650 xmlBufferAddHead (xmlBufferPtr buf, 651 const xmlChar *str, 652 int len); 653XMLPUBFUN int XMLCALL 654 xmlBufferCat (xmlBufferPtr buf, 655 const xmlChar *str); 656XMLPUBFUN int XMLCALL 657 xmlBufferCCat (xmlBufferPtr buf, 658 const char *str); 659XMLPUBFUN int XMLCALL 660 xmlBufferShrink (xmlBufferPtr buf, 661 unsigned int len); 662XMLPUBFUN int XMLCALL 663 xmlBufferGrow (xmlBufferPtr buf, 664 unsigned int len); 665XMLPUBFUN void XMLCALL 666 xmlBufferEmpty (xmlBufferPtr buf); 667XMLPUBFUN const xmlChar* XMLCALL 668 xmlBufferContent (const xmlBufferPtr buf); 669XMLPUBFUN void XMLCALL 670 xmlBufferSetAllocationScheme(xmlBufferPtr buf, 671 xmlBufferAllocationScheme scheme); 672XMLPUBFUN int XMLCALL 673 xmlBufferLength (const xmlBufferPtr buf); 674 675/* 676 * Creating/freeing new structures. 677 */ 678XMLPUBFUN xmlDtdPtr XMLCALL 679 xmlCreateIntSubset (xmlDocPtr doc, 680 const xmlChar *name, 681 const xmlChar *ExternalID, 682 const xmlChar *SystemID); 683XMLPUBFUN xmlDtdPtr XMLCALL 684 xmlNewDtd (xmlDocPtr doc, 685 const xmlChar *name, 686 const xmlChar *ExternalID, 687 const xmlChar *SystemID); 688XMLPUBFUN xmlDtdPtr XMLCALL 689 xmlGetIntSubset (xmlDocPtr doc); 690XMLPUBFUN void XMLCALL 691 xmlFreeDtd (xmlDtdPtr cur); 692#ifdef LIBXML_LEGACY_ENABLED 693XMLPUBFUN xmlNsPtr XMLCALL 694 xmlNewGlobalNs (xmlDocPtr doc, 695 const xmlChar *href, 696 const xmlChar *prefix); 697#endif /* LIBXML_LEGACY_ENABLED */ 698XMLPUBFUN xmlNsPtr XMLCALL 699 xmlNewNs (xmlNodePtr node, 700 const xmlChar *href, 701 const xmlChar *prefix); 702XMLPUBFUN void XMLCALL 703 xmlFreeNs (xmlNsPtr cur); 704XMLPUBFUN void XMLCALL 705 xmlFreeNsList (xmlNsPtr cur); 706XMLPUBFUN xmlDocPtr XMLCALL 707 xmlNewDoc (const xmlChar *version); 708XMLPUBFUN void XMLCALL 709 xmlFreeDoc (xmlDocPtr cur); 710XMLPUBFUN xmlAttrPtr XMLCALL 711 xmlNewDocProp (xmlDocPtr doc, 712 const xmlChar *name, 713 const xmlChar *value); 714#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ 715 defined(LIBXML_SCHEMAS_ENABLED) 716XMLPUBFUN xmlAttrPtr XMLCALL 717 xmlNewProp (xmlNodePtr node, 718 const xmlChar *name, 719 const xmlChar *value); 720#endif 721XMLPUBFUN xmlAttrPtr XMLCALL 722 xmlNewNsProp (xmlNodePtr node, 723 xmlNsPtr ns, 724 const xmlChar *name, 725 const xmlChar *value); 726XMLPUBFUN xmlAttrPtr XMLCALL 727 xmlNewNsPropEatName (xmlNodePtr node, 728 xmlNsPtr ns, 729 xmlChar *name, 730 const xmlChar *value); 731XMLPUBFUN void XMLCALL 732 xmlFreePropList (xmlAttrPtr cur); 733XMLPUBFUN void XMLCALL 734 xmlFreeProp (xmlAttrPtr cur); 735XMLPUBFUN xmlAttrPtr XMLCALL 736 xmlCopyProp (xmlNodePtr target, 737 xmlAttrPtr cur); 738XMLPUBFUN xmlAttrPtr XMLCALL 739 xmlCopyPropList (xmlNodePtr target, 740 xmlAttrPtr cur); 741#ifdef LIBXML_TREE_ENABLED 742XMLPUBFUN xmlDtdPtr XMLCALL 743 xmlCopyDtd (xmlDtdPtr dtd); 744#endif /* LIBXML_TREE_ENABLED */ 745#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) 746XMLPUBFUN xmlDocPtr XMLCALL 747 xmlCopyDoc (xmlDocPtr doc, 748 int recursive); 749#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ 750/* 751 * Creating new nodes. 752 */ 753XMLPUBFUN xmlNodePtr XMLCALL 754 xmlNewDocNode (xmlDocPtr doc, 755 xmlNsPtr ns, 756 const xmlChar *name, 757 const xmlChar *content); 758XMLPUBFUN xmlNodePtr XMLCALL 759 xmlNewDocNodeEatName (xmlDocPtr doc, 760 xmlNsPtr ns, 761 xmlChar *name, 762 const xmlChar *content); 763XMLPUBFUN xmlNodePtr XMLCALL 764 xmlNewNode (xmlNsPtr ns, 765 const xmlChar *name); 766XMLPUBFUN xmlNodePtr XMLCALL 767 xmlNewNodeEatName (xmlNsPtr ns, 768 xmlChar *name); 769#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) 770XMLPUBFUN xmlNodePtr XMLCALL 771 xmlNewChild (xmlNodePtr parent, 772 xmlNsPtr ns, 773 const xmlChar *name, 774 const xmlChar *content); 775#endif 776XMLPUBFUN xmlNodePtr XMLCALL 777 xmlNewDocText (xmlDocPtr doc, 778 const xmlChar *content); 779XMLPUBFUN xmlNodePtr XMLCALL 780 xmlNewText (const xmlChar *content); 781XMLPUBFUN xmlNodePtr XMLCALL 782 xmlNewDocPI (xmlDocPtr doc, 783 const xmlChar *name, 784 const xmlChar *content); 785XMLPUBFUN xmlNodePtr XMLCALL 786 xmlNewPI (const xmlChar *name, 787 const xmlChar *content); 788XMLPUBFUN xmlNodePtr XMLCALL 789 xmlNewDocTextLen (xmlDocPtr doc, 790 const xmlChar *content, 791 int len); 792XMLPUBFUN xmlNodePtr XMLCALL 793 xmlNewTextLen (const xmlChar *content, 794 int len); 795XMLPUBFUN xmlNodePtr XMLCALL 796 xmlNewDocComment (xmlDocPtr doc, 797 const xmlChar *content); 798XMLPUBFUN xmlNodePtr XMLCALL 799 xmlNewComment (const xmlChar *content); 800XMLPUBFUN xmlNodePtr XMLCALL 801 xmlNewCDataBlock (xmlDocPtr doc, 802 const xmlChar *content, 803 int len); 804XMLPUBFUN xmlNodePtr XMLCALL 805 xmlNewCharRef (xmlDocPtr doc, 806 const xmlChar *name); 807XMLPUBFUN xmlNodePtr XMLCALL 808 xmlNewReference (xmlDocPtr doc, 809 const xmlChar *name); 810XMLPUBFUN xmlNodePtr XMLCALL 811 xmlCopyNode (const xmlNodePtr node, 812 int recursive); 813XMLPUBFUN xmlNodePtr XMLCALL 814 xmlDocCopyNode (const xmlNodePtr node, 815 xmlDocPtr doc, 816 int recursive); 817XMLPUBFUN xmlNodePtr XMLCALL 818 xmlDocCopyNodeList (xmlDocPtr doc, 819 const xmlNodePtr node); 820XMLPUBFUN xmlNodePtr XMLCALL 821 xmlCopyNodeList (const xmlNodePtr node); 822#ifdef LIBXML_TREE_ENABLED 823XMLPUBFUN xmlNodePtr XMLCALL 824 xmlNewTextChild (xmlNodePtr parent, 825 xmlNsPtr ns, 826 const xmlChar *name, 827 const xmlChar *content); 828XMLPUBFUN xmlNodePtr XMLCALL 829 xmlNewDocRawNode (xmlDocPtr doc, 830 xmlNsPtr ns, 831 const xmlChar *name, 832 const xmlChar *content); 833XMLPUBFUN xmlNodePtr XMLCALL 834 xmlNewDocFragment (xmlDocPtr doc); 835#endif /* LIBXML_TREE_ENABLED */ 836 837/* 838 * Navigating. 839 */ 840XMLPUBFUN long XMLCALL 841 xmlGetLineNo (xmlNodePtr node); 842#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) 843XMLPUBFUN xmlChar * XMLCALL 844 xmlGetNodePath (xmlNodePtr node); 845#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */ 846XMLPUBFUN xmlNodePtr XMLCALL 847 xmlDocGetRootElement (xmlDocPtr doc); 848XMLPUBFUN xmlNodePtr XMLCALL 849 xmlGetLastChild (xmlNodePtr parent); 850XMLPUBFUN int XMLCALL 851 xmlNodeIsText (xmlNodePtr node); 852XMLPUBFUN int XMLCALL 853 xmlIsBlankNode (xmlNodePtr node); 854 855/* 856 * Changing the structure. 857 */ 858#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) 859XMLPUBFUN xmlNodePtr XMLCALL 860 xmlDocSetRootElement (xmlDocPtr doc, 861 xmlNodePtr root); 862#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ 863#ifdef LIBXML_TREE_ENABLED 864XMLPUBFUN void XMLCALL 865 xmlNodeSetName (xmlNodePtr cur, 866 const xmlChar *name); 867#endif /* LIBXML_TREE_ENABLED */ 868XMLPUBFUN xmlNodePtr XMLCALL 869 xmlAddChild (xmlNodePtr parent, 870 xmlNodePtr cur); 871XMLPUBFUN xmlNodePtr XMLCALL 872 xmlAddChildList (xmlNodePtr parent, 873 xmlNodePtr cur); 874#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) 875XMLPUBFUN xmlNodePtr XMLCALL 876 xmlReplaceNode (xmlNodePtr old, 877 xmlNodePtr cur); 878#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ 879#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ 880 defined(LIBXML_SCHEMAS_ENABLED) 881XMLPUBFUN xmlNodePtr XMLCALL 882 xmlAddPrevSibling (xmlNodePtr cur, 883 xmlNodePtr elem); 884#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */ 885XMLPUBFUN xmlNodePtr XMLCALL 886 xmlAddSibling (xmlNodePtr cur, 887 xmlNodePtr elem); 888XMLPUBFUN xmlNodePtr XMLCALL 889 xmlAddNextSibling (xmlNodePtr cur, 890 xmlNodePtr elem); 891XMLPUBFUN void XMLCALL 892 xmlUnlinkNode (xmlNodePtr cur); 893XMLPUBFUN xmlNodePtr XMLCALL 894 xmlTextMerge (xmlNodePtr first, 895 xmlNodePtr second); 896XMLPUBFUN int XMLCALL 897 xmlTextConcat (xmlNodePtr node, 898 const xmlChar *content, 899 int len); 900XMLPUBFUN void XMLCALL 901 xmlFreeNodeList (xmlNodePtr cur); 902XMLPUBFUN void XMLCALL 903 xmlFreeNode (xmlNodePtr cur); 904XMLPUBFUN void XMLCALL 905 xmlSetTreeDoc (xmlNodePtr tree, 906 xmlDocPtr doc); 907XMLPUBFUN void XMLCALL 908 xmlSetListDoc (xmlNodePtr list, 909 xmlDocPtr doc); 910/* 911 * Namespaces. 912 */ 913XMLPUBFUN xmlNsPtr XMLCALL 914 xmlSearchNs (xmlDocPtr doc, 915 xmlNodePtr node, 916 const xmlChar *nameSpace); 917XMLPUBFUN xmlNsPtr XMLCALL 918 xmlSearchNsByHref (xmlDocPtr doc, 919 xmlNodePtr node, 920 const xmlChar *href); 921#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) 922XMLPUBFUN xmlNsPtr * XMLCALL 923 xmlGetNsList (xmlDocPtr doc, 924 xmlNodePtr node); 925#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */ 926 927XMLPUBFUN void XMLCALL 928 xmlSetNs (xmlNodePtr node, 929 xmlNsPtr ns); 930XMLPUBFUN xmlNsPtr XMLCALL 931 xmlCopyNamespace (xmlNsPtr cur); 932XMLPUBFUN xmlNsPtr XMLCALL 933 xmlCopyNamespaceList (xmlNsPtr cur); 934 935/* 936 * Changing the content. 937 */ 938#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) 939XMLPUBFUN xmlAttrPtr XMLCALL 940 xmlSetProp (xmlNodePtr node, 941 const xmlChar *name, 942 const xmlChar *value); 943XMLPUBFUN xmlAttrPtr XMLCALL 944 xmlSetNsProp (xmlNodePtr node, 945 xmlNsPtr ns, 946 const xmlChar *name, 947 const xmlChar *value); 948#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */ 949XMLPUBFUN xmlChar * XMLCALL 950 xmlGetNoNsProp (xmlNodePtr node, 951 const xmlChar *name); 952XMLPUBFUN xmlChar * XMLCALL 953 xmlGetProp (xmlNodePtr node, 954 const xmlChar *name); 955XMLPUBFUN xmlAttrPtr XMLCALL 956 xmlHasProp (xmlNodePtr node, 957 const xmlChar *name); 958XMLPUBFUN xmlAttrPtr XMLCALL 959 xmlHasNsProp (xmlNodePtr node, 960 const xmlChar *name, 961 const xmlChar *nameSpace); 962XMLPUBFUN xmlChar * XMLCALL 963 xmlGetNsProp (xmlNodePtr node, 964 const xmlChar *name, 965 const xmlChar *nameSpace); 966XMLPUBFUN xmlNodePtr XMLCALL 967 xmlStringGetNodeList (xmlDocPtr doc, 968 const xmlChar *value); 969XMLPUBFUN xmlNodePtr XMLCALL 970 xmlStringLenGetNodeList (xmlDocPtr doc, 971 const xmlChar *value, 972 int len); 973XMLPUBFUN xmlChar * XMLCALL 974 xmlNodeListGetString (xmlDocPtr doc, 975 xmlNodePtr list, 976 int inLine); 977#ifdef LIBXML_TREE_ENABLED 978XMLPUBFUN xmlChar * XMLCALL 979 xmlNodeListGetRawString (xmlDocPtr doc, 980 xmlNodePtr list, 981 int inLine); 982#endif /* LIBXML_TREE_ENABLED */ 983XMLPUBFUN void XMLCALL 984 xmlNodeSetContent (xmlNodePtr cur, 985 const xmlChar *content); 986#ifdef LIBXML_TREE_ENABLED 987XMLPUBFUN void XMLCALL 988 xmlNodeSetContentLen (xmlNodePtr cur, 989 const xmlChar *content, 990 int len); 991#endif /* LIBXML_TREE_ENABLED */ 992XMLPUBFUN void XMLCALL 993 xmlNodeAddContent (xmlNodePtr cur, 994 const xmlChar *content); 995XMLPUBFUN void XMLCALL 996 xmlNodeAddContentLen (xmlNodePtr cur, 997 const xmlChar *content, 998 int len); 999XMLPUBFUN xmlChar * XMLCALL 1000 xmlNodeGetContent (xmlNodePtr cur); 1001XMLPUBFUN int XMLCALL 1002 xmlNodeBufGetContent (xmlBufferPtr buffer, 1003 xmlNodePtr cur); 1004XMLPUBFUN xmlChar * XMLCALL 1005 xmlNodeGetLang (xmlNodePtr cur); 1006XMLPUBFUN int XMLCALL 1007 xmlNodeGetSpacePreserve (xmlNodePtr cur); 1008#ifdef LIBXML_TREE_ENABLED 1009XMLPUBFUN void XMLCALL 1010 xmlNodeSetLang (xmlNodePtr cur, 1011 const xmlChar *lang); 1012XMLPUBFUN void XMLCALL 1013 xmlNodeSetSpacePreserve (xmlNodePtr cur, 1014 int val); 1015#endif /* LIBXML_TREE_ENABLED */ 1016XMLPUBFUN xmlChar * XMLCALL 1017 xmlNodeGetBase (xmlDocPtr doc, 1018 xmlNodePtr cur); 1019#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) 1020XMLPUBFUN void XMLCALL 1021 xmlNodeSetBase (xmlNodePtr cur, 1022 const xmlChar *uri); 1023#endif 1024 1025/* 1026 * Removing content. 1027 */ 1028XMLPUBFUN int XMLCALL 1029 xmlRemoveProp (xmlAttrPtr cur); 1030#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) 1031XMLPUBFUN int XMLCALL 1032 xmlUnsetNsProp (xmlNodePtr node, 1033 xmlNsPtr ns, 1034 const xmlChar *name); 1035XMLPUBFUN int XMLCALL 1036 xmlUnsetProp (xmlNodePtr node, 1037 const xmlChar *name); 1038#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ 1039 1040/* 1041 * Internal, don't use. 1042 */ 1043XMLPUBFUN void XMLCALL 1044 xmlBufferWriteCHAR (xmlBufferPtr buf, 1045 const xmlChar *string); 1046XMLPUBFUN void XMLCALL 1047 xmlBufferWriteChar (xmlBufferPtr buf, 1048 const char *string); 1049XMLPUBFUN void XMLCALL 1050 xmlBufferWriteQuotedString(xmlBufferPtr buf, 1051 const xmlChar *string); 1052 1053#ifdef LIBXML_OUTPUT_ENABLED 1054XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf, 1055 xmlDocPtr doc, 1056 xmlAttrPtr attr, 1057 const xmlChar *string); 1058#endif /* LIBXML_OUTPUT_ENABLED */ 1059 1060#ifdef LIBXML_TREE_ENABLED 1061/* 1062 * Namespace handling. 1063 */ 1064XMLPUBFUN int XMLCALL 1065 xmlReconciliateNs (xmlDocPtr doc, 1066 xmlNodePtr tree); 1067#endif 1068 1069#ifdef LIBXML_OUTPUT_ENABLED 1070/* 1071 * Saving. 1072 */ 1073XMLPUBFUN void XMLCALL 1074 xmlDocDumpFormatMemory (xmlDocPtr cur, 1075 xmlChar **mem, 1076 int *size, 1077 int format); 1078XMLPUBFUN void XMLCALL 1079 xmlDocDumpMemory (xmlDocPtr cur, 1080 xmlChar **mem, 1081 int *size); 1082XMLPUBFUN void XMLCALL 1083 xmlDocDumpMemoryEnc (xmlDocPtr out_doc, 1084 xmlChar **doc_txt_ptr, 1085 int * doc_txt_len, 1086 const char *txt_encoding); 1087XMLPUBFUN void XMLCALL 1088 xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, 1089 xmlChar **doc_txt_ptr, 1090 int * doc_txt_len, 1091 const char *txt_encoding, 1092 int format); 1093XMLPUBFUN int XMLCALL 1094 xmlDocFormatDump (FILE *f, 1095 xmlDocPtr cur, 1096 int format); 1097XMLPUBFUN int XMLCALL 1098 xmlDocDump (FILE *f, 1099 xmlDocPtr cur); 1100XMLPUBFUN void XMLCALL 1101 xmlElemDump (FILE *f, 1102 xmlDocPtr doc, 1103 xmlNodePtr cur); 1104XMLPUBFUN int XMLCALL 1105 xmlSaveFile (const char *filename, 1106 xmlDocPtr cur); 1107XMLPUBFUN int XMLCALL 1108 xmlSaveFormatFile (const char *filename, 1109 xmlDocPtr cur, 1110 int format); 1111XMLPUBFUN int XMLCALL 1112 xmlNodeDump (xmlBufferPtr buf, 1113 xmlDocPtr doc, 1114 xmlNodePtr cur, 1115 int level, 1116 int format); 1117 1118XMLPUBFUN int XMLCALL 1119 xmlSaveFileTo (xmlOutputBufferPtr buf, 1120 xmlDocPtr cur, 1121 const char *encoding); 1122XMLPUBFUN int XMLCALL 1123 xmlSaveFormatFileTo (xmlOutputBufferPtr buf, 1124 xmlDocPtr cur, 1125 const char *encoding, 1126 int format); 1127XMLPUBFUN void XMLCALL 1128 xmlNodeDumpOutput (xmlOutputBufferPtr buf, 1129 xmlDocPtr doc, 1130 xmlNodePtr cur, 1131 int level, 1132 int format, 1133 const char *encoding); 1134 1135XMLPUBFUN int XMLCALL 1136 xmlSaveFormatFileEnc (const char *filename, 1137 xmlDocPtr cur, 1138 const char *encoding, 1139 int format); 1140 1141XMLPUBFUN int XMLCALL 1142 xmlSaveFileEnc (const char *filename, 1143 xmlDocPtr cur, 1144 const char *encoding); 1145 1146#endif /* LIBXML_OUTPUT_ENABLED */ 1147/* 1148 * XHTML 1149 */ 1150XMLPUBFUN int XMLCALL 1151 xmlIsXHTML (const xmlChar *systemID, 1152 const xmlChar *publicID); 1153 1154/* 1155 * Compression. 1156 */ 1157XMLPUBFUN int XMLCALL 1158 xmlGetDocCompressMode (xmlDocPtr doc); 1159XMLPUBFUN void XMLCALL 1160 xmlSetDocCompressMode (xmlDocPtr doc, 1161 int mode); 1162XMLPUBFUN int XMLCALL 1163 xmlGetCompressMode (void); 1164XMLPUBFUN void XMLCALL 1165 xmlSetCompressMode (int mode); 1166 1167/* 1168* DOM-wrapper helper functions. 1169*/ 1170XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL 1171 xmlDOMWrapNewCtxt (void); 1172XMLPUBFUN void XMLCALL 1173 xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt); 1174XMLPUBFUN int XMLCALL 1175 xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt, 1176 xmlNodePtr elem, 1177 int options); 1178XMLPUBFUN int XMLCALL 1179 xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt, 1180 xmlDocPtr sourceDoc, 1181 xmlNodePtr node, 1182 xmlDocPtr destDoc, 1183 xmlNodePtr destParent, 1184 int options); 1185XMLPUBFUN int XMLCALL 1186 xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt, 1187 xmlDocPtr doc, 1188 xmlNodePtr node, 1189 int options); 1190XMLPUBFUN int XMLCALL 1191 xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt, 1192 xmlDocPtr sourceDoc, 1193 xmlNodePtr node, 1194 xmlNodePtr *clonedNode, 1195 xmlDocPtr destDoc, 1196 xmlNodePtr destParent, 1197 int deep, 1198 int options); 1199 1200#ifdef __cplusplus 1201} 1202#endif 1203#ifndef __XML_PARSER_H__ 1204#include <libxml/xmlmemory.h> 1205#endif 1206 1207#endif /* __XML_TREE_H__ */ 1208 1209