Skip to main content

libxml_rs/abi/
structs.rs

1// Lint policy (11.1-Z seal): `missing_docs` and
2// `missing_debug_implementations` are allowed here — the fields mirror
3// upstream C structs whose canonical documentation is the C header itself
4// (the same rationale bindgen applies to generated bindings). The exported
5// `#[repr(C)]` layout is the contract, verified byte-for-byte by the
6// data-abi courts; the Rust doc surface adds nothing to it.
7#![allow(missing_docs, missing_debug_implementations)]
8
9//! C ABI struct definitions — exact upstream layout (§14, §17).
10//!
11//! Every struct in this module is laid out to match the corresponding
12//! upstream C struct byte-for-byte on the target platform.
13//!
14//! # Upstream structs
15//!
16//! All structs derived from SRC-LIBXML2-2.15.3-TREE-H and related headers.
17//! See the sub-agent extraction output for complete field-level archaeology.
18//!
19//! # Safety
20//!
21//! These structs are `#[repr(C)]` and may be passed across the FFI boundary.
22//! Fields marked `_deprecated_*` or `_unused_*` are retained for ABI
23//! compatibility even when the upstream has deprecated them.
24//!
25//! # Phase 1 status
26//!
27//! All core tree structs, error struct, parser context, SAX handler,
28//! XPath context/object, and I/O structs are defined.
29//!
30//! # ABI verification
31//!
32//! Each struct must be verified with `offsetof`/`sizeof` probes compiled
33//! from upstream headers. See courts/abi-struct-*.json for receipts.
34
35use crate::abi::callbacks::*;
36use crate::abi::types::*;
37use std::os::raw::{c_char, c_int, c_long, c_uint, c_ulong, c_ushort, c_void};
38
39// ── Forward declarations ────────────────────────────────────────────────
40//
41// These are the internal struct tags. In C, these are typedef'd to
42// pointer types. We define them as opaque handles or full structs
43// depending on whether the struct is public or opaque.
44
45// Opaque types (defined in .c files, not exposed in headers):
46//   _xmlDict, _xmlHashTable, _xmlList, _xmlRegexp, _xmlCatalog,
47//   _xmlXPathCompExpr, _xmlAutomata, _xmlPattern
48
49// ── xmlBuffer ───────────────────────────────────────────────────────────
50//
51// Source: tree.h lines 109-126
52
53/// Buffer structure. Deprecated in favor of xmlBuf.
54#[repr(C)]
55pub struct _xmlBuffer {
56    pub content: *mut xmlChar,   // The buffer content UTF8 (deprecated)
57    pub use_: c_uint,            // The buffer size used (deprecated)
58    pub size: c_uint,            // The buffer size (deprecated)
59    pub alloc: c_int,            // The realloc method (deprecated)
60    pub contentIO: *mut xmlChar, // In IO mode may have different base (deprecated)
61}
62
63// ── xmlNotation ─────────────────────────────────────────────────────────
64//
65// Source: tree.h lines 297-305
66
67/// Notation declaration.
68#[repr(C)]
69pub struct _xmlNotation {
70    pub name: *const xmlChar,     // Notation name
71    pub PublicID: *const xmlChar, // Public identifier, if any
72    pub SystemID: *const xmlChar, // System identifier, if any
73}
74
75// ── xmlEnumeration ──────────────────────────────────────────────────────
76//
77// Source: tree.h lines 341-345
78
79/// Enumeration value for attribute declarations.
80#[repr(C)]
81pub struct _xmlEnumeration {
82    pub next: *mut _xmlEnumeration, // Next in enumeration (deprecated)
83    pub name: *const xmlChar,       // Enumeration value
84}
85
86// ── xmlAttribute (declaration) ──────────────────────────────────────────
87//
88// Source: tree.h lines 357-391
89// NOTE: This is the ATTRIBUTE DECLARATION struct, not attribute node.
90// Attribute node is _xmlAttr below.
91
92/// Attribute declaration from DTD.
93#[repr(C)]
94pub struct _xmlAttribute {
95    pub _private: *mut c_void,   // Application data
96    pub type_: c_int,            // XML_ATTRIBUTE_DECL
97    pub name: *const xmlChar,    // Attribute name
98    pub children: *mut _xmlNode, // NULL
99    pub last: *mut _xmlNode,     // NULL
100    pub parent: *mut _xmlDtd,    // DTD
101    pub next: *mut _xmlNode,     // Next sibling
102    pub prev: *mut _xmlNode,     // Previous sibling
103    pub doc: *mut _xmlDoc,       // Containing document
104
105    pub nexth: *mut _xmlAttribute,  // Next in hash table
106    pub atype: c_int,               // Attribute type
107    pub def: c_int,                 // Attribute default
108    pub defaultValue: *mut xmlChar, // Default value
109    pub tree: *mut _xmlEnumeration, // Enumeration tree (deprecated)
110    pub prefix: *const xmlChar,     // Namespace prefix
111    pub elem: *const xmlChar,       // Element name
112}
113
114// ── xmlElementContent ───────────────────────────────────────────────────
115//
116// Source: tree.h lines 423-438
117
118/// Element content model.
119#[repr(C)]
120pub struct _xmlElementContent {
121    pub type_: c_int,                    // PCDATA, ELEMENT, SEQ or OR (deprecated)
122    pub ocur: c_int,                     // ONCE, OPT, MULT or PLUS (deprecated)
123    pub name: *const xmlChar,            // Element name (deprecated)
124    pub c1: *mut _xmlElementContent,     // First child (deprecated)
125    pub c2: *mut _xmlElementContent,     // Second child (deprecated)
126    pub parent: *mut _xmlElementContent, // Parent (deprecated)
127    pub prefix: *const xmlChar,          // Namespace prefix (deprecated)
128}
129
130// ── xmlElement (declaration) ────────────────────────────────────────────
131//
132// Source: tree.h lines 447-474
133
134/// Element declaration from DTD.
135///
136/// # ABI
137///
138/// Layout mirrors upstream `struct _xmlElement` (libxml2 2.15.x tree.h): the
139/// declaration is node-shaped (children/last/parent/next/prev/doc) even though
140/// it is stored in the DTD's element hash table. `cont_model` is the compiled
141/// content-model regexp built by `xmlValidBuildContentModel` and is opaque
142/// here (`xmlRegexp *` upstream).
143#[repr(C)]
144pub struct _xmlElement {
145    pub _private: *mut c_void,            // application data
146    pub type_: c_int,                     // xmlElementType (XML_ELEMENT_DECL)
147    pub name: *const xmlChar,             // Element name
148    pub children: *mut _xmlNode,          // NULL
149    pub last: *mut _xmlNode,              // NULL
150    pub parent: *mut _xmlDtd,             // -> DTD
151    pub next: *mut _xmlNode,              // next sibling (NULL for decls)
152    pub prev: *mut _xmlNode,              // previous sibling (NULL for decls)
153    pub doc: *mut _xmlDoc,                // containing document
154    pub etype: c_int,                     // xmlElementTypeVal
155    pub content: *mut _xmlElementContent, // Content model
156    pub attributes: *mut _xmlAttribute,   // List of declared attributes
157    pub prefix: *const xmlChar,           // Namespace prefix
158    pub cont_model: *mut c_void,          // validating regexp (xmlRegexp *)
159}
160
161// ── xmlNs ───────────────────────────────────────────────────────────────
162//
163// Source: tree.h lines 501-512
164
165/// Namespace declaration or XPath namespace node.
166#[repr(C)]
167pub struct _xmlNs {
168    pub next: *mut _xmlNs,      // Next namespace
169    pub type_: c_int,           // XML_NAMESPACE_DECL
170    pub href: *const xmlChar,   // Namespace URI
171    pub prefix: *const xmlChar, // Namespace prefix
172    pub _private: *mut c_void,  // Application data
173    pub context: *mut _xmlDoc,  // Normally an xmlDoc (deprecated)
174}
175
176// ── xmlDtd ──────────────────────────────────────────────────────────────
177//
178// Source: tree.h lines 538-564
179
180/// DTD (Document Type Definition).
181#[repr(C)]
182pub struct _xmlDtd {
183    pub _private: *mut c_void,   // Application data
184    pub type_: c_int,            // XML_DTD_NODE
185    pub name: *const xmlChar,    // Name of the DTD
186    pub children: *mut _xmlNode, // First child
187    pub last: *mut _xmlNode,     // Last child
188    pub parent: *mut _xmlDoc,    // Parent node (document)
189    pub next: *mut _xmlNode,     // Next sibling
190    pub prev: *mut _xmlNode,     // Previous sibling
191    pub doc: *mut _xmlDoc,       // Containing document
192    // End of common part
193    pub notations: *mut c_void,   // Hash table for notations
194    pub elements: *mut c_void,    // Hash table for elements
195    pub attributes: *mut c_void,  // Hash table for attributes
196    pub entities: *mut c_void,    // Hash table for entities
197    pub ExternalID: *mut xmlChar, // Public identifier
198    pub SystemID: *mut xmlChar,   // System identifier
199    pub pentities: *mut c_void,   // Hash table for parameter entities
200}
201
202// ── xmlAttr ─────────────────────────────────────────────────────────────
203//
204// Source: tree.h lines 595-615
205
206/// Attribute node.
207#[repr(C)]
208pub struct _xmlAttr {
209    pub _private: *mut c_void,   // Application data
210    pub type_: c_int,            // XML_ATTRIBUTE_NODE
211    pub name: *const xmlChar,    // Local name
212    pub children: *mut _xmlNode, // First child (text value)
213    pub last: *mut _xmlNode,     // Last child
214    pub parent: *mut _xmlNode,   // Parent node
215    pub next: *mut _xmlAttr,     // Next sibling (attribute)
216    pub prev: *mut _xmlAttr,     // Previous sibling (attribute)
217    pub doc: *mut _xmlDoc,       // Containing document
218    pub ns: *mut _xmlNs,         // Namespace if any
219    pub atype: c_int,            // Attribute type
220    pub psvi: *mut c_void,       // Type/PSVI information
221    pub id: *mut c_void,         // ID struct (deprecated)
222}
223
224// ── xmlNode ─────────────────────────────────────────────────────────────
225//
226// Source: tree.h lines 645-688
227
228/// XML node — the core tree structure.
229#[repr(C)]
230pub struct _xmlNode {
231    pub _private: *mut c_void,   // Application data
232    pub type_: c_int,            // Type enum
233    pub name: *const xmlChar,    // Node name
234    pub children: *mut _xmlNode, // First child
235    pub last: *mut _xmlNode,     // Last child
236    pub parent: *mut _xmlNode,   // Parent node (NULL for documents)
237    pub next: *mut _xmlNode,     // Next sibling
238    pub prev: *mut _xmlNode,     // Previous sibling
239    pub doc: *mut _xmlDoc,       // Associated document
240    // End of common part
241    pub ns: *mut _xmlNs,           // Namespace of element
242    pub content: *mut xmlChar,     // Content (text/comment/PI)
243    pub properties: *mut _xmlAttr, // First attribute of element
244    pub nsDef: *mut _xmlNs,        // First namespace definition
245    pub psvi: *mut c_void,         // Type/PSVI information
246    pub line: c_ushort,            // Line number
247    pub extra: c_ushort,           // Extra data for XPath/XSLT
248}
249
250// ── xmlDoc ──────────────────────────────────────────────────────────────
251//
252// Source: tree.h lines 787-845
253
254/// XML Document.
255#[repr(C)]
256pub struct _xmlDoc {
257    pub _private: *mut c_void,   // Application data
258    pub type_: c_int,            // XML_DOCUMENT_NODE or XML_HTML_DOCUMENT_NODE
259    pub name: *mut c_char,       // NULL
260    pub children: *mut _xmlNode, // First child (root element)
261    pub last: *mut _xmlNode,     // Last child
262    pub parent: *mut _xmlNode,   // Parent node
263    pub next: *mut _xmlNode,     // Next sibling
264    pub prev: *mut _xmlNode,     // Previous sibling
265    pub doc: *mut _xmlDoc,       // Reference to itself
266    // End of common part
267    pub compression: c_int,      // Level of zlib compression
268    pub standalone: c_int,       // Standalone document status
269    pub intSubset: *mut _xmlDtd, // Internal subset
270    pub extSubset: *mut _xmlDtd, // External subset
271    pub oldNs: *mut _xmlNs,      // Old namespace (used during parsing)
272    pub version: *mut xmlChar,   // Version string from XML declaration
273    pub encoding: *mut xmlChar,  // Actual encoding
274    pub ids: *mut c_void,        // Hash table for ID attributes
275    pub refs: *mut c_void,       // Hash table for IDREFs (deprecated)
276    pub URL: *mut xmlChar,       // URI of the document
277    pub charset: c_int,          // Unused (encoding indicator)
278    pub dict: *mut c_void,       // Dictionary for names (opaque _xmlDict)
279    pub psvi: *mut c_void,       // Type/PSVI information
280    pub parseFlags: c_int,       // Parser options used
281    pub properties: c_int,       // Document properties flags
282}
283
284// ── xmlEntity ───────────────────────────────────────────────────────────
285//
286// Source: entities.h lines 42-74
287
288/// Entity declaration.
289#[repr(C)]
290pub struct _xmlEntity {
291    pub _private: *mut c_void,      // Application data
292    pub type_: c_int,               // XML_ENTITY_DECL (must be second!)
293    pub name: *const xmlChar,       // Entity name
294    pub children: *mut _xmlNode,    // First child link
295    pub last: *mut _xmlNode,        // Last child link
296    pub parent: *mut _xmlDtd,       // -> DTD
297    pub next: *mut _xmlNode,        // Next sibling link
298    pub prev: *mut _xmlNode,        // Previous sibling link
299    pub doc: *mut _xmlDoc,          // The containing document
300    pub orig: *mut xmlChar,         // Content without ref substitution
301    pub content: *mut xmlChar,      // Content or ndata if unparsed
302    pub length: c_int,              // The content length
303    pub etype: c_int,               // The entity type
304    pub ExternalID: *const xmlChar, // External identifier for PUBLIC
305    pub SystemID: *const xmlChar,   // URI for SYSTEM or PUBLIC Entity
306    pub nexte: *mut _xmlEntity,     // Unused
307    pub URI: *const xmlChar,        // The full URI as computed
308    pub owner: c_int,               // Unused
309    pub flags: c_int,               // Various flags
310    pub expandedSize: c_ulong,      // Expanded size
311}
312
313// ── xmlError ────────────────────────────────────────────────────────────
314//
315// Source: xmlerror.h
316
317/// Structured error information.
318#[repr(C)]
319#[derive(Debug)]
320pub struct _xmlError {
321    pub domain: c_int,        // Error domain
322    pub code: c_int,          // Error code
323    pub message: *mut c_char, // Human-readable error message
324    pub level: c_int,         // Error level
325    pub file: *mut c_char,    // Filename if available
326    pub line: c_int,          // Line number if available
327    pub str1: *mut c_char,    // Extra string information
328    pub str2: *mut c_char,    // Extra string information
329    pub str3: *mut c_char,    // Extra string information
330    pub int1: c_int,          // Extra number information
331    pub int2: c_int,          // Column number if available
332    pub ctxt: *mut c_void,    // Parser context if available
333    pub node: *mut c_void,    // Node if available
334}
335
336// ── xmlParserInput ──────────────────────────────────────────────────────
337//
338// Source: parser.h
339
340/// Parser input stream.
341#[repr(C)]
342pub struct _xmlParserInput {
343    pub buf: *mut _xmlParserInputBuffer, // Input buffer (deprecated)
344    pub filename: *const c_char,         // The filename or URI (deprecated)
345    pub directory: *const c_char,        // Unused (deprecated)
346    pub base: *const xmlChar,            // Base of the array to parse
347    pub cur: *const xmlChar,             // Current char being parsed (deprecated)
348    pub end: *const xmlChar,             // End of the array to parse
349    pub length: c_int,                   // Unused (deprecated)
350    pub line: c_int,                     // Current line (deprecated)
351    pub col: c_int,                      // Current column (deprecated)
352    pub consumed: c_ulong,               // How many xmlChars consumed (deprecated)
353    pub free: Option<unsafe extern "C" fn(*mut c_char)>, // Deallocation func (deprecated)
354    pub encoding: *const xmlChar,        // Unused (deprecated)
355    pub version: *const xmlChar,         // The version string for entity (deprecated)
356    pub flags: c_int,                    // Flags (deprecated)
357    pub id: c_int,                       // Unique identifier (deprecated)
358    pub parentConsumed: c_ulong,         // Unused (deprecated)
359    pub entity: *mut _xmlEntity,         // Entity if any (deprecated)
360}
361
362// ── xmlParserInputBuffer ────────────────────────────────────────────────
363//
364// Source: xmlIO.h
365
366/// Parser input buffer.
367#[repr(C)]
368pub struct _xmlParserInputBuffer {
369    pub context: *mut c_void,                         // (deprecated)
370    pub readcallback: Option<xmlInputReadCallback>,   // (deprecated)
371    pub closecallback: Option<xmlInputCloseCallback>, // (deprecated)
372    pub encoder: *mut c_void,                         // I18N converter (deprecated)
373    pub buffer: *mut c_void,                          // Local buffer (deprecated)
374    pub raw: *mut c_void,                             // Raw input buffer (deprecated)
375    pub compressed: c_int,                            // Compression flag (deprecated)
376    pub error: c_int,                                 // (deprecated)
377    pub rawconsumed: c_ulong,                         // (deprecated)
378}
379
380// ── xmlOutputBuffer ─────────────────────────────────────────────────────
381//
382// Source: xmlIO.h
383
384/// Output buffer.
385#[repr(C)]
386pub struct _xmlOutputBuffer {
387    pub context: *mut c_void,                          // (deprecated)
388    pub writecallback: Option<xmlOutputWriteCallback>, // (deprecated)
389    pub closecallback: Option<xmlOutputCloseCallback>, // (deprecated)
390    pub encoder: *mut c_void,                          // I18N converter
391    pub buffer: *mut c_void,                           // Local buffer
392    pub conv: *mut c_void,                             // Output conversion buffer
393    pub written: c_int,                                // Total bytes written
394    pub error: c_int,                                  // Error flag
395}
396
397// ── xmlCharEncodingHandler ───────────────────────────────────────────────
398//
399// Source: encoding.h
400
401/// Character encoding conversion handler.
402///
403/// # UPSTREAM-PARITY
404///
405/// Layout matches upstream `encoding.h` `struct _xmlCharEncodingHandler`
406/// (2.15.x): `name`, then two anonymous unions (`input`, `output`) each
407/// carrying either a modern `xmlCharEncConvFunc` or a legacy
408/// `xmlCharEncodingInputFunc`/`xmlCharEncodingOutputFunc`, then
409/// `inputCtxt`, `outputCtxt`, `ctxtDtor`, `flags`.
410/// sizeof == 56, _Alignof == 8 on x86-64.
411#[repr(C)]
412pub union EncodingInputUnion {
413    pub func: Option<xmlCharEncConvFunc>,
414    pub legacyFunc: Option<xmlCharEncodingInputFunc>,
415}
416
417/// Output-side counterpart of [`EncodingInputUnion`].
418#[repr(C)]
419pub union EncodingOutputUnion {
420    pub func: Option<xmlCharEncConvFunc>,
421    pub legacyFunc: Option<xmlCharEncodingOutputFunc>,
422}
423
424/// Character encoding conversion handler.
425#[repr(C)]
426pub struct _xmlCharEncodingHandler {
427    pub name: *mut c_char,                        // Encoding name
428    pub input: EncodingInputUnion,                // Input converter (union)
429    pub output: EncodingOutputUnion,              // Output converter (union)
430    pub inputCtxt: *mut c_void,                   // Iconv context for input
431    pub outputCtxt: *mut c_void,                  // Iconv context for output
432    pub ctxtDtor: Option<xmlCharEncConvCtxtDtor>, // Context destructor
433    pub flags: c_int,                             // xmlCharEncFlags
434}
435
436// ── xmlBuf ──────────────────────────────────────────────────────────────
437//
438// Source: tree.h
439
440/// Buffer structure (modern replacement for xmlBuffer).
441#[repr(C)]
442pub struct _xmlBuf {
443    pub content: *mut xmlChar, // The buffer content UTF8
444    pub use_: c_uint,          // The buffer size used
445    pub size: c_uint,          // The buffer size
446    pub alloc: c_int,          // The realloc method
447    pub error: c_int,          // Error flag
448    pub buffer: c_int,         // Is this a buffer from xmlBuffer?
449    pub io: c_int,             // In IO mode?
450}
451
452// ── xmlSAXHandler ───────────────────────────────────────────────────────
453//
454// Source: parser.h
455
456/// SAX event handler structure.
457#[repr(C)]
458pub struct _xmlSAXHandler {
459    pub internalSubset: Option<internalSubsetSAXFunc>,
460    pub isStandalone: Option<isStandaloneSAXFunc>,
461    pub hasInternalSubset: Option<hasInternalSubsetSAXFunc>,
462    pub hasExternalSubset: Option<hasExternalSubsetSAXFunc>,
463    pub resolveEntity: Option<resolveEntitySAXFunc>,
464    pub getEntity: Option<getEntitySAXFunc>,
465    pub entityDecl: Option<entityDeclSAXFunc>,
466    pub notationDecl: Option<notationDeclSAXFunc>,
467    pub attributeDecl: Option<attributeDeclSAXFunc>,
468    pub elementDecl: Option<elementDeclSAXFunc>,
469    pub unparsedEntityDecl: Option<unparsedEntityDeclSAXFunc>,
470    pub setDocumentLocator: Option<setDocumentLocatorSAXFunc>,
471    pub startDocument: Option<startDocumentSAXFunc>,
472    pub endDocument: Option<endDocumentSAXFunc>,
473    pub startElement: Option<startElementSAXFunc>,
474    pub endElement: Option<endElementSAXFunc>,
475    pub reference: Option<referenceSAXFunc>,
476    pub characters: Option<charactersSAXFunc>,
477    pub ignorableWhitespace: Option<ignorableWhitespaceSAXFunc>,
478    pub processingInstruction: Option<processingInstructionSAXFunc>,
479    pub comment: Option<commentSAXFunc>,
480    pub warning: Option<warningSAXFunc>,
481    pub error: Option<errorSAXFunc>,
482    pub fatalError: Option<fatalErrorSAXFunc>,
483    pub getParameterEntity: Option<getParameterEntitySAXFunc>,
484    pub cdataBlock: Option<cdataBlockSAXFunc>,
485    pub externalSubset: Option<externalSubsetSAXFunc>,
486    pub initialized: c_uint,
487    pub _private: *mut c_void,
488    pub startElementNs: Option<startElementNsSAX2Func>,
489    pub endElementNs: Option<endElementNsSAX2Func>,
490    pub serror: Option<xmlStructuredErrorFunc>,
491}
492
493/// SAX handler, version 1 (upstream `struct _xmlSAXHandlerV1`, parser.h).
494///
495/// # ABI
496///
497/// Exactly the first 28 fields of `_xmlSAXHandler`; this is the type of the
498/// deprecated exported consts `xmlDefaultSAXHandler` / `htmlDefaultSAXHandler`.
499#[repr(C)]
500pub struct _xmlSAXHandlerV1 {
501    pub internalSubset: Option<internalSubsetSAXFunc>,
502    pub isStandalone: Option<isStandaloneSAXFunc>,
503    pub hasInternalSubset: Option<hasInternalSubsetSAXFunc>,
504    pub hasExternalSubset: Option<hasExternalSubsetSAXFunc>,
505    pub resolveEntity: Option<resolveEntitySAXFunc>,
506    pub getEntity: Option<getEntitySAXFunc>,
507    pub entityDecl: Option<entityDeclSAXFunc>,
508    pub notationDecl: Option<notationDeclSAXFunc>,
509    pub attributeDecl: Option<attributeDeclSAXFunc>,
510    pub elementDecl: Option<elementDeclSAXFunc>,
511    pub unparsedEntityDecl: Option<unparsedEntityDeclSAXFunc>,
512    pub setDocumentLocator: Option<setDocumentLocatorSAXFunc>,
513    pub startDocument: Option<startDocumentSAXFunc>,
514    pub endDocument: Option<endDocumentSAXFunc>,
515    pub startElement: Option<startElementSAXFunc>,
516    pub endElement: Option<endElementSAXFunc>,
517    pub reference: Option<referenceSAXFunc>,
518    pub characters: Option<charactersSAXFunc>,
519    pub ignorableWhitespace: Option<ignorableWhitespaceSAXFunc>,
520    pub processingInstruction: Option<processingInstructionSAXFunc>,
521    pub comment: Option<commentSAXFunc>,
522    pub warning: Option<warningSAXFunc>,
523    pub error: Option<errorSAXFunc>,
524    pub fatalError: Option<fatalErrorSAXFunc>,
525    pub getParameterEntity: Option<getParameterEntitySAXFunc>,
526    pub cdataBlock: Option<cdataBlockSAXFunc>,
527    pub externalSubset: Option<externalSubsetSAXFunc>,
528    pub initialized: c_uint,
529}
530
531/// Character-range table entry (upstream `xmlChSRange`, chvalid.h).
532#[repr(C)]
533pub struct xmlChSRange {
534    pub low: c_ushort,
535    pub high: c_ushort,
536}
537
538/// Long character-range table entry (upstream `xmlChLRange`, chvalid.h).
539#[repr(C)]
540pub struct xmlChLRange {
541    pub low: c_uint,
542    pub high: c_uint,
543}
544
545/// Character-class range group (upstream `xmlChRangeGroup`, chvalid.h) — the
546/// type of the exported char-class tables `xmlIsBaseCharGroup` &c.
547#[repr(C)]
548pub struct xmlChRangeGroup {
549    pub nbShortRange: c_int,
550    pub nbLongRange: c_int,
551    pub shortRange: *const xmlChSRange,
552    pub longRange: *const xmlChLRange,
553}
554
555// SAFETY: the group's raw pointers reference immutable `#[no_mangle]` const
556// arrays (generated from upstream data); they are never mutated, so the type
557// is safe to share across threads — required for the exported `static` tables
558// (upstream declares them `const`).
559unsafe impl Sync for xmlChRangeGroup {}
560
561// ── xmlParserCtxt ───────────────────────────────────────────────────────
562//
563// Source: parser.h
564
565/// Parser context — the primary parsing state structure.
566#[repr(C)]
567pub struct _xmlParserCtxt {
568    pub sax: *mut _xmlSAXHandler, // SAX handler (deprecated)
569    pub userData: *mut c_void,    // User data (deprecated)
570    pub myDoc: *mut _xmlDoc,      // Document being built (deprecated)
571    pub wellFormed: c_int,        // Is document well formed? (deprecated)
572    pub replaceEntities: c_int,   // Replace entities? (deprecated)
573    pub version: *mut xmlChar,    // XML version string (deprecated)
574    pub encoding: *mut xmlChar,   // Declared encoding (deprecated)
575    pub standalone: c_int,        // Standalone document (deprecated)
576    pub html: c_int,              // HTML document (deprecated)
577    // Input stream stack
578    pub input: *mut _xmlParserInput,         // Current input stream
579    pub inputNr: c_int,                      // Number of current input streams
580    pub inputMax: c_int,                     // Max number of input streams (deprecated)
581    pub inputTab: *mut *mut _xmlParserInput, // Stack of inputs
582    // Node analysis stack
583    pub node: *mut _xmlNode,         // Current element (deprecated)
584    pub nodeNr: c_int,               // Depth of parsing stack (deprecated)
585    pub nodeMax: c_int,              // Max depth (deprecated)
586    pub nodeTab: *mut *mut _xmlNode, // Array of nodes (deprecated)
587    // Node info
588    pub record_info: c_int,             // Whether node info should be kept
589    pub node_seq: xmlParserNodeInfoSeq, // Info about each node parsed (deprecated)
590    // Error
591    pub errNo: c_int, // Error code (deprecated)
592    // Reference and external subset
593    pub hasExternalSubset: c_int, // (deprecated)
594    pub hasPErefs: c_int,         // (deprecated)
595    pub external: c_int,          // (deprecated)
596    pub valid: c_int,             // Is document valid? (deprecated)
597    pub validate: c_int,          // Validate flag (deprecated)
598    pub vctxt: _xmlValidCtxt,     // Validity context
599    // Push parser state
600    pub instate: c_int,         // (deprecated)
601    pub token: c_int,           // (deprecated)
602    pub directory: *mut c_char, // Document directory (deprecated)
603    // Node name stack
604    pub name: *const xmlChar,         // Current parsed Node (deprecated)
605    pub nameNr: c_int,                // (deprecated)
606    pub nameMax: c_int,               // (deprecated)
607    pub nameTab: *mut *const xmlChar, // (deprecated)
608    // Misc
609    pub nbChars: c_long,            // (deprecated)
610    pub checkIndex: c_long,         // (deprecated)
611    pub keepBlanks: c_int,          // (deprecated)
612    pub disableSAX: c_int,          // (deprecated)
613    pub inSubset: c_int,            // DTD parsing state (deprecated)
614    pub intSubName: *const xmlChar, // Internal subset name (deprecated)
615    pub extSubURI: *mut xmlChar,    // External subset URI (deprecated)
616    pub extSubSystem: *mut xmlChar, // External subset public ID (deprecated)
617    // xml:space values
618    pub space: *mut c_int,    // (deprecated)
619    pub spaceNr: c_int,       // (deprecated)
620    pub spaceMax: c_int,      // (deprecated)
621    pub spaceTab: *mut c_int, // (deprecated)
622    // Entity loop prevention
623    pub depth: c_int,                 // (deprecated)
624    pub entity: *mut _xmlParserInput, // (deprecated)
625    pub charset: c_int,               // (deprecated)
626    pub nodelen: c_int,               // (deprecated)
627    pub nodemem: c_int,               // (deprecated)
628    pub pedantic: c_int,              // (deprecated)
629    pub _private: *mut c_void,        // User data (deprecated)
630    pub loadsubset: c_int,            // Load external subset (deprecated)
631    pub linenumbers: c_int,           // (deprecated)
632    pub catalogs: *mut c_void,        // (deprecated)
633    pub recovery: c_int,              // Recovery mode (deprecated)
634    pub progressive: c_int,           // (deprecated)
635    pub dict: *mut c_void,            // Dictionary (deprecated)
636    pub atts: *mut *const xmlChar,    // Attributes array (deprecated)
637    pub maxatts: c_int,               // (deprecated)
638    pub docdict: c_int,               // (deprecated)
639    // Pre-interned strings
640    pub str_xml: *const xmlChar,    // (deprecated)
641    pub str_xmlns: *const xmlChar,  // (deprecated)
642    pub str_xml_ns: *const xmlChar, // (deprecated)
643    // New SAX mode
644    pub sax2: c_int,                // (deprecated)
645    pub nsNr: c_int,                // (deprecated)
646    pub nsMax: c_int,               // (deprecated)
647    pub nsTab: *mut *const xmlChar, // (deprecated)
648    pub attallocs: *mut c_uint,     // (deprecated)
649    pub pushTab: *mut c_void,       // xmlStartTag (deprecated)
650    pub attsDefault: *mut c_void,   // (deprecated)
651    pub attsSpecial: *mut c_void,   // (deprecated)
652    pub nsWellFormed: c_int,        // (deprecated)
653    pub options: c_int,             // Extra options (deprecated)
654    pub dictNames: c_int,           // (deprecated)
655    // Streaming
656    pub freeElemsNr: c_int,       // (deprecated)
657    pub freeElems: *mut _xmlNode, // (deprecated)
658    pub freeAttrsNr: c_int,       // (deprecated)
659    pub freeAttrs: *mut _xmlAttr, // (deprecated)
660    pub lastError: _xmlError,     // Last error info (deprecated)
661    pub parseMode: c_int,         // (deprecated)
662    pub nbentities: c_ulong,      // (deprecated)
663    pub sizeentities: c_ulong,    // (deprecated)
664    // HTML non-recursive parser
665    pub nodeInfo: *mut c_void,    // (deprecated)
666    pub nodeInfoNr: c_int,        // (deprecated)
667    pub nodeInfoMax: c_int,       // (deprecated)
668    pub nodeInfoTab: *mut c_void, // (deprecated)
669    pub input_id: c_int,          // (deprecated)
670    pub sizeentcopy: c_ulong,     // (deprecated)
671    pub endCheckState: c_int,     // (deprecated)
672    pub nbErrors: c_ushort,       // (deprecated)
673    pub nbWarnings: c_ushort,     // (deprecated)
674    pub maxAmpl: c_uint,          // (deprecated)
675    // Namespace database
676    pub nsdb: *mut c_void,     // (deprecated)
677    pub attrHashMax: c_uint,   // (deprecated)
678    pub attrHash: *mut c_void, // (deprecated)
679    // Error handler
680    pub errorHandler: Option<xmlStructuredErrorFunc>, // (deprecated)
681    pub errorCtxt: *mut c_void,                       // (deprecated)
682    // Resource loader
683    pub resourceLoader: Option<xmlResourceLoader>, // (deprecated)
684    pub resourceCtxt: *mut c_void,                 // (deprecated)
685    // Encoding conversion
686    pub convImpl: Option<xmlCharEncConvImpl>, // (deprecated)
687    pub convCtxt: *mut c_void,                // (deprecated)
688}
689
690// ── xmlValidCtxt ────────────────────────────────────────────────────────
691//
692// Source: valid.h
693
694/// Validation context.
695#[repr(C)]
696pub struct _xmlValidCtxt {
697    pub userData: *mut c_void,                   // User specific data
698    pub error: Option<xmlValidityErrorFunc>,     // Error callback
699    pub warning: Option<xmlValidityWarningFunc>, // Warning callback
700    pub node: *mut _xmlNode,                     // Current parsed Node
701    pub nodeNr: c_int,                           // Depth of the parsing stack
702    pub nodeMax: c_int,                          // Max depth
703    pub nodeTab: *mut *mut _xmlNode,             // Array of nodes
704    pub flags: c_uint,                           // Internal flags
705    pub doc: *mut _xmlDoc,                       // The document
706    pub valid: c_int,                            // Temporary validity check result
707    pub vstate: *mut c_void,                     // Current validation state
708    pub vstateNr: c_int,                         // Depth of validation stack
709    pub vstateMax: c_int,                        // Max depth
710    pub vstateTab: *mut c_void,                  // Array of validation states
711    pub am: *mut c_void,                         // Automata
712    pub state: *mut c_void,                      // Automata state
713}
714
715// ── xmlID / xmlRef (valid.h ID/IDREF table entries) ────────────────────
716//
717// Source: tree.h `struct _xmlID` / `struct _xmlRef` (opaque upstream).
718
719/// An XML ID instance (ID table entry).
720#[repr(C)]
721pub struct _xmlID {
722    pub next: *mut _xmlID,    // next ID
723    pub value: *mut xmlChar,  // The ID name
724    pub attr: *mut _xmlAttr,  // The attribute holding it
725    pub name: *const xmlChar, // The attribute if attr is not available
726    pub lineno: c_int,        // The line number if attr is not available
727    pub doc: *mut _xmlDoc,    // The document holding the ID
728}
729
730/// An XML IDREF instance (ref table entry).
731#[repr(C)]
732pub struct _xmlRef {
733    pub next: *mut _xmlRef,    // next Ref
734    pub value: *const xmlChar, // The Ref name
735    pub attr: *mut _xmlAttr,   // The attribute holding it
736    pub name: *const xmlChar,  // The attribute if attr is not available
737    pub lineno: c_int,         // The line number if attr is not available
738}
739
740// ── xmlParserNodeInfo ───────────────────────────────────────────────────
741
742/// Node info for parser tracking.
743#[repr(C)]
744pub struct _xmlParserNodeInfo {
745    pub node: *const _xmlNode,
746    pub begin_pos: c_ulong,
747    pub begin_line: c_ulong,
748    pub end_pos: c_ulong,
749    pub end_line: c_ulong,
750}
751
752/// Node info sequence.
753#[repr(C)]
754pub struct _xmlParserNodeInfoSeq {
755    pub block: *mut _xmlParserNodeInfo,
756    pub index: *mut c_int,
757    pub block_max: c_int,
758    pub size: c_int,
759}
760
761/// Typedef alias for `_xmlParserNodeInfoSeq`.
762pub type xmlParserNodeInfoSeq = _xmlParserNodeInfoSeq;
763
764// ── xmlXPathContext ─────────────────────────────────────────────────────
765//
766// Source: xpath.h
767
768/// XPath evaluation context.
769#[repr(C)]
770pub struct _xmlXPathContext {
771    pub doc: *mut _xmlDoc,                                 // The current document
772    pub node: *mut _xmlNode,                               // The current node
773    pub nb_variables_unused: c_int,                        // (unused)
774    pub max_variables_unused: c_int,                       // (unused)
775    pub varHash: *mut c_void,                              // Hash table of defined variables
776    pub nb_types: c_int,                                   // Number of defined types
777    pub max_types: c_int,                                  // Max number of types
778    pub types: *mut c_void,                                // Array of defined types (xmlXPathType)
779    pub nb_funcs_unused: c_int,                            // (unused)
780    pub max_funcs_unused: c_int,                           // (unused)
781    pub funcHash: *mut c_void,                             // Hash table of defined funcs
782    pub nb_axis: c_int,                                    // Number of defined axis
783    pub max_axis: c_int,                                   // Max number of axis
784    pub axis: *mut c_void,                                 // Array of defined axis (xmlXPathAxis)
785    pub namespaces: *mut *mut _xmlNs,                      // Array of namespaces
786    pub nsNr: c_int,                                       // Number of namespaces in scope
787    pub user: *mut c_void,                                 // Function to free
788    pub contextSize: c_int,                                // Context size
789    pub proximityPosition: c_int,                          // Proximity position
790    pub xptr: c_int,                                       // XPointer context?
791    pub here: *mut _xmlNode,                               // For here()
792    pub origin: *mut _xmlNode,                             // For origin()
793    pub nsHash: *mut c_void,                               // Namespaces hash table
794    pub varLookupFunc: Option<xmlXPathVariableLookupFunc>, // Variable lookup func
795    pub varLookupData: *mut c_void,                        // Variable lookup data
796    pub extra: *mut c_void,                                // Needed for XSLT
797    pub function: *const xmlChar,                          // Function name when calling a function
798    pub functionURI: *const xmlChar,                       // Function namespace URI
799    pub funcLookupFunc: Option<xmlXPathFuncLookupFunc>,    // Function lookup func
800    pub funcLookupData: *mut c_void,                       // Function lookup data
801    pub tmpNsList: *mut *mut _xmlNs,                       // Array of temp namespaces
802    pub tmpNsNr: c_int,                                    // Number of temp namespaces
803    pub userData: *mut c_void,                             // User specific data
804    pub error: Option<xmlStructuredErrorFunc>,             // Error callback
805    pub lastError: _xmlError,                              // Last error
806    pub debugNode: *mut _xmlNode,                          // Source node (XSLT)
807    pub dict: *mut c_void,                                 // Dictionary
808    pub flags: c_int,                                      // Compilation flags
809    pub cache: *mut c_void,                                // Cache for XPath objects
810    pub opLimit: c_ulong,                                  // Resource limits
811    pub opCount: c_ulong,
812    pub depth: c_int,
813}
814
815// ── xmlXPathObject ──────────────────────────────────────────────────────
816//
817// Source: xpath.h
818
819/// XPath evaluated object.
820#[repr(C)]
821pub struct _xmlXPathObject {
822    pub type_: c_int,            // Object type
823    pub nodesetval: *mut c_void, // Node set (xmlNodeSet)
824    pub boolval: c_int,          // Boolean value
825    pub floatval: f64,           // Number value
826    pub stringval: *mut xmlChar, // String value
827    pub user: *mut c_void,       // User pointer
828    pub index: c_int,            // Index
829    pub user2: *mut c_void,      // User pointer 2
830    pub index2: c_int,           // Index 2
831}
832
833// ── Node set (contained within XPath objects) ───────────────────────────
834
835/// XPath node set.
836#[repr(C)]
837pub struct _xmlNodeSet {
838    pub nodeNr: c_int,               // Number of nodes
839    pub nodeMax: c_int,              // Max number of nodes
840    pub nodeTab: *mut *mut _xmlNode, // Array of nodes
841}
842
843// ── XSLT types ──────────────────────────────────────────────────────────
844//
845// ═══════════════════════════════════════════════════════════════════════════════
846// XSLT Types (Phase 8)
847// ═══════════════════════════════════════════════════════════════════════════════
848// Source: xslt.h, xsltInternals.h (from libxslt)
849
850/// XSLT stylesheet — the compiled representation of an XSLT stylesheet.
851///
852/// # UPSTREAM-PARITY
853///
854/// Layout matches upstream `_xsltStylesheet` from xsltInternals.h (libxslt
855/// 1.1.45); field order and types match the C struct exactly for ABI
856/// compatibility. Verified by the RUST-MIRROR-ABI court
857/// (tools/abi/rust_mirror_court.py). Courts: XSLT-STYLESHEET-*
858#[repr(C)]
859pub struct _xsltStylesheet {
860    pub parent: *mut _xsltStylesheet,   // parent stylesheet (imports)
861    pub next: *mut _xsltStylesheet,     // next stylesheet in imports
862    pub imports: *mut _xsltStylesheet,  // list of imported stylesheets
863    pub docList: *mut _xsltDocument,    // documents of this stylesheet
864    pub doc: *mut _xmlDoc,              // the stylesheet document
865    pub stripSpaces: *mut c_void,       // xmlHashTablePtr: elements to strip
866    pub stripAll: c_int,                // strip all whitespace
867    pub cdataSection: *mut c_void,      // xmlHashTablePtr
868    pub variables: *mut _xsltStackElem, // global variables/params (list)
869    pub templates: *mut _xsltTemplate,  // ordered templates (highest first)
870    pub templatesHash: *mut c_void,     // xmlHashTablePtr: template lookup
871    pub rootMatch: *mut c_void,         // xsltCompMatchPtr
872    pub keyMatch: *mut c_void,
873    pub elemMatch: *mut c_void,
874    pub attrMatch: *mut c_void,
875    pub parentMatch: *mut c_void,
876    pub textMatch: *mut c_void,
877    pub piMatch: *mut c_void,
878    pub commentMatch: *mut c_void,
879    pub nsAliases: *mut c_void,     // xmlHashTablePtr
880    pub attributeSets: *mut c_void, // xmlHashTablePtr
881    pub nsHash: *mut c_void,        // xmlHashTablePtr
882    pub nsDefs: *mut c_void,
883    pub keys: *mut c_void,    // void *: key definitions
884    pub method: *mut xmlChar, // output method
885    pub methodURI: *mut xmlChar,
886    pub version: *mut xmlChar,
887    pub encoding: *mut xmlChar,
888    pub omitXmlDeclaration: c_int,
889    pub decimalFormat: *mut _xsltDecimalFormat, // xsltDecimalFormatPtr
890    pub standalone: c_int,
891    pub doctypePublic: *mut xmlChar,
892    pub doctypeSystem: *mut xmlChar,
893    pub indent: c_int,
894    pub mediaType: *mut xmlChar,
895    pub preComps: *mut c_void, // xsltElemPreCompPtr
896    pub warnings: c_int,
897    pub errors: c_int,
898    pub exclPrefix: *mut xmlChar,
899    pub exclPrefixTab: *mut *mut xmlChar,
900    pub exclPrefixNr: c_int,
901    pub exclPrefixMax: c_int,
902    pub _private: *mut c_void,
903    pub extInfos: *mut c_void, // xmlHashTablePtr
904    pub extrasNr: c_int,
905    pub includes: *mut _xsltDocument, // xsltDocumentPtr
906    pub dict: *mut c_void,            // xmlDictPtr
907    pub attVTs: *mut c_void,
908    pub defaultAlias: *const xmlChar,
909    pub nopreproc: c_int,
910    pub internalized: c_int,
911    pub literal_result: c_int,
912    pub principal: *mut _xsltStylesheet, // xsltStylesheetPtr
913    // UPSTREAM-PARITY: `compCtxt` and `principalData` sit inside
914    // `#ifdef XSLT_REFACTORED` in xsltInternals.h and are absent from the
915    // oracle layout (system libxslt 1.1.45 ships with XSLT_REFACTORED
916    // disabled; verified against the installed xsltInternals.h). The mirror
917    // intentionally omits them so field offsets match the oracle DSO.
918    pub forwards_compatible: c_int,
919    pub namedTemplates: *mut c_void,      // xmlHashTablePtr
920    pub xpathCtxt: *mut _xmlXPathContext, // xmlXPathContextPtr
921    pub opLimit: c_ulong,
922    pub opCount: c_ulong,
923}
924
925/// XSLT transform context — runtime state during a transformation.
926///
927/// # ABI
928///
929/// Layout mirrors upstream `struct _xsltTransformContext` (libxslt 1.1.42
930/// xsltInternals.h). The runtime keeps the XPath value stack on
931/// `xpathCtxt->value*` (upstream behaviour); there is no separate return
932/// stack in the context.
933#[repr(C)]
934pub struct _xsltTransformContext {
935    pub style: *mut _xsltStylesheet, // stylesheet being applied
936    pub type_: c_int,                // xsltOutputType
937    pub templ: *mut _xsltTemplate,   // current template
938    pub templNr: c_int,
939    pub templMax: c_int,
940    pub templTab: *mut *mut _xsltTemplate, // xsltTemplatePtr *
941    pub vars: *mut _xsltStackElem,         // current variable stack head
942    pub varsNr: c_int,
943    pub varsMax: c_int,
944    pub varsTab: *mut *mut _xsltStackElem, // xsltStackElemPtr *
945    pub varsBase: c_int,
946    pub extFunctions: *mut c_void, // xmlHashTablePtr
947    pub extElements: *mut c_void,  // xmlHashTablePtr
948    pub extInfos: *mut c_void,     // xmlHashTablePtr
949    pub mode: *const xmlChar,
950    pub modeURI: *const xmlChar,
951    pub docList: *mut _xsltDocument,      // xsltDocumentPtr
952    pub document: *mut _xsltDocument,     // xsltDocumentPtr (current doc)
953    pub node: *mut _xmlNode,              // current source node
954    pub nodeList: *mut _xmlNodeSet,       // xmlNodeSetPtr
955    pub output: *mut _xmlDoc,             // current result document
956    pub insert: *mut _xmlNode,            // insertion point
957    pub xpathCtxt: *mut _xmlXPathContext, // xmlXPathContextPtr
958    pub state: c_int,                     // xsltTransformState
959    pub globalVars: *mut c_void,          // xmlHashTablePtr
960    pub inst: *mut _xmlNode,              // current instruction node
961    pub xinclude: c_int,
962    pub outputFile: *const c_char, // const char *
963    pub profile: c_int,
964    pub prof: c_long,
965    pub profNr: c_int,
966    pub profMax: c_int,
967    pub profTab: *mut c_long, // long *
968    pub _private: *mut c_void,
969    pub extrasNr: c_int,
970    pub extrasMax: c_int,
971    pub extras: *mut c_void,                // xsltRuntimeExtraPtr
972    pub styleList: *mut _xsltDocument,      // xsltDocumentPtr
973    pub sec: *mut c_void,                   // xsltSecurityPrefsPtr
974    pub error: Option<xmlGenericErrorFunc>, // xmlGenericErrorFunc
975    pub errctx: *mut c_void,
976    pub sortfunc: *mut c_void,    // xsltSortFunc
977    pub tmpRVT: *mut _xmlDoc,     // xmlDocPtr
978    pub persistRVT: *mut _xmlDoc, // xmlDocPtr
979    pub ctxtflags: c_int,
980    pub lasttext: *const xmlChar,
981    pub lasttsize: c_int,
982    pub lasttuse: c_int,
983    pub debugStatus: c_int,
984    pub traceCode: *mut c_ulong, // unsigned long *
985    pub parserOptions: c_int,
986    pub dict: *mut c_void,    // xmlDictPtr
987    pub tmpDoc: *mut _xmlDoc, // xmlDocPtr
988    pub internalized: c_int,
989    pub nbKeys: c_int,
990    pub hasTemplKeyPatterns: c_int,
991    pub currentTemplateRule: *mut _xsltTemplate, // xsltTemplatePtr
992    pub initialContextNode: *mut _xmlNode,       // xmlNodePtr
993    pub initialContextDoc: *mut _xmlDoc,         // xmlDocPtr
994    pub cache: *mut c_void,                      // xsltTransformCachePtr
995    pub contextVariable: *mut c_void,
996    pub localRVT: *mut _xmlDoc,     // xmlDocPtr
997    pub localRVTBase: *mut _xmlDoc, // xmlDocPtr
998    pub keyInitLevel: c_int,
999    pub depth: c_int,
1000    pub maxTemplateDepth: c_int,
1001    pub maxTemplateVars: c_int,
1002    pub opLimit: c_ulong,
1003    pub opCount: c_ulong,
1004    pub sourceDocDirty: c_int,
1005    pub currentId: c_ulong,
1006    pub newLocale: *mut c_void,  // xsltNewLocaleFunc
1007    pub freeLocale: *mut c_void, // xsltFreeLocaleFunc
1008    pub genSortKey: *mut c_void, // xsltGenSortKeyFunc
1009}
1010
1011/// XSLT compiled template.
1012///
1013/// # ABI
1014///
1015/// Layout mirrors upstream `struct _xsltTemplate` (xsltInternals.h).
1016#[repr(C)]
1017pub struct _xsltTemplate {
1018    pub next: *mut _xsltTemplate,    // next template in list
1019    pub style: *mut _xsltStylesheet, // owning stylesheet
1020    pub r#match: *mut xmlChar,       // match pattern (compiled string)
1021    pub priority: f32,               // float
1022    pub name: *const xmlChar,        // template name (named templates)
1023    pub nameURI: *const xmlChar,
1024    pub mode: *const xmlChar, // template mode
1025    pub modeURI: *const xmlChar,
1026    pub content: *mut _xmlNode, // template content
1027    pub elem: *mut _xmlNode,    // the xsl:template node
1028    pub inheritedNsNr: c_int,
1029    pub inheritedNs: *mut *mut _xmlNs, // xmlNsPtr *
1030    pub nbCalls: c_int,
1031    pub time: c_ulong,
1032    pub params: *mut c_void,
1033    pub templNr: c_int,
1034    pub templMax: c_int,
1035    pub templCalledTab: *mut *mut _xsltTemplate, // xsltTemplatePtr *
1036    pub templCountTab: *mut c_int,               // int *
1037    pub position: c_int,
1038}
1039
1040/// XSLT document wrapper.
1041///
1042/// # ABI
1043///
1044/// Layout mirrors upstream `struct _xsltDocument` (xsltInternals.h).
1045#[repr(C)]
1046pub struct _xsltDocument {
1047    pub next: *mut _xsltDocument,     // next document in list
1048    pub main: c_int,                  // is this the main stylesheet doc?
1049    pub doc: *mut _xmlDoc,            // the wrapped document
1050    pub keys: *mut c_void,            // void *
1051    pub includes: *mut _xsltDocument, // list of included documents
1052    pub preproc: c_int,               // pre-proc flag
1053    pub nbKeysComputed: c_int,
1054}
1055
1056/// XSLT key definition.
1057///
1058/// # ABI
1059///
1060/// Layout mirrors upstream `struct _xsltKeyDef` (xsltInternals.h).
1061#[repr(C)]
1062pub struct _xsltKeyDef {
1063    pub next: *mut _xsltKeyDef,   // next key definition
1064    pub inst: *mut _xmlNode,      // the xsl:key instruction node
1065    pub name: *mut xmlChar,       // key name
1066    pub nameURI: *mut xmlChar,    // key namespace URI
1067    pub r#match: *mut xmlChar,    // match pattern
1068    pub r#use: *mut xmlChar,      // use expression
1069    pub comp: *mut c_void,        // xmlXPathCompExprPtr
1070    pub usecomp: *mut c_void,     // xmlXPathCompExprPtr
1071    pub nsList: *mut *mut _xmlNs, // xmlNsPtr *
1072    pub nsNr: c_int,
1073}
1074
1075/// XSLT key table entry.
1076///
1077/// # ABI
1078///
1079/// Layout mirrors upstream `struct _xsltKeyTable` (xsltInternals.h).
1080#[repr(C)]
1081pub struct _xsltKeyTable {
1082    pub next: *mut _xsltKeyTable, // next key table
1083    pub name: *mut xmlChar,       // key name
1084    pub nameURI: *mut xmlChar,    // key namespace URI
1085    pub keys: *mut c_void,        // xmlHashTablePtr
1086}
1087
1088/// XSLT stack element (variable/parameter binding).
1089///
1090/// # ABI
1091///
1092/// Layout mirrors upstream `struct _xsltStackElem` (xsltInternals.h).
1093#[repr(C)]
1094pub struct _xsltStackElem {
1095    pub next: *mut _xsltStackElem,           // next stack element
1096    pub comp: *mut c_void,                   // xsltStylePreCompPtr
1097    pub computed: c_int,                     // was the value computed?
1098    pub name: *const xmlChar,                // variable/parameter name
1099    pub nameURI: *const xmlChar,             // namespace URI
1100    pub select: *const xmlChar,              // select expression
1101    pub tree: *mut _xmlNode,                 // content tree (inline content)
1102    pub value: *mut _xmlXPathObject,         // evaluated value (xmlXPathObjectPtr)
1103    pub fragment: *mut _xmlDoc,              // xmlDocPtr (RVT)
1104    pub level: c_int,                        // scope level
1105    pub context: *mut _xsltTransformContext, // xsltTransformContextPtr
1106    pub flags: c_int,
1107}
1108
1109/// XSLT decimal format definition.
1110///
1111/// # ABI
1112///
1113/// Layout mirrors upstream `struct _xsltDecimalFormat` (xsltInternals.h).
1114#[repr(C)]
1115pub struct _xsltDecimalFormat {
1116    pub next: *mut _xsltDecimalFormat, // next decimal format
1117    pub name: *mut xmlChar,            // format name (NULL = default)
1118    pub digit: *mut xmlChar,
1119    pub patternSeparator: *mut xmlChar,
1120    pub minusSign: *mut xmlChar,
1121    pub infinity: *mut xmlChar,
1122    pub noNumber: *mut xmlChar,
1123    pub decimalPoint: *mut xmlChar,
1124    pub grouping: *mut xmlChar,
1125    pub percent: *mut xmlChar,
1126    pub permille: *mut xmlChar,
1127    pub zeroDigit: *mut xmlChar,
1128    pub nsUri: *const xmlChar,
1129}
1130
1131/// XSLT namespace alias.
1132///
1133/// # UPSTREAM-PARITY
1134///
1135/// Layout matches upstream `_xsltNsAlias` from xsltInternals.h.
1136#[repr(C)]
1137pub struct _xsltNsAlias {
1138    /// Next namespace alias.
1139    pub next: *mut _xsltNsAlias,
1140
1141    /// Result namespace URI.
1142    pub resultNs: *const xmlChar,
1143
1144    /// Stylesheet namespace URI.
1145    pub styleNs: *const xmlChar,
1146}
1147
1148/// XSLT attribute set.
1149///
1150/// # UPSTREAM-PARITY
1151///
1152/// Layout matches upstream `_xsltAttrSet` from xsltInternals.h.
1153#[repr(C)]
1154pub struct _xsltAttrSet {
1155    /// Next attribute set.
1156    pub next: *mut _xsltAttrSet,
1157
1158    /// Attribute set name.
1159    pub name: *const xmlChar,
1160
1161    /// Attribute set namespace URI.
1162    pub ns: *const xmlChar,
1163
1164    /// The xsl:attribute-set instruction node.
1165    pub inst: *mut _xmlNode,
1166
1167    /// Owning stylesheet.
1168    pub style: *mut _xsltStylesheet,
1169
1170    /// Import depth.
1171    pub depth: c_int,
1172}
1173
1174/// XSLT sort element.
1175///
1176/// # UPSTREAM-PARITY
1177///
1178/// Layout matches upstream `_xsltSort` from xsltInternals.h.
1179#[repr(C)]
1180pub struct _xsltSort {
1181    /// Next sort element.
1182    pub next: *mut _xsltSort,
1183
1184    /// The xsl:sort instruction node.
1185    pub inst: *mut _xmlNode,
1186
1187    /// The sort key select expression.
1188    pub select: *const xmlChar,
1189
1190    /// Language for sorting.
1191    pub lang: *const xmlChar,
1192
1193    /// Data type ("text" or "number").
1194    pub dataType: *const xmlChar,
1195
1196    /// Sort order ("ascending" or "descending").
1197    pub order: *const xmlChar,
1198
1199    /// Case order ("upper-first" or "lower-first").
1200    pub caseOrder: *const xmlChar,
1201
1202    /// Whether this sort is a text sort.
1203    pub isText: c_int,
1204
1205    /// Whether the select expression was a constant.
1206    pub hasConst: c_int,
1207
1208    /// Locale information.
1209    pub locale: *mut c_void,
1210
1211    /// Owning stylesheet.
1212    pub style: *mut _xsltStylesheet,
1213
1214    /// Import depth.
1215    pub depth: c_int,
1216}
1217
1218// ── Type aliases for pointer types ──────────────────────────────────────
1219
1220pub type xmlNodePtr = *mut _xmlNode;
1221pub type xmlDocPtr = *mut _xmlDoc;
1222pub type xmlNsPtr = *mut _xmlNs;
1223pub type xmlAttrPtr = *mut _xmlAttr;
1224pub type xmlDtdPtr = *mut _xmlDtd;
1225pub type xmlEntityPtr = *mut _xmlEntity;
1226pub type xmlErrorPtr = *mut _xmlError;
1227pub type xmlParserCtxtPtr = *mut _xmlParserCtxt;
1228pub type xmlParserInputPtr = *mut _xmlParserInput;
1229pub type xmlParserInputBufferPtr = *mut _xmlParserInputBuffer;
1230pub type xmlOutputBufferPtr = *mut _xmlOutputBuffer;
1231pub type xmlSAXHandlerPtr = *mut _xmlSAXHandler;
1232pub type xmlValidCtxtPtr = *mut _xmlValidCtxt;
1233pub type xmlBufferPtr = *mut _xmlBuffer;
1234pub type xmlElementPtr = *mut _xmlElement;
1235pub type xmlElementContentPtr = *mut _xmlElementContent;
1236pub type xmlNotationPtr = *mut _xmlNotation;
1237pub type xmlEnumerationPtr = *mut _xmlEnumeration;
1238pub type xmlAttributeDeclPtr = *mut _xmlAttribute;
1239pub type xmlXPathContextPtr = *mut _xmlXPathContext;
1240pub type xmlXPathObjectPtr = *mut _xmlXPathObject;
1241pub type xmlNodeSetPtr = *mut _xmlNodeSet;
1242pub type xmlCharEncodingHandlerPtr = *mut _xmlCharEncodingHandler;
1243pub type xmlBufPtr = *mut _xmlBuf;
1244pub type xsltStylesheetPtr = *mut _xsltStylesheet;
1245pub type xsltTransformContextPtr = *mut _xsltTransformContext;
1246pub type xsltTemplatePtr = *mut _xsltTemplate;
1247pub type xsltKeyDefPtr = *mut _xsltKeyDef;
1248pub type xsltKeyTablePtr = *mut _xsltKeyTable;
1249pub type xsltStackElemPtr = *mut _xsltStackElem;
1250pub type xsltDecimalFormatPtr = *mut _xsltDecimalFormat;
1251pub type xsltNsAliasPtr = *mut _xsltNsAlias;
1252pub type xsltAttrSetPtr = *mut _xsltAttrSet;
1253pub type xsltDocumentPtr = *mut _xsltDocument;
1254pub type xsltSortPtr = *mut _xsltSort;