libxml-rs 0.1.0-alpha.49

Native-Rust forensic reimplementation of libxml2+libxslt with C ABI drop-in replacement. Cross-version oracle matrix (libxml2 2.7.8-2.15.3, libxslt 1.1.26-1.1.45) with semantic epochs; full xmllint/xmlcatalog/xsltproc CLIs; differential-court-verified C API closure; three-DSO ELF packaging (libxml2.so.16 core + libxslt.so.1/libexslt.so.0 facades, upstream NEEDED chain); fail-closed oracle-isolated ABI-FUNCTION-SIGNATURE plane (SOURCE_PROTOTYPE + MACHINE_ABI fingerprints, zero silent omissions); Phase-12 real downstream substitution (binary/static/docker substitution, export-surface disposition, ELF version graphs); Phase-13 hostile audit courts (ABI/ownership/allocator/callbacks/failure/threads/oracle-contamination) byte-identical vs the system oracle incl. the upstream thread-local globals model; Phase-14 downstream custodian validation courts (lxml/Nokogiri/PHP/Debian). Test counts live in atlas/TEST_COUNTS.json, residuals in atlas/RESIDUAL_LEDGER.json (generated evidence).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
/**
 * @file
 *
 * Document tree API for libxml-rs
 */

#ifndef __XML_TREE_H__
#define __XML_TREE_H__

#include <stdio.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlstring.h>
#include <libxml/xmlmemory.h>
#include <libxml/xmlregexp.h>

