Skip to main content

XPathOptions

Struct XPathOptions 

Source
pub struct XPathOptions {
    pub libxml2_compatible: bool,
    pub xpath_2_0: bool,
    pub max_eval_steps: u64,
}
Expand description

Knobs for the XPath 1.0 lexer + evaluator. Default is strict XPath 1.0 spec conformance; flipping libxml2_compatible relaxes three points where libxml2 historically deviates from the spec:

  1. Number literals with exponents — XPath 1.0 § 3.5 forbids 1e10 / 1.5e-3 style exponent notation in number literals; libxml2 accepts them. In compat mode we accept too.
  2. number('-') — XPath 1.0 § 4.4 says the result is NaN when the argument is not a lexical number; libxml2 returns -0. In compat mode we return -0.
  3. string() of large numbers — XPath 1.0 § 4.2 mandates decimal-only output; libxml2 emits 1.23456789012346e+19 in scientific form for very large / very small magnitudes. In compat mode we emit libxml2’s scientific form.

Default: false (strict — recommended). Set to true only when porting from libxml2-flavoured XPath corpora or pipelines.

Fields§

§libxml2_compatible: bool§xpath_2_0: bool

Enable XPath 2.0 syntax additions that XPath 1.0 forbids:

  • if (cond) then a else b conditional expression
  • for $v in seq return body (with comma-chained bindings)
  • (more 2.0 grammar will land here as it grows)

Off by default — XPath 1.0 is the spec contract callers depend on. The XSLT compiler flips this on when the stylesheet declares version="2.0" (or higher).

§max_eval_steps: u64

Per-evaluation step ceiling — the cap on charged eval steps that bounds adversarial nested-predicate complexity (the //*[//*[…]] O(N^k) shape). When exceeded, evaluation aborts with an error rather than hanging. Defaults to eval::DEFAULT_MAX_EVAL_STEPS (20M) — comfortable for ordinary and generated XPath. Lower it (e.g. 1–2M) when evaluating untrusted expressions to tighten the worst-case CPU bound; raise it for trusted, legitimately-expensive generated XPath. A value of 0 makes every evaluation fail on its first step.

Trait Implementations§

Source§

impl Clone for XPathOptions

Source§

fn clone(&self) -> XPathOptions

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 XPathOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for XPathOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.