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§
Sourcefn children(&self, id: NodeId) -> &[NodeId] ⓘ
fn children(&self, id: NodeId) -> &[NodeId] ⓘ
Children in document order (content children only — attributes are
addressed separately via attr_range).
Sourcefn parent(&self, id: NodeId) -> Option<NodeId>
fn parent(&self, id: NodeId) -> Option<NodeId>
Parent node id, or None for the synthetic Document node (id 0).
Sourcefn attr_range(&self, id: NodeId) -> Range<NodeId>
fn attr_range(&self, id: NodeId) -> Range<NodeId>
Attribute-node id range for an element (empty range for non-elements).
Sourcefn kind(&self, id: NodeId) -> XPathNodeKind
fn kind(&self, id: NodeId) -> XPathNodeKind
Tree-agnostic node-kind discriminant.
Sourcefn pi_target(&self, id: NodeId) -> &str
fn pi_target(&self, id: NodeId) -> &str
PI target — only meaningful for XPathNodeKind::PI; returns ""
for other kinds.
Sourcefn string_value(&self, id: NodeId) -> String
fn string_value(&self, id: NodeId) -> String
XPath 1.0 § 5 string value of the node.
Sourcefn node_name(&self, id: NodeId) -> &str
fn node_name(&self, id: NodeId) -> &str
Qualified name (prefix:local) — element / attribute / PI; "" otherwise.
Sourcefn local_name(&self, id: NodeId) -> &str
fn local_name(&self, id: NodeId) -> &str
Local part of the QName (everything after the colon, or the whole name).
Sourcefn namespace_uri(&self, id: NodeId) -> &str
fn namespace_uri(&self, id: NodeId) -> &str
Namespace URI bound to the element/attribute’s prefix; "" otherwise.
Provided Methods§
Sourcefn graft_dynamic_document(&self, _doc: &Document) -> Option<NodeId>
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.
Sourcefn ns_range(&self, _id: NodeId) -> Range<NodeId>
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.
Sourcefn namespace_prefix(&self, _id: NodeId) -> Option<&str>
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.
Sourcefn is_element(&self, id: NodeId) -> bool
fn is_element(&self, id: NodeId) -> bool
Convenience: kind(id) == Element.
Sourcefn is_id_attribute(&self, attr_id: NodeId) -> bool
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.
Sourcefn is_idref_attribute(&self, _attr_id: NodeId) -> bool
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().
Sourcefn allocate_rtf_text_nodes(&self, _values: Vec<String>) -> Option<Vec<NodeId>>
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.
Sourcefn rtf_builder(&self) -> Option<RtfBuilder>
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.
Sourcefn finish_rtf(&self, _builder: RtfBuilder) -> Option<NodeId>
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.
Sourcefn rtf_node_type(&self, _id: NodeId) -> Option<(String, String)>
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.
Sourcefn is_synthetic_wrap(&self, _id: NodeId) -> bool
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".