是否有适用于XPath version2的编译器可以转储执行树?

时间:2019-06-23 13:36:36

标签: xpath compiler-construction

我需要可以为任何已编译的XPath版本2表达式写出执行树的东西。

使用testXPath附带的程序libxml2,您可以编译XPath表达式,然后转储代表执行该表达式的步骤的树。但这仅适用于XPath版本1。

我已经在Google上搜索了几天,以找到适用于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)
     ^

1 个答案:

答案 0 :(得分:0)

Saxon-EE将使用Expression.export()方法导出内部XPath表达式树的XML表示形式。这支持XPath 3.1。