Is there an XPath into Groovy GPath compiler?

608 Views Asked by At

We have quite a lot of legacy XPath expressions and are considering to migrate the code over to Groovy + XmlSlurper + GPath.

I'm thinking the task would be smoother if there was a tool (or an API) that takes an existing XPath and produces/executes the corresponding GPath. I.e. something like:

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' )

P.S. Of course, the same can be achieved by straightforward application of XPath APIs, but it feels more right to stick with native way of doing things (GPath).

P.P.S. On the other hand, may be GPath is not a good choice? Would appreciate any comments.

1

There are 1 best solutions below

0
On BEST ANSWER

No ready to use product found. Made a decision to go with XPath, and call Java XPath API (Saxon) from Groovy. Works good.