英文:
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='123']//span
or
//ul/li[last()]/../span
or
/bookstore/book[position()>=2 and position() <= (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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论