pub struct RtfBuilder {
pub typed_nodes: Vec<(NodeId, Box<(String, String)>)>,
/* private fields */
}Expand description
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.
Typical usage from the XSLT engine:
let mut b = idx.start_rtf();
let root = b.add_document();
let elem = b.add_element(root, "foo", "", None, &[]);
b.add_text(elem, "hello");
let root_id = idx.finish_rtf(b); // returns encoded root NodeIdFields§
§typed_nodes: Vec<(NodeId, Box<(String, String)>)>Schema-aware: (encoded NodeId, (type-ns, type-local)) for each
constructed node carrying a type= / xsl:type= annotation.
Collected during construction (the builder already encodes ids
to global form) and drained into the host index’s PSVI table by
DocIndex::finish_rtf.
Implementations§
Source§impl RtfBuilder
impl RtfBuilder
Sourcepub fn add_document(&mut self) -> NodeId
pub fn add_document(&mut self) -> NodeId
Add the synthetic Document node. Must be the first call — the index conventionally treats local id 0 as the document root. Returns the encoded global id.
Sourcepub fn add_element(
&mut self,
parent: NodeId,
qname: &str,
namespace_uri: &str,
prefix: Option<&str>,
) -> NodeId
pub fn add_element( &mut self, parent: NodeId, qname: &str, namespace_uri: &str, prefix: Option<&str>, ) -> NodeId
Add an element child of parent. parent is a global
id (the value previously returned by add_document or
another add_element).
pub fn add_text(&mut self, parent: NodeId, content: &str) -> NodeId
pub fn add_comment(&mut self, parent: NodeId, content: &str) -> NodeId
pub fn add_pi(&mut self, parent: NodeId, target: &str, data: &str) -> NodeId
Sourcepub fn start_attrs(&mut self, elem_global: NodeId)
pub fn start_attrs(&mut self, elem_global: NodeId)
Set the contiguous attribute-id range for an element.
Attributes are appended via add_attribute AFTER the
element and BEFORE any further content children — caller
is responsible for ordering and for calling finish_attrs
to lock in the range.
pub fn add_attribute( &mut self, elem_global: NodeId, qname: &str, namespace_uri: &str, prefix: Option<&str>, value: &str, ) -> NodeId
Sourcepub fn start_ns(&mut self, elem_global: NodeId)
pub fn start_ns(&mut self, elem_global: NodeId)
Open the namespace-node range for elem_global. Subsequent
[add_namespace_node] calls populate the contiguous slab;
the range covers them automatically. Callers must invoke
this after the attribute slab (start_attrs /
add_attribute) and before the first child, so attribute
and namespace nodes don’t interleave with element children.
Sourcepub fn add_namespace_node(
&mut self,
elem_global: NodeId,
prefix: Option<&str>,
uri: &str,
) -> NodeId
pub fn add_namespace_node( &mut self, elem_global: NodeId, prefix: Option<&str>, uri: &str, ) -> NodeId
Add an in-scope namespace node to elem_global. prefix is
None for the default-namespace binding and Some("") is
treated identically; otherwise pass the prefix without colons.
Returns the globally-encoded id of the new namespace node so
callers can index it directly (rarely needed — the typical
access path is ns_range(elem)).