Skip to main content

Module rtf

Module rtf 

Source
Expand description

XSLT result-tree-fragment storage for XPath navigation.

When XSLT 2.0 binds a body-form xsl:variable, the spec models the variable’s value as a temporary document tree. XPath expressions like $rtf/foo need to navigate into that tree just like a source document — children, attributes, predicates, the works.

Our super::context::DocIndex is built once from the source and held as &DocIndex everywhere afterward, so RTFs can’t be grafted into its primary node table mid-evaluation. Instead each RTF is built complete-then-frozen as an RtfIndex (owned-string copies of element / attribute / text content) and pushed into a elsa::FrozenVec hosted by DocIndex. The FrozenVec lets us append via shared &self while every &RtfIndex we hand out keeps its heap address stable for the lifetime of the surrounding evaluation — so the DocIndexLike accessors on DocIndex can route to the right RTF and return &[NodeId] slices directly from its internal table.

§NodeId encoding

RTF node-ids carry a marker bit so the dispatch is a single mask test on every accessor. The layout (on 64-bit usize):

 63        62      32             0
  ┌────────┬───────┬───────────────┐
  │ synth  │  RTF  │   rtf-index   │   ← bits 32..62 = which RTF
  ├────────┴───────┴───────────────┤
  │           local node id        │   ← bits 0..32   = node within
  └────────────────────────────────┘

synth is the existing EXSLT synthetic-text marker (bit 63); RTF is bit 62. The two are mutually exclusive: an id is either synthetic-text, an RTF node, or a real source-tree node.

Structs§

RtfBuilder
Helper for populating an RtfIndex one node at a time. The builder owns the slot index it’ll be pushed into so it can encode child / parent / attribute ids directly to global form during construction; no second pass needed.
RtfIndex
One result-tree fragment indexed for XPath navigation. Built complete-then-frozen — once a RtfIndex is pushed into the host elsa::FrozenVec, its nodes table never mutates.
RtfNode
One node inside an RtfIndex. Strings are owned (boxed) so the index can stand alone after the source crate::xpath::eval result-tree fragment has been built — XSLT bind_variable constructs the index then drops the intermediate.

Enums§

RtfNodeKind

Constants§

RTF_BASE
Bit 62 — set on every NodeId that addresses a node in an RtfIndex. Mutually exclusive with the synthetic-text marker (bit 63) so a single mask test on each accessor dispatches the three storage regions.

Functions§

decode_rtf_id
Decompose an RTF node-id into (host-vector index, local id).
encode_rtf_id
Compose an RTF node-id from its host-vector index and the per-RTF local id. Panics in debug mode when either component exceeds its bit budget.
is_rtf_id
True iff id addresses an RtfIndex node (bit 62 set).