pub enum XPathValue {
NodeSet(Vec<usize>),
ForeignNodeSet(Vec<*const Node<'static>>),
String(String),
Number(Numeric),
Boolean(bool),
Typed(Box<TypedAtomic>),
Sequence(Vec<Value>),
IntRange {
lo: i64,
hi: i64,
},
Map(Box<Vec<(Value, Value)>>),
Array(Box<Vec<Value>>),
Function(Box<FunctionItem>),
}Variants§
NodeSet(Vec<usize>)
ForeignNodeSet(Vec<*const Node<'static>>)
Result of document(URI) — nodes that live in a doc the
engine’s current DocIndex doesn’t cover. The engine treats
these opaquely; ops that need traversal/string-value delegate
to the bindings (compat looks up the right DocIndex via its
doc registry). Pointer-identity dedup, no document order
across docs.
String(String)
Number(Numeric)
Boolean(bool)
Typed(Box<TypedAtomic>)
XPath 2.0 typed atomic value — carries the source XSD type
tag so instance of xs:T, cast as xs:T, and other
type-aware operators can answer schema questions about it.
Numeric / boolean / string operations treat a Typed value
as its underlying representation (see value_to_number,
value_to_string, value_to_bool for the lowering
rules) so XPath 1.0-style consumers keep working unchanged.
Boxed to keep sizeof(Value) at the existing ~32-byte
footprint — non-2.0 hot paths that never produce typed
values pay no memory-bandwidth tax on every Value clone /
push. The cost shifts to one heap allocation per xs:T(…)
call, which is bounded and small.
Sequence(Vec<Value>)
XPath 2.0 §2.4 heterogeneous sequence of typed / atomic
items. Produced by the parenthesised sequence constructor
(a, b, c) when at least one item is a typed atomic — keeps
each item’s type tag intact so instance of / subsequence /
data() round-trip correctly. When every item is a node or
every item is an untyped atomic, the existing NodeSet / single
Value paths are still used to avoid the per-item Value
allocation overhead.
Invariant: items are themselves never Sequence —
sequences flatten at construction (XPath 2.0 §3.3.1).
IntRange
XPath 2.0 §3.3.1 integer range (m to n) carried as bounds
instead of an expanded list. Stays compact for the W3C
Unicode-category test families that iterate 1 to 0x10FFFF
— materialising would cost millions of Value allocations
and burn the per-thread eval-step budget on tree construction
alone. Consumers that need positional / set semantics
(subsequence, document-order comparisons, count of a
mixed sequence) expand via [items_of]; consumers that can
stay arithmetic (count, sum, simple-map first projection)
special-case the variant to keep things O(1).
Invariant: lo <= hi — empty ranges normalise to
NodeSet(vec![]) at construction so consumers never see an
IntRange they need to test for emptiness.
Map(Box<Vec<(Value, Value)>>)
XPath 3.1 §17.1 map — an ordered list of (key, value) entries.
Keys are single atomic values; values are arbitrary sequences
(themselves Values). Lookup compares keys by value
(map_key_eq). Boxed to keep sizeof(Value) small.
Array(Box<Vec<Value>>)
XPath 3.1 §17.3 array — an ordered list of members, each an
arbitrary sequence (a Value). Indexed 1-based via ?.
Function(Box<FunctionItem>)
XPath 3.1 function item — an inline function (with its captured closure), a named-function reference, or a partial application.
Implementations§
Source§impl Value
impl Value
Sourcepub fn untyped(self) -> Value
pub fn untyped(self) -> Value
Strip a typed wrapper, returning the underlying untyped Value. Numeric typed → Number; boolean typed → Boolean; otherwise → String (the typed value’s lexical form, moved out without cloning). A Sequence collapses to a NodeSet only when every item is already a node (no atomic-sequence lowering); a singleton Sequence unwraps to its sole item. Non-Typed, non-Sequence values pass through unchanged.