我需要一些东西,可以为任何已编译的XPath版本2表达式写出执行树。
使用libxml2附带的程序testXPath,您可以编译一个XPath表达式,然后转储表示执行该表达式的步骤的树。但它仅适用于XPath版本1。
我已经用谷歌搜索了几天,想找到适用于XPath版本2的东西,但没有找到。
下面是一个使用testXPath的示例:
testXPath --tree '/foo[@bar="baz"]/horse'输出:
SORT
COLLECT 'child' 'name' 'node' horse
COLLECT 'child' 'name' 'node' foo
ROOT
PREDICATE
EQUAL =
COLLECT 'attributes' 'name' 'node' bar
NODE
ELEM Object is a string : baz
COLLECT 'attributes' 'name' 'node' bar
NODE以下是XPath版本2的示例:
testXPath --tree '/foo/(bar|baz)'结果是:
XPath error : Invalid expression
/foo/(bar|baz)
^发布于 2019-06-24 05:16:20
Saxon-EE将使用Expression.export()方法导出内部XPath表达式树的XML表示。这支持XPath 3.1。
https://stackoverflow.com/questions/56724411
复制相似问题