#ifdef __cplusplus
extern "C" {
#endif




































































































































/* Forward declarations */
struct _xmlParserInputBuffer;
typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
typedef struct _xmlParserInput xmlParserInput;
typedef struct _xmlParserCtxt xmlParserCtxt;
typedef xmlParserInputBuffer *xmlParserInputBufferPtr;

struct _xmlOutputBuffer;
typedef struct _xmlOutputBuffer xmlOutputBuffer;
typedef xmlOutputBuffer *xmlOutputBufferPtr;

typedef struct _xmlBuffer xmlBuffer;
typedef xmlBuffer *xmlBufferPtr;

/* Phase 14 (DOWNSTREAM-LXML): upstream tree.h defines LIBXML2_NEW_BUFFER to
 * express that the API uses the new xmlBuf-based buffers (introduced in
 * libxml2 2.9.0); consumers (lxml etree_defs.h) key their xmlBuf alias off
 * it. Verbatim from the upstream oracle header. */
#define LIBXML2_NEW_BUFFER

typedef struct _xmlBuf xmlBuf;
typedef xmlBuf *xmlBufPtr;

typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;

typedef struct _xmlDoc xmlDoc;
typedef xmlDoc *xmlDocPtr;

typedef struct _xmlNs xmlNs;
typedef xmlNs *xmlNsPtr;

typedef struct _xmlAttr xmlAttr;
typedef xmlAttr *xmlAttrPtr;

typedef struct _xmlDtd xmlDtd;
typedef xmlDtd *xmlDtdPtr;

typedef struct _xmlEntity xmlEntity;
typedef xmlEntity *xmlEntityPtr;

typedef struct _xmlNotation xmlNotation;
typedef xmlNotation *xmlNotationPtr;

typedef struct _xmlElementContent xmlElementContent;
typedef xmlElementContent *xmlElementContentPtr;

typedef struct _xmlAttribute xmlAttribute;
typedef xmlAttribute *xmlAttributePtr;

/* DTD declaration tables (upstream tree.h) */
typedef struct _xmlHashTable xmlAttributeTable;
typedef xmlAttributeTable *xmlAttributeTablePtr;
typedef struct _xmlHashTable xmlElementTable;
typedef xmlElementTable *xmlElementTablePtr;
typedef struct _xmlHashTable xmlEntitiesTable;
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
typedef struct _xmlHashTable xmlNotationTable;
typedef xmlNotationTable *xmlNotationTablePtr;

typedef struct _xmlEnumeration xmlEnumeration;
typedef xmlEnumeration *xmlEnumerationPtr;

typedef struct _xmlID xmlID;
typedef xmlID *xmlIDPtr;

typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;

struct _xmlParserNodeInfo {
    const struct _xmlNode *node;
    unsigned long begin_pos;
    unsigned long begin_line;
    unsigned long end_pos;
    unsigned long end_line;
};

typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;

typedef struct _xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;

struct _xmlParserNodeInfoSeq {
    unsigned long maximum;
    unsigned long length;
    xmlParserNodeInfo *buffer;
};

/* Element types */
typedef enum {
    XML_ELEMENT_NODE = 1,
    XML_ATTRIBUTE_NODE = 2,
    XML_TEXT_NODE = 3,
    XML_CDATA_SECTION_NODE = 4,
    XML_ENTITY_REF_NODE = 5,
    XML_ENTITY_NODE = 6,
    XML_PI_NODE = 7,
    XML_COMMENT_NODE = 8,
    XML_DOCUMENT_NODE = 9,
    XML_DOCUMENT_TYPE_NODE = 10,
    XML_DOCUMENT_FRAG_NODE = 11,
    XML_NOTATION_NODE = 12,
    XML_HTML_DOCUMENT_NODE = 13,
    XML_DTD_NODE = 14,
    XML_ELEMENT_DECL = 15,
    XML_ATTRIBUTE_DECL = 16,
    XML_ENTITY_DECL = 17,
    XML_NAMESPACE_DECL = 18,
    XML_XINCLUDE_START = 19,
    XML_XINCLUDE_END = 20
} xmlElementType;

typedef enum {
    XML_ATTRIBUTE_CDATA = 1,
    XML_ATTRIBUTE_ID = 2,
    XML_ATTRIBUTE_IDREF = 3,
    XML_ATTRIBUTE_IDREFS = 4,
    XML_ATTRIBUTE_ENTITY = 5,
    XML_ATTRIBUTE_ENTITIES = 6,
    XML_ATTRIBUTE_NMTOKEN = 7,
    XML_ATTRIBUTE_NMTOKENS = 8,
    XML_ATTRIBUTE_ENUMERATION = 9,
    XML_ATTRIBUTE_NOTATION = 10
} xmlAttributeType;

typedef enum {
    XML_ATTRIBUTE_NONE = 1,
    XML_ATTRIBUTE_REQUIRED = 2,
    XML_ATTRIBUTE_IMPLIED = 3,
    XML_ATTRIBUTE_FIXED = 4
} xmlAttributeDefault;

typedef enum {
    XML_INTERNAL_GENERAL_ENTITY = 1,
    XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
    XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
    XML_INTERNAL_PARAMETER_ENTITY = 4,
    XML_EXTERNAL_PARAMETER_ENTITY = 5,
    XML_INTERNAL_PREDEFINED_ENTITY = 6
} xmlEntityType;

typedef enum {
    XML_BUFFER_ALLOC_DOUBLEIT,
    XML_BUFFER_ALLOC_EXACT,
    XML_BUFFER_ALLOC_IMMUTABLE,
    XML_BUFFER_ALLOC_IO,
    XML_BUFFER_ALLOC_HYBRID,
    XML_BUFFER_ALLOC_BOUNDED
} xmlBufferAllocationScheme;

/* Document properties */

/* Well-known namespaces */
#define XML_XML_NAMESPACE ((const xmlChar *) "http://www.w3.org/XML/1998/namespace")
#define XML_XMLNS_NAMESPACE ((const xmlChar *) "http://www.w3.org/2000/xmlns/")
#define XML_XMLNS_PREFIX ((const xmlChar *) "xmlns")

/* Limits */
#define XML_MAX_TEXT_LENGTH 1000000000
#define XML_MAX_NAME_LENGTH 50000
#define XML_MAX_DICTIONARY_LIMIT 10000000
#define XML_MAX_LOOKUP_LIMIT 1000000
#define XML_MAX_HUGE_LENGTH 100000000
#define XML_MAX_NAMELEN 50000
#define XML_MAX_ATTRIBUTE_LENGTH 50000

/* Buffer structure */
struct _xmlBuffer {
    xmlChar *content;
    unsigned int use;
    unsigned int size;
    xmlBufferAllocationScheme alloc;
    xmlChar *contentIO;
};

/* Node structure */
struct _xmlNode {
    void *_private;
    int type;
    const xmlChar *name;
    xmlNodePtr children;
    xmlNodePtr last;
    xmlNodePtr parent;
    xmlNodePtr next;
    xmlNodePtr prev;
    xmlDocPtr doc;
    xmlNsPtr ns;
    xmlChar *content;
    xmlAttrPtr properties;
    xmlNsPtr nsDef;
    void *psvi;
    unsigned short line;
    unsigned short extra;
};

/* Attribute structure */
struct _xmlAttr {
    void *_private;
    int type;
    const xmlChar *name;
    xmlNodePtr children;
    xmlNodePtr last;
    xmlNodePtr parent;
    xmlAttrPtr next;
    xmlAttrPtr prev;
    xmlDocPtr doc;
    xmlNsPtr ns;
    int atype;
    void *psvi;
    xmlIDPtr id;
};

/* Namespace structure */
struct _xmlNs {
    xmlNsPtr next;
    int type;
    const xmlChar *href;
    const xmlChar *prefix;
    void *_private;
    struct _xmlDoc *context;
};

/* Document structure */
struct _xmlDoc {
    void *_private;
    int type;
    char *name;
    xmlNodePtr children;
    xmlNodePtr last;
    xmlNodePtr parent;
    xmlNodePtr next;
    xmlNodePtr prev;
    xmlDocPtr doc;
    int compression;
    int standalone;
    xmlDtdPtr intSubset;
    xmlDtdPtr extSubset;
    xmlNsPtr oldNs;
    xmlChar *version;
    xmlChar *encoding;
    void *ids;
    void *refs;
    xmlChar *URL;
    int charset;
    struct _xmlDict *dict;
    void *psvi;
    int parseFlags;
    int properties;
};

/* DTD structure */
struct _xmlDtd {
    void *_private;
    int type;
    const xmlChar *name;
    xmlNodePtr children;
    xmlNodePtr last;
    xmlNodePtr parent;
    xmlNodePtr next;
    xmlNodePtr prev;
    xmlDocPtr doc;
    void *notations;
    void *elements;
    void *attributes;
    void *entities;
    xmlChar *ExternalID;
    xmlChar *SystemID;
    void *pentities;
};

/* Entity structure */
struct _xmlEntity {
    void *_private;
    int type;
    const xmlChar *name;
    xmlNodePtr children;
    xmlNodePtr last;
    xmlNodePtr parent;
    xmlNodePtr next;
    xmlNodePtr prev;
    xmlDocPtr doc;
    xmlChar *orig;
    xmlChar *content;
    int length;
    int etype;
    const xmlChar *ExternalID;
    const xmlChar *SystemID;
    xmlEntityPtr nexte;
    const xmlChar *URI;
    int owner;
    int flags;
    unsigned long expandedSize;
};

/* Notation structure */
struct _xmlNotation {
    const xmlChar *name;
    const xmlChar *PublicID;
    const xmlChar *SystemID;
};

/* Element content structure */
struct _xmlElementContent {
    int type;
    int ocur;
    const xmlChar *name;
    xmlElementContentPtr c1;
    xmlElementContentPtr c2;
    xmlElementContentPtr parent;
    const xmlChar *prefix;
};

/* Enumeration structure */
struct _xmlEnumeration {
    struct _xmlEnumeration *next;
    const xmlChar *name;
};

/* Attribute declaration structure */
struct _xmlAttribute {
    void *_private;
    int type;
    const xmlChar *name;
    xmlNodePtr children;
    xmlNodePtr last;
    xmlNodePtr parent;
    xmlNodePtr next;
    xmlNodePtr prev;
    xmlDocPtr doc;
    xmlAttributePtr nexth;
    int atype;
    int def;
    const xmlChar *defaultValue;
    xmlEnumerationPtr tree;
    const xmlChar *prefix;
    const xmlChar *elem;
};

/* Element declaration types */
typedef enum {
    XML_ELEMENT_TYPE_UNDEFINED = 0,
    XML_ELEMENT_TYPE_EMPTY = 1,
    XML_ELEMENT_TYPE_ANY = 2,
    XML_ELEMENT_TYPE_MIXED = 3,
    XML_ELEMENT_TYPE_ELEMENT = 4
} xmlElementTypeVal;

/* Namespace type */
#define XML_LOCAL_NAMESPACE 0
typedef int xmlNsType;

/* Tree functions */
XMLPUBFUN xmlDocPtr xmlNewDoc(const xmlChar *version);
XMLPUBFUN void xmlFreeDoc(xmlDocPtr doc);
XMLPUBFUN xmlDocPtr xmlCopyDoc(const xmlDocPtr doc, int recursive);
XMLPUBFUN xmlNodePtr xmlNewNode(xmlNsPtr ns, const xmlChar *name);
XMLPUBFUN void xmlFreeNode(xmlNodePtr node);
XMLPUBFUN void xmlFreeNodeList(xmlNodePtr node);
XMLPUBFUN xmlNodePtr xmlCopyNode(const xmlNodePtr node, int extended);
XMLPUBFUN void xmlUnlinkNode(xmlNodePtr node);
XMLPUBFUN xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
XMLPUBFUN xmlNodePtr xmlAddSibling(xmlNodePtr cur, xmlNodePtr sibling);
XMLPUBFUN xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
                                  const xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlNodePtr xmlNewText(const xmlChar *content);
XMLPUBFUN xmlNodePtr xmlNewComment(const xmlChar *content);
XMLPUBFUN xmlNodePtr xmlNewPI(const xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlNodePtr xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len);
XMLPUBFUN xmlNodePtr xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root);
XMLPUBFUN xmlNodePtr xmlDocGetRootElement(const xmlDoc *doc);
XMLPUBFUN long xmlGetLineNo(const xmlNode *node);
XMLPUBFUN xmlNodePtr xmlFirstElementChild(xmlNodePtr parent);
XMLPUBFUN xmlNodePtr xmlLastElementChild(xmlNodePtr parent);
XMLPUBFUN xmlNodePtr xmlNextElementSibling(xmlNodePtr node);
XMLPUBFUN xmlNodePtr xmlPreviousElementSibling(xmlNodePtr node);
XMLPUBFUN int xmlNodeIsText(const xmlNode *node);
XMLPUBFUN int xmlIsBlankNode(const xmlNode *node);
XMLPUBFUN xmlNsPtr xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix);
XMLPUBFUN void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
XMLPUBFUN xmlNs **xmlGetNsList(const xmlDoc *doc, const xmlNode *node);
XMLPUBFUN xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace);
XMLPUBFUN xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar *href);
XMLPUBFUN xmlAttrPtr xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value);
XMLPUBFUN xmlChar *xmlGetProp(const xmlNode *node, const xmlChar *name);
XMLPUBFUN xmlChar *xmlNodeGetContent(const xmlNode *cur);
XMLPUBFUN xmlChar *xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur);
XMLPUBFUN int xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content);
XMLPUBFUN void xmlNodeSetName(xmlNodePtr cur, const xmlChar *name);
XMLPUBFUN int xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc);
XMLPUBFUN int xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc);
XMLPUBFUN xmlAttrPtr xmlHasProp(const xmlNode *node, const xmlChar *name);
XMLPUBFUN xmlNodePtr xmlDocCopyNode(const xmlNodePtr node, xmlDocPtr doc, int extended);
XMLPUBFUN xmlNodePtr xmlCopyNodeList(const xmlNodePtr node);
XMLPUBFUN xmlAttrPtr xmlCopyProp(xmlNodePtr target, const xmlAttrPtr cur);
XMLPUBFUN xmlAttrPtr xmlCopyPropList(xmlNodePtr target, const xmlAttrPtr cur);
XMLPUBFUN xmlChar *xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace);
XMLPUBFUN xmlAttrPtr xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns,
                                   const xmlChar *name, const xmlChar *value);
