Mica::XML::XPath
XPath 1.0 over Mica::XML::Document trees.
Supported: the full XPath 1.0 expression grammar (location paths,
abbreviations, predicates, filter expressions, unions, arithmetic,
comparisons, variables); the axes child, descendant,
descendant-or-self, self, parent, ancestor, ancestor-or-self,
following, following-sibling, preceding, preceding-sibling and
attribute; all node tests; and the core function library except
id() and lang(). The namespace axis, id() and lang() raise
Mica::XML::XPathError. See the README for the grammar.
document = Mica::XML.parse(%(<a><b n="1"/><b n="2"/></a>))
expression = Mica::XML::XPath.compile("//b[@n > 1]")
expression.evaluate(document.node) # => [#<Mica::XML::Node ELEMENT_NODE name="b">]
Constants
The default work budget for one evaluation: 64 operations per node of the document, plus 1,000,000, and at most 10 seconds. Each axis step with position-free predicates is linear in the document, so ordinary queries use a small fraction of it; nested and positional predicates multiply, and the budget stops them.
Significant digits kept when converting a decimal string; enough for correct rounding of any binary64 value once a sticky digit is added.
Class methods
Parses path. Raises Mica::XML::XPathError on a syntax error or an
unsupported feature. Lexing and parsing are charged to meter (one
operation per byte and per token, with the expression's bytes as
units), or to a fresh meter on DEFAULT_WORK_BUDGET, and stop with a
positioned Mica::LimitExceededError when it runs out.