Skip to main content

DocIndexLike

Trait DocIndexLike 

Source
pub trait DocIndexLike {
Show 20 methods // Required methods fn children(&self, id: NodeId) -> &[NodeId] ; fn parent(&self, id: NodeId) -> Option<NodeId>; fn attr_range(&self, id: NodeId) -> Range<NodeId>; fn kind(&self, id: NodeId) -> XPathNodeKind; fn pi_target(&self, id: NodeId) -> &str; fn string_value(&self, id: NodeId) -> String; fn node_name(&self, id: NodeId) -> &str; fn local_name(&self, id: NodeId) -> &str; fn namespace_uri(&self, id: NodeId) -> &str; // Provided methods fn graft_dynamic_document(&self, _doc: &Document) -> Option<NodeId> { ... } fn ns_range(&self, _id: NodeId) -> Range<NodeId> { ... } fn namespace_prefix(&self, _id: NodeId) -> Option<&str> { ... } fn is_element(&self, id: NodeId) -> bool { ... } fn is_id_attribute(&self, attr_id: NodeId) -> bool { ... } fn is_idref_attribute(&self, _attr_id: NodeId) -> bool { ... } fn allocate_rtf_text_nodes( &self, _values: Vec<String>, ) -> Option<Vec<NodeId>> { ... } fn rtf_builder(&self) -> Option<RtfBuilder> { ... } fn finish_rtf(&self, _builder: RtfBuilder) -> Option<NodeId> { ... } fn rtf_node_type(&self, _id: NodeId) -> Option<(String, String)> { ... } fn is_synthetic_wrap(&self, _id: NodeId) -> bool { ... }
}
Expand description

Methods the XPath evaluator needs from any backing tree representation.

Both super::context::DocIndex and super::context::DocIndex implement this trait so eval can run against either.

Required Methods§

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 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_uri(&self, id: NodeId) -> &str

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

Provided Methods§

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 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 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 is_element(&self, id: NodeId) -> bool

Convenience: kind(id) == Element.

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().

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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