Expand description
W3C XInclude 1.0 — arena-DOM port of crate::xinclude.
Mirrors the legacy crate::xinclude::process_xincludes behaviour, but
operates on the arena DOM (sup_xml_tree::dom::Document).
§API shape: returns a new Document (not mutate-in-place)
The legacy implementation mutates the tree in place: it locates every
<xi:include> element inside a parent’s Vec<Node>, removes it, and
splices in the resolved nodes. That model maps poorly onto the arena
DOM because:
- Arena nodes live in a
bumpalo::Bumpthat’s owned by theDocument; per-node allocations cannot be freed individually. An<xi:include>element that gets “replaced” would simply leak its bytes (harmless, but wasteful). - Included content is parsed into a separate
Documentwith its own arena. An arenaNode<'doc>carries references (&'doc str,&'doc Namespace) tied to that arena and so cannot be moved into a different one — it must be deep-copied. - The neat way to deep-copy across arenas while at the same time
expanding nested
xi:includeelements is to do both in a single walk: read the source tree, allocate equivalents in a destination builder, and substitute include elements as they’re encountered.
So this module’s public entry point process_xincludes
returns a new Document rather than mutating its argument. The
original document is left untouched.
Structs§
- XInclude
Options - Options for
process_xincludes.
Constants§
- XINCLUDE_
NS - XInclude namespace URI. Constant per spec § 4.
Functions§
- process_
xincludes - Process every
xi:includeelement indoc, returning a freshDocumentin which each include has been replaced by the resolved content. Operates by deep-copying the original tree into a new arena;docis left untouched. - resolve_
xpointer - Resolve an XPointer expression against an included document, returning the element/document nodes selected, in document order.