class

Mica::XML::XPath::Expression

Inherits Reference < Object

A parsed XPath expression that can be evaluated many times.

Constructors

new(source : String, root : Expr)

Wraps a syntax tree built by XPath.compile. A tree deeper than the compiler allows is rejected here as well.

Source

Instance methods

evaluate(node : Node, namespaces : Hash(String, String) | Nil = nil, variables : Hash(String, Value) | Nil = nil, *, budget : Core::WorkBudget = DEFAULT_WORK_BUDGET, meter : Core::WorkMeter | Nil = nil) : Value

Evaluates the expression with node as the context node.

namespaces maps prefixes to URIs; when nil the namespaces declared on the document's root element are used (the default namespace is registered as xmlns). The evaluation runs under budget (its units are the document's nodes plus the expression's bytes), or draws on meter when given. Raises Mica::WorkBudgetExceededError or Mica::DeadlineExceededError, positioned in the expression, when it runs out.

Source
evaluate_boolean(node : Node, namespaces : Hash(String, String) | Nil = nil, variables : Hash(String, Value) | Nil = nil, *, budget : Core::WorkBudget = DEFAULT_WORK_BUDGET, meter : Core::WorkMeter | Nil = nil) : Bool

Evaluates the expression and converts the result with the XPath boolean() rules inside the same budget.

Source
evaluate_number(node : Node, namespaces : Hash(String, String) | Nil = nil, variables : Hash(String, Value) | Nil = nil, *, budget : Core::WorkBudget = DEFAULT_WORK_BUDGET, meter : Core::WorkMeter | Nil = nil) : Float64

Evaluates the expression and converts the result with the XPath number() rules inside the same budget.

Source
evaluate_string(node : Node, namespaces : Hash(String, String) | Nil = nil, variables : Hash(String, Value) | Nil = nil, *, budget : Core::WorkBudget = DEFAULT_WORK_BUDGET, meter : Core::WorkMeter | Nil = nil) : String

Evaluates the expression and converts the result with the XPath string() rules inside the same budget (the string value of a node set's first node can be the text of the whole document).

Source
source
Source