XMLPUBFUN int xmlRemoveProp(xmlAttrPtr attr);
XMLPUBFUN xmlDtdPtr xmlGetIntSubset(const xmlDoc *doc);
XMLPUBFUN xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
                               const xmlChar *ExternalID, const xmlChar *SystemID);
XMLPUBFUN xmlEntityPtr xmlNewEntity(xmlDocPtr doc, const xmlChar *name, int type,
                                     const xmlChar *ExternalID, const xmlChar *SystemID,
                                     const xmlChar *content);
XMLPUBFUN xmlEntityPtr xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name);
XMLPUBFUN xmlEntityPtr xmlGetParameterEntity(xmlDoc *doc, const xmlChar *name);
XMLPUBFUN xmlBufferPtr xmlBufferCreate(void);
XMLPUBFUN xmlBufferPtr xmlBufferCreateSize(size_t size);
XMLPUBFUN xmlBufferPtr xmlBufferCreateStatic(void *mem, size_t size);
XMLPUBFUN void xmlBufferFree(xmlBufferPtr buf);
XMLPUBFUN void xmlBufferEmpty(xmlBufferPtr buf);
XMLPUBFUN const xmlChar *xmlBufferContent(const xmlBuffer *buf);
XMLPUBFUN int xmlBufferLength(const xmlBuffer *buf);
XMLPUBFUN int xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len);
XMLPUBFUN int xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len);
XMLPUBFUN void xmlBufferSetAllocationScheme(xmlBufferPtr buf, xmlBufferAllocationScheme scheme);
XMLPUBFUN int xmlBufferShrink(xmlBufferPtr buf, unsigned int len);
XMLPUBFUN int xmlBufferGrow(xmlBufferPtr buf, unsigned int len);
XMLPUBFUN int xmlBufferReserve(xmlBufferPtr buf, int len);
XMLPUBFUN xmlChar *xmlBufferDetach(xmlBufferPtr buf);
XMLPUBFUN int xmlIsBlankNode(const xmlNode *node);
















































































































































































































