English 中文(简体)
有XPath进入 Groovy GPath 编译器吗?
原标题:Is there an XPath into Groovy GPath compiler?

我们有很多遗留的 XPath 表达方式, 正在考虑将代码迁移到 Groovy + XmlSlurper + GPath 。

我认为,如果有一个工具(或API)可以使用现有的 XPath 并生产/执行相应的 GPath。 I. e. 例如:

def resp = new XmlSlurper().parseText(responseAsXml)
def gpath = GPathSomething.compile("//foo/bar[id= 123 ]")
def result = gpath.execute(resp)
def result2 = gpath. ** .grep( it.@bar =  baz  )

当然,通过直接应用XPath API,也可以实现同样的目标,但坚持当地的做法(GPath)更合适。

P.P.S.另一方面,G.P.P.也许G.P.P.不是一个很好的选择?希望得到任何评论。

最佳回答

无法使用发现的产品。 决定使用 XPath, 并给Groovy的 Java XPath API (Saxon) 打电话。 效果不错 。

问题回答

暂无回答




相关问题
Groovy - how to exit each loop?

I m new to Grails/Groovy and am trying to find a node in a an xml file; I ve figured out how to iterate over all of them, but I want to exit the loop when the target node is found. I ve read that ...

Eclipse Spring Builder set properties with Groovy beans

I typically use groovy to construct simple bean but the Spring IDE plugin to eclipse fails to build when I try to set a property that is generated by groovy without an explicit setter. For example, ...

How can I get this snippet to work?

I d like to port a little piece of code from Ruby to Groovy, and I m stuck at this: def given(array,closure) { closure.delegate = array closure() } given([1,2,3,4]) { findAll { it > 4} ...

Changing the value in a map in Groovy

This is about a very basic program I m writing in Groovy. I have defined a map inside a method: def addItem() { print("Enter the item name: ") def itemName = reader.readLine() print(...

Is functional Clojure or imperative Groovy more readable?

OK, no cheating now. No, really, take a minute or two and try this out. What does "positions" do? Edit: simplified according to cgrand s suggestion. (defn redux [[current next] flag] [(if flag ...

热门标签