Skip to main content

DocIndex

Struct DocIndex 

Source
pub struct DocIndex<'doc> {
    pub nodes: Vec<INode<'doc>>,
    /* private fields */
}

Fields§

§nodes: Vec<INode<'doc>>

Implementations§

Source§

impl<'doc> DocIndex<'doc>

Source

pub fn build(doc: &'doc ArenaDoc) -> Self

Build a flat index over doc. O(n) in the number of nodes.

Source

pub fn add_document(&mut self, doc: &'doc ArenaDoc) -> NodeId

Append another document’s tree to this index, returning the NodeId of the new synthetic Document node. Used to make runtime-loaded documents (e.g. via the XSLT document() function or XInclude resolution) addressable through the same XPath index as the primary source.

The added doc must outlive 'doc — typically achieved by owning it in a Vec<Box<Document>> that lives at least as long as the index.

Source

pub fn string_value(&self, id: NodeId) -> String

XPath 1.0 § 5 string value of a node.

Source

pub fn node_name(&self, id: NodeId) -> &str

Source

pub fn local_name(&self, id: NodeId) -> &str

Source

pub fn namespace_uri(&self, id: NodeId) -> &str

Source

pub fn namespace_prefix(&self, id: NodeId) -> Option<&str>

Source§

impl<'doc> DocIndex<'doc>

Source

pub fn allocate_rtf_text_nodes_inherent( &self, values: Vec<String>, ) -> Vec<NodeId>

Allocate one synthetic text node per supplied string and return their NodeIds in document order. Used by EXSLT functions like str:tokenize, str:split, and regexp:match that need to materialise a node-set of strings without an XSLT-engine RTF arena to host them.

The nodes are top-level — they have no parent and no document — but every DocIndexLike accessor handles them correctly so callers can iterate the result with xsl:for-each, take their string-value, count them, etc. Their IDs sort after every real node-set node, so unions stay totally ordered.

Source§

impl<'doc> DocIndex<'doc>

Source

pub fn start_rtf(&self) -> RtfBuilder

Begin building a new result-tree fragment. Returns an RtfBuilder that knows its eventual host-vector slot — callers populate it via add_document / add_element / etc., then hand it back to finish_rtf.

Source

pub fn mark_synthetic_wrap(&self, root: NodeId)

Mark root (an RTF document-root NodeId) as the synthetic wrap of a sequence-typed XSLT binding. See synthetic_wraps for the rationale.

Source

pub fn is_synthetic_wrap(&self, id: NodeId) -> bool

True when id is a synthetic doc-wrap created for sequence-typed binding storage rather than a real source / XSLT document tree root. Used by XTDE1270 / XTDE1370 / XTDE1380 to refuse the wrap as a document for the purposes of fn:key / fn:unparsed-entity-uri and friends.

Source

pub fn finish_rtf(&self, builder: RtfBuilder) -> NodeId

Freeze a populated builder into the host vector. Returns the globally-encoded id of the RTF’s document node so the caller can bind a variable directly to it.

Source

pub fn rtf_node_type(&self, id: NodeId) -> Option<(String, String)>

Governing type (ns, local) recorded for a constructed RTF node, if it was built with a type= / xsl:type= annotation.

Source

pub fn graft_dynamic_document(&self, doc: &Document) -> NodeId

Graft a fully-parsed sup_xml_tree::dom::Document into the index at runtime, returning the node id of its synthetic document root. Used by XSLT 2.0 doc() / XSLT 1.0 document() to resolve URIs computed at apply time (rather than statically discovered at compile time).

The grafted doc reuses the super::rtf storage: every node’s data is copied into the RTF’s append-only nodes table so the caller can drop the source [Document] right after the call. XPath operations on the returned node id dispatch through the same RTF accessors that XSLT-built result-tree fragments use. Bytes-for-bytes structural fidelity is preserved (PIs, comments, attributes, namespace declarations); doc-level XSD typing and unparsed- entity metadata are not — the spec leaves those undefined for doc()-loaded resources.

Trait Implementations§

Source§

impl<'doc> DocIndexLike for DocIndex<'doc>

Source§

fn graft_dynamic_document(&self, doc: &Document) -> Option<NodeId>

Graft a parsed sup_xml_tree::dom::Document into the index at runtime, returning the node id of its synthetic document root. Concrete DocIndex implementations use the same append-only RTF storage that XSLT result-tree fragments use, so the call needs only &self; stub implementations (test shims) return None to fall back to the legacy “URI not pre-loaded” error path in document_fn.
Source§

fn children(&self, id: NodeId) -> &[NodeId]

Children in document order (content children only — attributes are addressed separately via attr_range).
Source§

fn parent(&self, id: NodeId) -> Option<NodeId>

Parent node id, or None for the synthetic Document node (id 0).
Source§

fn attr_range(&self, id: NodeId) -> Range<NodeId>

Attribute-node id range for an element (empty range for non-elements).
Source§

fn ns_range(&self, id: NodeId) -> Range<NodeId>

Namespace-node id range for an element — the synthetic namespace nodes that XPath’s namespace:: axis traverses. One per distinct in-scope prefix (own + inherited, with closer declarations shadowing) plus the implicit xml prefix. Empty for non-elements. Default impl returns an empty range; the arena index materialises these eagerly during build.
Source§

fn kind(&self, id: NodeId) -> XPathNodeKind

Tree-agnostic node-kind discriminant.
Source§

fn pi_target(&self, id: NodeId) -> &str

PI target — only meaningful for XPathNodeKind::PI; returns "" for other kinds.
Source§

fn string_value(&self, id: NodeId) -> String

XPath 1.0 § 5 string value of the node.
Source§

fn node_name(&self, id: NodeId) -> &str

Qualified name (prefix:local) — element / attribute / PI; "" otherwise.
Source§

fn local_name(&self, id: NodeId) -> &str

Local part of the QName (everything after the colon, or the whole name).
Source§

fn namespace_prefix(&self, id: NodeId) -> Option<&str>

Namespace prefix declared on this element/attribute (e.g. "dc"), or None when the node has no namespace or is the default namespace. Default impl returns None; types that carry namespace info (the arena index) override.
Source§

fn namespace_uri(&self, id: NodeId) -> &str

Namespace URI bound to the element/attribute’s prefix; "" otherwise.
Source§

fn is_element(&self, id: NodeId) -> bool

Convenience: kind(id) == Element.
Source§

fn allocate_rtf_text_nodes(&self, values: Vec<String>) -> Option<Vec<NodeId>>

Allocate one synthetic text node per supplied string and return their NodeIds. Used by EXSLT functions (str:tokenize, str:split, regexp:match) that need to return a node-set of computed strings without an XSLT-engine RTF arena to host them. Default returns None — the index implementation doesn’t support runtime allocation. Indexes that do (the arena DocIndex) override to return the new IDs in document order.
Source§

fn rtf_builder(&self) -> Option<RtfBuilder>

Start an append-only RTF subtree the caller can build into via the returned [RtfBuilder]. The builder’s add_document / add_element / add_text / add_attribute API populates a fresh tree; callers hand it back to finish_rtf to publish the resulting RtfIndex into the arena. Default returns None — indexes without arena storage (test shims, foreign-doc wrappers) can signal “no RTF construction support” here. The concrete arena DocIndex overrides to return a real builder.
Source§

fn finish_rtf(&self, builder: RtfBuilder) -> Option<NodeId>

Publish a populated [RtfBuilder] into the arena, returning the global id of the synthetic document root. Mirrors rtf_builder; default returns None.
Source§

fn rtf_node_type(&self, id: NodeId) -> Option<(String, String)>

Schema-aware: governing type (ns, local) of a constructed RTF node built with a type= / xsl:type= annotation, if any. Default None — indexes without RTF type tracking report every constructed node as untyped.
Source§

fn is_synthetic_wrap(&self, id: NodeId) -> bool

True when id is a synthetic RTF doc-wrap that holds the items of a sequence-typed XSLT binding rather than a real XML / XSLT document tree. Used by XSLT’s XTDE1270 / XTDE1370 / XTDE1380 to refuse the wrap as a document root when the spec asks for the “root of the tree containing the context node”. Default false — index shims without sequence-typed binding support never produce such wraps.
Source§

fn is_id_attribute(&self, attr_id: NodeId) -> bool

True iff attr_id is a DTD-declared ID-type attribute or matches the xml:id convention. Default returns true for any attribute whose local name is id (libxml2’s de facto behaviour); indexes built from documents with DTDs override to consult the parsed <!ATTLIST … ID> declarations.
Source§

fn is_idref_attribute(&self, attr_id: NodeId) -> bool

True iff attr_id is a DTD-declared IDREF/IDREFS-type attribute. Unlike ID there is no DTD-less convention, so the default returns false; indexes built from documents with DTDs override to consult the parsed <!ATTLIST … IDREF> declarations. Consulted by XPath 2.0 §14.5.5’s idref().

Auto Trait Implementations§

§

impl<'doc> !Freeze for DocIndex<'doc>

§

impl<'doc> !RefUnwindSafe for DocIndex<'doc>

§

impl<'doc> !Send for DocIndex<'doc>

§

impl<'doc> !Sync for DocIndex<'doc>

§

impl<'doc> !UnwindSafe for DocIndex<'doc>

§

impl<'doc> Unpin for DocIndex<'doc>

§

impl<'doc> UnsafeUnpin for DocIndex<'doc>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.