/* [11.1-G] begin: extracted verbatim from upstream oracle header */
typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt;
typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr;

/**
 * A function called to acquire namespaces (xmlNs) from the wrapper.
 *
 * @param ctxt  a DOM wrapper context
 * @param node  the context node (element or attribute)
 * @param nsName  the requested namespace name
 * @param nsPrefix  the requested namespace prefix
 * @returns an xmlNs or NULL in case of an error.
 */
typedef xmlNs *(*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxt *ctxt,
						 xmlNode *node,
						 const xmlChar *nsName,
						 const xmlChar *nsPrefix);

/**
 * Context for DOM wrapper-operations.
 */

typedef struct _xmlElement xmlElement;
typedef xmlElement *xmlElementPtr;
/**
 * An XML Element declaration from a DTD.
 *
 * Should be treated as opaque. Accessing members directly
 * is deprecated.
 */

typedef struct _xmlRef xmlRef;
typedef xmlRef *xmlRefPtr;
/*
 * An XML IDREF instance.
 */

typedef enum{
    XML_DOC_WELLFORMED		= 1<<0,
    XML_DOC_NSVALID		= 1<<1,
    XML_DOC_OLD10		= 1<<2,
    XML_DOC_DTDVALID		= 1<<3,
    XML_DOC_XINCLUDE		= 1<<4,
    XML_DOC_USERBUILT		= 1<<5,
    XML_DOC_INTERNAL		= 1<<6,
    XML_DOC_HTML		= 1<<7
} xmlDocProperties;

