Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 58 variants Or(Box<Expr>, Box<Expr>), And(Box<Expr>, Box<Expr>), Eq(Box<Expr>, Box<Expr>), Ne(Box<Expr>, Box<Expr>), Lt(Box<Expr>, Box<Expr>), Gt(Box<Expr>, Box<Expr>), Le(Box<Expr>, Box<Expr>), Ge(Box<Expr>, Box<Expr>), ValueEq(Box<Expr>, Box<Expr>), ValueNe(Box<Expr>, Box<Expr>), ValueLt(Box<Expr>, Box<Expr>), ValueGt(Box<Expr>, Box<Expr>), ValueLe(Box<Expr>, Box<Expr>), ValueGe(Box<Expr>, Box<Expr>), Add(Box<Expr>, Box<Expr>), Sub(Box<Expr>, Box<Expr>), Mul(Box<Expr>, Box<Expr>), Div(Box<Expr>, Box<Expr>), Mod(Box<Expr>, Box<Expr>), Neg(Box<Expr>), Union(Box<Expr>, Box<Expr>), Path(LocationPath), FilterPath { primary: Box<Expr>, predicates: Vec<Expr>, steps: Vec<Step>, }, FunctionCall(String, Vec<Expr>), Variable(String), Literal(String), Integer(i64), Decimal(Decimal), Double(f64), IfThenElse { cond: Box<Expr>, then_branch: Box<Expr>, else_branch: Box<Expr>, }, For { bindings: Vec<(String, Expr)>, body: Box<Expr>, }, Let { bindings: Vec<(String, Expr)>, body: Box<Expr>, }, Range(Box<Expr>, Box<Expr>), SimpleMap(Box<Expr>, Box<Expr>), NodeBefore(Box<Expr>, Box<Expr>), NodeAfter(Box<Expr>, Box<Expr>), NodeIs(Box<Expr>, Box<Expr>), Sequence(Vec<Expr>), Quantified { kind: QuantifierKind, bindings: Vec<(String, Expr)>, test: Box<Expr>, }, IDiv(Box<Expr>, Box<Expr>), Intersect(Box<Expr>, Box<Expr>), Except(Box<Expr>, Box<Expr>), InstanceOf(Box<Expr>, SequenceType), CastAs(Box<Expr>, SingleType), TryCatch { body: Box<Expr>, catches: Vec<XPathCatch>, }, CastableAs(Box<Expr>, SingleType), TreatAs(Box<Expr>, SequenceType), WithDefaultCollation(String, Box<Expr>), BackwardsCompat(Box<Expr>), MapConstructor(Vec<(Expr, Expr)>), ArrayConstructor { members: Vec<Expr>, square: bool, }, Lookup(Box<Expr>, LookupKey), UnaryLookup(LookupKey), InlineFunction { params: Vec<String>, sig: Box<FunctionSig>, body: Box<Expr>, }, ContextItem, NamedFunctionRef { name: String, arity: usize, }, DynamicCall { func: Box<Expr>, args: Vec<Expr>, }, Placeholder,
}

Variants§

§

Or(Box<Expr>, Box<Expr>)

§

And(Box<Expr>, Box<Expr>)

§

Eq(Box<Expr>, Box<Expr>)

General comparison (=, !=, <, >, <=, >=) — existential over the cartesian product of the two operand sequences (XPath 2.0 §3.5.2).

§

Ne(Box<Expr>, Box<Expr>)

§

Lt(Box<Expr>, Box<Expr>)

§

Gt(Box<Expr>, Box<Expr>)

§

Le(Box<Expr>, Box<Expr>)

§

Ge(Box<Expr>, Box<Expr>)

§

ValueEq(Box<Expr>, Box<Expr>)

Value comparison (eq, ne, lt, gt, le, ge) — single- item operands, returns the empty sequence when either side is empty, raises a type error when either side has more than one item (XPath 2.0 §3.5.1).

§

ValueNe(Box<Expr>, Box<Expr>)

§

ValueLt(Box<Expr>, Box<Expr>)

§

ValueGt(Box<Expr>, Box<Expr>)

