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:
- Number literals with exponents — XPath 1.0 § 3.5 forbids
1e10/1.5e-3style exponent notation in number literals; libxml2 accepts them. In compat mode we accept too. number('-')— XPath 1.0 § 4.4 says the result isNaNwhen the argument is not a lexical number; libxml2 returns-0. In compat mode we return-0.string()of large numbers — XPath 1.0 § 4.2 mandates decimal-only output; libxml2 emits1.23456789012346e+19in 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: boolEnable XPath 2.0 syntax additions that XPath 1.0 forbids:
if (cond) then a else bconditional expressionfor $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: u64Per-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
impl Clone for XPathOptions
Source§fn clone(&self) -> XPathOptions
fn clone(&self) -> XPathOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more