typedef enum{
    XML_ELEMENT_CONTENT_ONCE = 1,
    XML_ELEMENT_CONTENT_OPT,
    XML_ELEMENT_CONTENT_MULT,
    XML_ELEMENT_CONTENT_PLUS
} xmlElementContentOccur;

typedef enum{
    XML_ELEMENT_CONTENT_PCDATA = 1,
    XML_ELEMENT_CONTENT_ELEMENT,
    XML_ELEMENT_CONTENT_SEQ,
    XML_ELEMENT_CONTENT_OR
} xmlElementContentType;

struct _xmlDOMWrapCtxt {
    void * _private;
    /*
    * The type of this context, just in case we need specialized
    * contexts in the future.
    */
    int type;
    /*
    * Internal namespace map used for various operations.
    */
    void * namespaceMap;
    /*
    * Use this one to acquire an xmlNs intended for node->ns.
    * (Note that this is not intended for elem->nsDef).
    */
    xmlDOMWrapAcquireNsFunction getNsForNodeFunc;
};

struct _xmlElement {
    /** application data */
    void           *_private;
    /** XML_ELEMENT_DECL */
    xmlElementType          type;
    /** element name */
    const xmlChar          *name;
    /** NULL */
    struct _xmlNode    *children;
    /** NULL */
    struct _xmlNode        *last;
    /** -> DTD */
    struct _xmlDtd       *parent;
    /** next sibling */
    struct _xmlNode        *next;
    /** previous sibling */
    struct _xmlNode        *prev;
    /** containing document */
    struct _xmlDoc          *doc;

    /** element type */
    xmlElementTypeVal      etype XML_DEPRECATED_MEMBER;
    /** allowed element content */
    xmlElementContent *content XML_DEPRECATED_MEMBER;
    /** list of declared attributes */
    xmlAttribute     *attributes XML_DEPRECATED_MEMBER;
    /** namespace prefix if any */
    const xmlChar        *prefix XML_DEPRECATED_MEMBER;
#ifdef LIBXML_REGEXP_ENABLED
    /** validating regexp */
    xmlRegexp         *contModel XML_DEPRECATED_MEMBER;
#else
    void	      *contModel XML_DEPRECATED_MEMBER;
#endif
};

struct _xmlID {
    /* next ID */
    struct _xmlID    *next XML_DEPRECATED_MEMBER;
    /* The ID name */
    xmlChar *value XML_DEPRECATED_MEMBER;
    /* The attribute holding it */
    xmlAttr          *attr XML_DEPRECATED_MEMBER;
    /* The attribute if attr is not available */
    const xmlChar    *name XML_DEPRECATED_MEMBER;
    /* The line number if attr is not available */
    int               lineno XML_DEPRECATED_MEMBER;
    /* The document holding the ID */
    struct _xmlDoc   *doc XML_DEPRECATED_MEMBER;
};

struct _xmlRef {
    /* next Ref */
    struct _xmlRef    *next XML_DEPRECATED_MEMBER;
    /* The Ref name */
    const xmlChar     *value XML_DEPRECATED_MEMBER;
    /* The attribute holding it */
    xmlAttr          *attr XML_DEPRECATED_MEMBER;
    /* The attribute if attr is not available */
    const xmlChar    *name XML_DEPRECATED_MEMBER;
    /* The line number if attr is not available */
    int               lineno XML_DEPRECATED_MEMBER;
};

/* [11.1-G] end: extracted definitions */

/* [11.1-L] begin: node-registration callback declarations extracted verbatim
 * from the oracle libxml2 2.15.3 tree.h (exported by the candidate DSO). */