§

ValueLe(Box<Expr>, Box<Expr>)

§

ValueGe(Box<Expr>, Box<Expr>)

§

Add(Box<Expr>, Box<Expr>)

§

Sub(Box<Expr>, Box<Expr>)

§

Mul(Box<Expr>, Box<Expr>)

§

Div(Box<Expr>, Box<Expr>)

§

Mod(Box<Expr>, Box<Expr>)

§

Neg(Box<Expr>)

§

Union(Box<Expr>, Box<Expr>)

§

Path(LocationPath)

§

FilterPath

Primary expression with optional predicates and additional steps.

Fields

§primary: Box<Expr>
§predicates: Vec<Expr>
§steps: Vec<Step>
§

FunctionCall(String, Vec<Expr>)

§

Variable(String)

§

Literal(String)

§

Integer(i64)

Integer literal — no . and no exponent (42), an xs:integer. A literal too large for i64 is lexed as a Expr::Decimal.

§

Decimal(Decimal)

Decimal literal — a . but no exponent (3.14), an xs:decimal. Carries an exact rust_decimal::Decimal parsed from the source lexical form (so 0.1 is 1/10 exactly, not the f64 nearest neighbour). Stringifies in decimal form, never scientific.

§

Double(f64)

Numeric literal with an exponent (1.5e0) — an xs:double. In a 2.0 host this evaluates to a typed double so it takes the F&O scientific string form.

§

IfThenElse

XPath 2.0 if (cond) then a else b. Both branches are ExprSingle — already parsed as full expressions.

Fields

§cond: Box<Expr>
§then_branch: Box<Expr>
§else_branch: Box<Expr>
§

For

XPath 2.0 for $v in seq return body, with chained bindings (for $a in A, $b in B return ...) flattened into the bindings list in source order.

Fields

§bindings: Vec<(String, Expr)>
§body: Box<Expr>
§

Let

XPath 3.0 let $v := expr return body, with chained bindings (let $a := A, $b := B return ...) flattened into the bindings list in source order. Each binding is evaluated once and is visible to later bindings and the body.

Fields

§bindings: Vec<(String, Expr)>
§body: Box<Expr>
§

Range(Box<Expr>, Box<Expr>)

XPath 2.0 range m to n — yields the integer sequence m, m+1, …, n (inclusive). Empty when m > n. Atomic non-integer operands round to integers before the range materialises.

§

SimpleMap(Box<Expr>, Box<Expr>)

XPath 3.0 simple-map operator E1 ! E2 — evaluates E2 with each item of E1 as the context item; concatenates results in iteration order (no document-order sort). Distinct from / in that the right-hand side need not be a node-step: (1, 2, 3) ! (. * 2) yields (2, 4, 6).

§

NodeBefore(Box<Expr>, Box<Expr>)

XPath 2.0 node-comparison $a << $b — true iff $a precedes $b in document order. Empty operands yield the empty sequence.

§

NodeAfter(Box<Expr>, Box<Expr>)

XPath 2.0 node-comparison $a >> $b — node-after.

§

NodeIs(Box<Expr>, Box<Expr>)

XPath 2.0 node-comparison $a is $b — true iff both operands are the same node. Each operand must atomise to at most one node; an empty operand yields the empty sequence (§3.5.3).

§

Sequence(Vec<Expr>)

XPath 2.0 parenthesised sequence literal (a, b, c) — at least two elements (a singleton is just a parenthesised expression). Evaluation concatenates each item; atomics become synthetic text nodes so the result is uniformly a NodeSet.

§

Quantified

XPath 2.0 quantified expression some $v in seq satisfies test / every $v in seq satisfies test. Boolean result: any / all items of the sequence satisfy the predicate.

Fields

§bindings: Vec<(String, Expr)>
§test: Box<Expr>
§

IDiv(Box<Expr>, Box<Expr>)

XPath 2.0 lhs idiv rhs — integer quotient with truncation towards zero (XPath 2.0 § 3.4). Distinct from div, which always produces a float.

§

Intersect(Box<Expr>, Box<Expr>)

