Skip to main content

Module xinclude

Module xinclude 

Source
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:

  1. Arena nodes live in a bumpalo::Bump that’s owned by the Document; per-node allocations cannot be freed individually. An <xi:include> element that gets “replaced” would simply leak its bytes (harmless, but wasteful).
  2. Included content is parsed into a separate Document with its own arena. An arena Node<'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.
  3. The neat way to deep-copy across arenas while at the same time expanding nested xi:include elements 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§

XIncludeOptions
Options for process_xincludes.

Constants§

XINCLUDE_NS
XInclude namespace URI. Constant per spec § 4.

Functions§

process_xincludes
Process every xi:include element in doc, returning a fresh Document in which each include has been replaced by the resolved content. Operates by deep-copying the original tree into a new arena; doc is left untouched.
resolve_xpointer
Resolve an XPointer expression against an included document, returning the element/document nodes selected, in document order.