typedef void (*xmlRegisterNodeFunc) (xmlNode *node);
typedef void (*xmlDeregisterNodeFunc) (xmlNode *node);
XMLPUBFUN xmlRegisterNodeFunc
	    xmlRegisterNodeDefault	(xmlRegisterNodeFunc func);
XMLPUBFUN xmlDeregisterNodeFunc
	    xmlDeregisterNodeDefault	(xmlDeregisterNodeFunc func);
/* [11.1-L] end: extracted declarations */

/* [11.1-S] begin: oracle-extracted declarations
 * Extracted verbatim from the upstream headers (11.1-S header-surface
 * audit: every function the oracle headers declare must be declared by the
 * drop-in headers — the source-compatibility contract. Signatures are the upstream ABI contract.
 */
XMLPUBFUN xmlNode * xmlAddChildList (xmlNode *parent, xmlNode *cur);
XMLPUBFUN xmlNode * xmlAddNextSibling (xmlNode *cur, xmlNode *elem);
XMLPUBFUN xmlNode * xmlAddPrevSibling (xmlNode *cur, xmlNode *elem);
XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBuffer *buf, xmlDoc *doc, xmlAttr *attr, const xmlChar *string);
XMLPUBFUN xmlChar* xmlBufContent (const xmlBuf* buf);
XMLPUBFUN xmlChar* xmlBufEnd (xmlBuf *buf);
XMLPUBFUN int xmlBufGetNodeContent (xmlBuf *buf, const xmlNode *cur);
XMLPUBFUN size_t xmlBufNodeDump (xmlBuf *buf, xmlDoc *doc, xmlNode *cur, int level, int format);
XMLPUBFUN size_t xmlBufShrink (xmlBuf *buf, size_t len);
XMLPUBFUN size_t xmlBufUse (xmlBuf *buf);
XMLPUBFUN int xmlBufferCCat (xmlBuffer *buf, const char *str);
XMLPUBFUN int xmlBufferCat (xmlBuffer *buf, const xmlChar *str);
XMLPUBFUN int xmlBufferDump (FILE *file, xmlBuffer *buf);
XMLPUBFUN int xmlBufferResize (xmlBuffer *buf, unsigned int size);
XMLPUBFUN void xmlBufferWriteCHAR (xmlBuffer *buf, const xmlChar *string);
XMLPUBFUN void xmlBufferWriteChar (xmlBuffer *buf, const char *string);
XMLPUBFUN void xmlBufferWriteQuotedString(xmlBuffer *buf, const xmlChar *string);
XMLPUBFUN xmlChar * xmlBuildQName (const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len);
XMLPUBFUN unsigned long xmlChildElementCount (xmlNode *parent);
XMLPUBFUN xmlDtd * xmlCopyDtd (xmlDtd *dtd);
XMLPUBFUN xmlNs * xmlCopyNamespace (xmlNs *cur);
XMLPUBFUN xmlNs * xmlCopyNamespaceList (xmlNs *cur);
XMLPUBFUN xmlDtd * xmlCreateIntSubset (xmlDoc *doc, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId);
XMLPUBFUN int xmlDOMWrapAdoptNode (xmlDOMWrapCtxt *ctxt, xmlDoc *sourceDoc, xmlNode *node, xmlDoc *destDoc, xmlNode *destParent, int options);
XMLPUBFUN int xmlDOMWrapCloneNode (xmlDOMWrapCtxt *ctxt, xmlDoc *sourceDoc, xmlNode *node, xmlNode **clonedNode, xmlDoc *destDoc, xmlNode *destParent, int deep, int options);
XMLPUBFUN void xmlDOMWrapFreeCtxt (xmlDOMWrapCtxt *ctxt);
XMLPUBFUN xmlDOMWrapCtxt * xmlDOMWrapNewCtxt (void);
XMLPUBFUN int xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxt *ctxt, xmlNode *elem, int options);
XMLPUBFUN int xmlDOMWrapRemoveNode (xmlDOMWrapCtxt *ctxt, xmlDoc *doc, xmlNode *node, int options);
XMLPUBFUN xmlNode * xmlDocCopyNodeList (xmlDoc *doc, xmlNode *node);
XMLPUBFUN int xmlDocDump (FILE *f, xmlDoc *cur);
XMLPUBFUN void xmlDocDumpFormatMemory (xmlDoc *cur, xmlChar **mem, int *size, int format);
XMLPUBFUN void xmlDocDumpFormatMemoryEnc(xmlDoc *out_doc, xmlChar **doc_txt_ptr, int * doc_txt_len, const char *txt_encoding, int format);
XMLPUBFUN void xmlDocDumpMemory (xmlDoc *cur, xmlChar **mem, int *size);
XMLPUBFUN void xmlDocDumpMemoryEnc (xmlDoc *out_doc, xmlChar **doc_txt_ptr, int * doc_txt_len, const char *txt_encoding);
XMLPUBFUN int xmlDocFormatDump (FILE *f, xmlDoc *cur, int format);
XMLPUBFUN void xmlElemDump (FILE *f, xmlDoc *doc, xmlNode *cur);
XMLPUBFUN void xmlFreeDtd (xmlDtd *cur);
XMLPUBFUN void xmlFreeNs (xmlNs *cur);
XMLPUBFUN void xmlFreeNsList (xmlNs *cur);
XMLPUBFUN void xmlFreeProp (xmlAttr *cur);
XMLPUBFUN void xmlFreePropList (xmlAttr *cur);
XMLPUBFUN xmlBufferAllocationScheme xmlGetBufferAllocationScheme(void);
XMLPUBFUN int xmlGetCompressMode (void);
XMLPUBFUN int xmlGetDocCompressMode (const xmlDoc *doc);
XMLPUBFUN xmlNode * xmlGetLastChild (const xmlNode *parent);
XMLPUBFUN xmlChar * xmlGetNoNsProp (const xmlNode *node, const xmlChar *name);
XMLPUBFUN xmlChar * xmlGetNodePath (const xmlNode *node);
XMLPUBFUN int xmlGetNsListSafe (const xmlDoc *doc, const xmlNode *node, xmlNs ***out);
XMLPUBFUN xmlAttr * xmlHasNsProp (const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace);
XMLPUBFUN int xmlIsXHTML (const xmlChar *systemID, const xmlChar *publicID);
XMLPUBFUN xmlNode * xmlNewCharRef (xmlDoc *doc, const xmlChar *name);
XMLPUBFUN xmlNode * xmlNewDocComment (xmlDoc *doc, const xmlChar *content);
XMLPUBFUN xmlNode * xmlNewDocFragment (xmlDoc *doc);
XMLPUBFUN xmlNode * xmlNewDocNode (xmlDoc *doc, xmlNs *ns, const xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlNode * xmlNewDocNodeEatName (xmlDoc *doc, xmlNs *ns, xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlNode * xmlNewDocPI (xmlDoc *doc, const xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlAttr * xmlNewDocProp (xmlDoc *doc, const xmlChar *name, const xmlChar *value);
XMLPUBFUN xmlNode * xmlNewDocRawNode (xmlDoc *doc, xmlNs *ns, const xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlNode * xmlNewDocText (const xmlDoc *doc, const xmlChar *content);
XMLPUBFUN xmlNode * xmlNewDocTextLen (xmlDoc *doc, const xmlChar *content, int len);
XMLPUBFUN xmlNode * xmlNewNodeEatName (xmlNs *ns, xmlChar *name);
XMLPUBFUN xmlAttr * xmlNewNsProp (xmlNode *node, xmlNs *ns, const xmlChar *name, const xmlChar *value);
XMLPUBFUN xmlAttr * xmlNewNsPropEatName (xmlNode *node, xmlNs *ns, xmlChar *name, const xmlChar *value);
XMLPUBFUN xmlAttr * xmlNewProp (xmlNode *node, const xmlChar *name, const xmlChar *value);
XMLPUBFUN xmlNode * xmlNewReference (const xmlDoc *doc, const xmlChar *name);
XMLPUBFUN xmlNode * xmlNewTextChild (xmlNode *parent, xmlNs *ns, const xmlChar *name, const xmlChar *content);
XMLPUBFUN xmlNode * xmlNewTextLen (const xmlChar *content, int len);
XMLPUBFUN int xmlNodeAddContent (xmlNode *cur, const xmlChar *content);
XMLPUBFUN int xmlNodeAddContentLen (xmlNode *cur, const xmlChar *content, int len);
XMLPUBFUN int xmlNodeBufGetContent (xmlBuffer *buffer, const xmlNode *cur);
XMLPUBFUN int xmlNodeDump (xmlBuffer *buf, xmlDoc *doc, xmlNode *cur, int level, int format);
XMLPUBFUN void xmlNodeDumpOutput (xmlOutputBuffer *buf, xmlDoc *doc, xmlNode *cur, int level, int format, const char *encoding);
XMLPUBFUN int xmlNodeGetAttrValue (const xmlNode *node, const xmlChar *name, const xmlChar *nsUri, xmlChar **out);
XMLPUBFUN int xmlNodeGetBaseSafe (const xmlDoc *doc, const xmlNode *cur, xmlChar **baseOut);
XMLPUBFUN xmlChar * xmlNodeGetLang (const xmlNode *cur);
XMLPUBFUN int xmlNodeGetSpacePreserve (const xmlNode *cur);
XMLPUBFUN xmlChar * xmlNodeListGetRawString (const xmlDoc *doc, const xmlNode *list, int inLine);
XMLPUBFUN xmlChar * xmlNodeListGetString (xmlDoc *doc, const xmlNode *list, int inLine);
XMLPUBFUN int xmlNodeSetBase (xmlNode *cur, const xmlChar *uri);
XMLPUBFUN int xmlNodeSetContentLen (xmlNode *cur, const xmlChar *content, int len);
XMLPUBFUN int xmlNodeSetLang (xmlNode *cur, const xmlChar *lang);
XMLPUBFUN int xmlNodeSetSpacePreserve (xmlNode *cur, int val);
XMLPUBFUN int xmlReconciliateNs (xmlDoc *doc, xmlNode *tree);
XMLPUBFUN xmlNode * xmlReplaceNode (xmlNode *old, xmlNode *cur);
XMLPUBFUN int xmlSaveFile (const char *filename, xmlDoc *cur);
XMLPUBFUN int xmlSaveFileEnc (const char *filename, xmlDoc *cur, const char *encoding);
/* Legacy save family: upstream tree.h declares these alongside the
 * xmlsave.h xmlSaveTo* family (tree2.c includes only tree.h and calls
 * xmlSaveFormatFileEnc). Declared here verbatim so tree.h-only consumers
 * compile unchanged (Phase-12 EXTERNAL-CONSUMERS court). */
XMLPUBFUN int xmlSaveFormatFile (const char *filename, xmlDoc *cur, int format);
XMLPUBFUN int xmlSaveFileTo (xmlOutputBuffer *buf, xmlDoc *cur, const char *encoding);
XMLPUBFUN int xmlSaveFormatFileTo (xmlOutputBuffer *buf, xmlDoc *cur, const char *encoding, int format);
XMLPUBFUN int xmlSaveFormatFileEnc (const char *filename, xmlDoc *cur, const char *encoding, int format);
XMLPUBFUN void xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
XMLPUBFUN void xmlSetCompressMode (int mode);
XMLPUBFUN void xmlSetDocCompressMode (xmlDoc *doc, int mode);
XMLPUBFUN xmlChar * xmlSplitQName2 (const xmlChar *name, xmlChar **prefix);
XMLPUBFUN const xmlChar * xmlSplitQName3 (const xmlChar *name, int *len);
XMLPUBFUN xmlNode * xmlStringGetNodeList (const xmlDoc *doc, const xmlChar *value);
XMLPUBFUN xmlNode * xmlStringLenGetNodeList (const xmlDoc *doc, const xmlChar *value, int len);
XMLPUBFUN int xmlTextConcat (xmlNode *node, const xmlChar *content, int len);
XMLPUBFUN xmlNode * xmlTextMerge (xmlNode *first, xmlNode *second);
XMLPUBFUN xmlDeregisterNodeFunc xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
XMLPUBFUN xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
XMLPUBFUN int xmlUnsetNsProp (xmlNode *node, xmlNs *ns, const xmlChar *name);
XMLPUBFUN int xmlUnsetProp (xmlNode *node, const xmlChar *name);
XMLPUBFUN int xmlValidateNCName (const xmlChar *value, int space);
XMLPUBFUN int xmlValidateNMToken (const xmlChar *value, int space);
XMLPUBFUN int xmlValidateName (const xmlChar *value, int space);
XMLPUBFUN int xmlValidateQName (const xmlChar *value, int space);
/* [11.1-S] end: oracle-extracted declarations */

/* [13.1] begin: thread-local node-hook accessors + macro aliases
 *
 * Phase 13 (HOSTILE-THREADS): upstream 2.15 keeps the node
 * register/deregister hooks per-thread (globals.c xmlGetThreadLocalStorage);
 * the oracle headers alias the names to `(*__xmlXxx())` accessor functions
 * and the oracle DSO exports only the accessors. The candidate implements
 * the same contract (src/xml/globals/tls.rs). Guarded by
 * XML_GLOBALS_NO_REDEFINITION exactly like upstream tree.h.
 */
XMLPUBFUN xmlRegisterNodeFunc *__xmlRegisterNodeDefaultValue(void);
XMLPUBFUN xmlDeregisterNodeFunc *__xmlDeregisterNodeDefaultValue(void);

#ifndef XML_GLOBALS_NO_REDEFINITION
  #define xmlRegisterNodeDefaultValue \
    (*__xmlRegisterNodeDefaultValue())
  #define xmlDeregisterNodeDefaultValue \
    (*__xmlDeregisterNodeDefaultValue())
#endif /* XML_GLOBALS_NO_REDEFINITION */
/* [13.1] end: thread-local node-hook accessors + macro aliases */

#ifdef __cplusplus
}
#endif

#endif /* __XML_TREE_H__ */