tree.h 37 KB

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