好的免费 Java XPath Evaluator 源代码 - 也许是 JXPath?
有没有好的免费 XPath 评估器源代码可用?
我们有一个与 XML 不太相似的树形数据结构。然而,如果能够包含类似于 XPath 求值器(轻量级)的东西来在结构中导航,那就太好了。
对于 XPath 表达式来说会很酷,例如:
\Node1*\Child20* \Node11 sum(\Node1*\value)
等等...
我认为我们自己实现解决方案需要一段时间,但不幸的是我们的时间很紧。我们需要来源以使我们能够根据标记化字符串遍历我们的结构。
我并不是在寻找 XPath 库本身,而是在寻找用于评估 XPath 样式表达式的代码。
我希望能够解释基于 XPath 的表达式并处理我们自己的内部数据结构 - 我们自己的对象模型实现。
我在旅行中遇到过 JXPath 但从未使用过它似乎是我可以使用的东西。有人用过这个吗?
谢谢,
安德斯
Is there a good free XPath evaluator source code available?
We have a tree style data structure which is not too dissimilar to XML. However, it would be great to include something similar to an XPath evaluator (lightweight) to navigate through the structure.
Would be cool to XPath expressions such as:
\Node1*\Child20*
\Node11
sum(\Node1*\value)
etc etc...
I think it would take a while to implement a solution ourselves but unfortunately we have tight very timescales. We would need to source to enable us to go through our structure based on the tokenized string.
I am not looking for XPath libraries as such, just the code to evaluate XPath style expressions.
I want to be able to interpret an XPath based expression and process our own internal data structure - our own object model implementation.
I have come across JXPath on my travels but have never used it but it seems like something that I could use. Has anyone ever used this?
Thanks,
Andez
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
HTML Cleaner
非常好,我总是使用这个库作为 Xpath 解析器。您可以尝试: http://htmlcleaner.sourceforge.net/HTML Cleaner
is pretty good, I always use this library for Xpath parser. You can try: http://htmlcleaner.sourceforge.net/您将在 Apache Xalan 中找到 Java 中 XPath 的完整开源实现。
You will find a complete open source implementation of XPath in Java in Apache Xalan.
Java 内置了 XPath 支持。
以下代码提取 xpath 表达式的值:
Java has XPath support built-in.
The following code extracts the value of an xpath expression:
如果您为数据结构编写适配器来实现 Saxon 的 NodeInfo 接口,那么 Saxon 的 XPath 引擎将适用于任何输入数据结构。与修改 XPath 处理器的源代码相比,这似乎是一种更简洁的方法,您必须永远维护 XPath 处理器的源代码。
Saxon's XPath engine will work with any input data structure if you write an adapter for your data structure to implement Saxon's NodeInfo interface. This seems a much cleaner approach than modifying the source code of an XPath processor, which you would then have to maintain for ever.
JXPath 应该适合这个。但您可能必须将其与您的数据结构集成,如 http:// commons.apache.org/jxpath/users-guide.html#Custom_Pointers_and_Iterators。
我最近做了类似的事情,而且效果很好。文档有点薄弱,但看看 DomNodePointer/Dom***Iterator 等现有实现应该会对您的实现有很大帮助。
为了完整起见,Jaxen 允许采用类似的方法。但由于许可原因,我自己无法使用它。
JXPath should be fine for this. But you will probably have to integrate it with your data structure as described at http://commons.apache.org/jxpath/users-guide.html#Custom_Pointers_and_Iterators.
I did a similar thing recently and it worked quiet nicely. Documentation is a little weak but looking it the existing implementations like DomNodePointer/Dom***Iterator should greatly help with your implementation.
For completeness, Jaxen would allow a similar approach. But due to licensing reasons I couldn't use it myself.