Expand description
XPath 1.0 importer for Quarb.
Translates an XPath 1.0 expression into an equivalent Quarb
query, following the mapping in the specification’s comparative
guide. The translatable subset covers the axes and predicate
forms Quarb models directly; everything else is refused with an
XPathError::Unsupported naming the construct, never silently
approximated.
- Axes:
child,descendant,parent(..),ancestor,self(.),attribute(@),following-sibling(>>),preceding-sibling(<<). Nofollowing/preceding(document-order) ornamespaceaxes. - Node tests: names (namespace-prefixed names become quoted
Quarb segments),
*, and terminaltext(). Nonode(),comment(), orprocessing-instruction(): Quarb navigates elements only. - Predicates: positional
[n],[last()]→[-1](and[last() - k]→[-(k+1)]),position()comparisons → index / range predicates ([position() > 1]→[2..]), comparisons over attributes,text(),.and relative descending paths, existence tests,and/or/not(),contains(),starts-with(). - Top level: union
|becomes||;count(...)andsum(...)become@| count/@| sumaggregations.
Known semantic divergences are reported as Translation::notes
rather than errors:
[n]on an abbreviated//step: XPath expands//name[n]to a per-parentchild::step, positioning within each parent, while Quarb positions within the hop’s whole per-source result list. The two agree when all matches share one parent. On the child axis (name[n]) and the explicit descendant axis (descendant::name[n]) the translation is exact.- Quarb’s
::textis the concatenated descendant text, while XPath’stext()selects immediate text-node children. The two agree on leaf elements.
Structs§
- Translation
- A successful translation: the Quarb query, plus notes on known semantic divergences that apply to it.
Enums§
- XPath
Error - An error translating an XPath expression.