解析XPath使用PetitParser在Java中

huangapple go评论75阅读模式
英文:

Parse XPath with PetitParser in Java

问题

"有人知道是否有一个在Java中使用PetitParser的XPath解析器的现有实现吗?我假设几乎不可能覆盖所有可通过例如javax.xml.xpath.XPath理解的XPath表达式,但也许有一个实现覆盖了一些XPath表达式,比如

//div[@id='123']//span

//ul/li[last()]/../span

/bookstore/book[position()>=2 and position() <= (last() - 1)]

以提供一些示例。"

英文:

Does anybody know if there is an existing implementation of an XPath parser in Java that uses PetitParser?
I assume it is more or less impossible to cover all thinkable XPath expressions that are understood by e.g. javax.xml.xpath.XPath but maybe there is an implementation that covers some XPath expressions like

//div[@id=&#39;123&#39;]//span
or
//ul/li[last()]/../span
or
/bookstore/book[position()&gt;=2 and position() &lt;= (last() - 1)]

to give some examples.

答案1

得分: 1

XML包在Dart中配备了一个使用PetitParser编写的简单XPath实现。将该语法(和评估器)转换为PetitParser的Java版本应该相对容易。

请注意,该语法尚不支持完整的标准,但其中包含了最常用的部分。还有一个在线演示,您可以在其中体验功能。

英文:

The XML package in Dart comes with a simple XPath implementation that was written using PetitParser. It should be relatively easy to convert that grammar (and evaluator) to the Java version of PetitParser.

Note that the grammar does not support the full standard (yet), but the most commonly used parts are there. There is also an online demo, where you can play with the functionality.

huangapple
  • 本文由 发表于 2023年4月1日 00:07:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900622.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定