A specification-driven XPath 1.0 compiler and evaluator for MoonBit.
moon add cravan371/xpath-evaluator@0.1.0import {
"cravan371/xpath-evaluator" @xpath,
}moon run src/cmd/xpath --target native -- eval \
--expr "//book[@category='fiction']/title/text()" examples/books.xml1984moon run src/cmd/xpath --target native -- eval \
--expr "//d:response/d:href/text()" \
--namespace d=DAV: --format json examples/webdav-multistatus.xmlxpath eval --expr <XPath> [--namespace prefix=uri] [--format text|json]
[--max-input-units N] [--max-nodes N] [--max-depth N] [xml-file|-]let static_context = StaticContext::new()
let compiled = compile("//book/title/text()", static_context)
let document = parse_document("<library><book><title>1984</title></book></library>")
let context = DynamicContext::new(document, document.root())
let titles = select(compiled, context)
// 一次性场景:先编译表达式,随后解析 XML 并求值。
let result = evaluate_xml("count(//book)", "<library><book/></library>")moon fmt --check
moon check --target all --deny-warn
moon test --target all --warn-list -68-1+73
moon build src/cmd/xpath --target native
moon info --target all
bash scripts/cli_e2e.shfn evaluate_xml(expression : String, xml : String, static_context? : StaticContext) -> XPathValue raise XPathErrorfn parse_document(xml : String, max_input_units? : Int, max_nodes? : Int, max_depth? : Int) -> Document raise XPathErrorInstall
Download zipA specification-driven XPath 1.0 compiler and evaluator for MoonBit.