XPath 2.0 lhs intersect rhs — node-set intersection in document order.

§

Except(Box<Expr>, Box<Expr>)

XPath 2.0 lhs except rhs — nodes in lhs not present in rhs, document order preserved.

§

InstanceOf(Box<Expr>, SequenceType)

XPath 2.0 expr instance of SequenceType — boolean predicate.

§

CastAs(Box<Expr>, SingleType)

XPath 2.0 expr cast as SingleType — value conversion; raises a runtime error when the source value can’t be cast.

§

TryCatch

XPath 3.1 try { TryExpr } catch <NameTest>* { CatchExpr } … — evaluate body; on dynamic error, walk catches and evaluate the first whose name-tests match the caught error’s QName. Inside the catch handler, $err:code / $err:description / etc. are bound to the error’s metadata.

Fields

§body: Box<Expr>
§catches: Vec<XPathCatch>
§

CastableAs(Box<Expr>, SingleType)

XPath 2.0 expr castable as SingleType — boolean predicate for “can this value cast without error”.

§

TreatAs(Box<Expr>, SequenceType)

XPath 2.0 expr treat as SequenceType — assertion that the runtime value already conforms; raises an error otherwise.

§

WithDefaultCollation(String, Box<Expr>)

Synthetic — not produced by the XPath parser. The XSLT compiler wraps each top-level expression whose static context declares a non-codepoint [xsl:]default-collation so the runtime can install that URI on a thread-local before evaluating inner. Value-comparison operators (eq, ne, lt, …) consult that thread-local when both operands are strings/untyped — XPath 2.0 §3.5.2 says they use the static default collation in that case.

§

BackwardsCompat(Box<Expr>)

Synthetic — not produced by the XPath parser. The XSLT compiler wraps each top-level expression that sits in an XPath-1.0 backwards-compatibility scope (a [xsl:]version="1.0" ancestor inside a 2.0 stylesheet, XSLT 2.0 §3.8). The runtime installs a thread-local flag before evaluating inner so the XPath-1.0-compat conversion rules (XPath 2.0 §B.1) apply: arithmetic operands are atomised to xs:double, and to-range bounds use the first item of a sequence.

§

MapConstructor(Vec<(Expr, Expr)>)

XPath 3.1 §3.11.1 map constructor map { k1: v1, k2: v2, … }. Each entry is (key-expr, value-expr); keys evaluate to a single atomic value, values to an arbitrary sequence.

§

ArrayConstructor

XPath 3.1 §3.11.2 array constructors — [ a, b, c ] (square: one member per comma-separated expression) or array { … } (curly: one member per item of the contained sequence).

Fields

§members: Vec<Expr>
§square: bool
§

Lookup(Box<Expr>, LookupKey)

XPath 3.1 §3.11.3 postfix lookup E ? K — indexes into the map or array produced by E.

§

UnaryLookup(LookupKey)

XPath 3.1 unary lookup ? K — indexes into the context item.

§

InlineFunction

XPath 3.1 §3.12 inline function function($p, …) { body }. Parameter types and the return type are accepted but not enforced; only the parameter names matter for binding.

Fields

§params: Vec<String>
§sig: Box<FunctionSig>

Declared signature (parameter and return types, item()* where omitted) — used for function subtyping in instance of.

§body: Box<Expr>
§

ContextItem

XPath 3.0 §3.1.4 context-item expression . used as a primary — yields the current context item (which may be a non-node such as a function item). Distinct from a self::node() step: produced only where . carries a postfix (.(args), .?key), so the context item’s actual value, not its node projection, drives the postfix.

§

NamedFunctionRef

XPath 3.1 §3.1.6 named function reference name#arity.

Fields

§name: String
§arity: usize
§

DynamicCall

XPath 3.1 §3.2.2 dynamic function call F(args) where F is an expression yielding a function item. The ? placeholder (partial application) appears as Expr::Placeholder in args.

Fields

§func: Box<Expr>
§args: Vec<Expr>
§

Placeholder

XPath 3.1 partial-application argument placeholder (?).

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.