Custom XPath Functions using Groovy

  • nzblue_fish
  • 09/30/09
  • Offline
Posted: Tue, 03/02/2010 - 17:04

Hi,

Is there anyone in the MDC interested in seeing if you can use Groovy to build custom XPath functions?

Just as an experiment, I have tried it out, but after a couple of attempts I've got to the point where I've exceeded my Java/Groovy skills. The last shot at this produced the following result when running an emml in debug mode:

    2010-03-03 09:50:03,411 ERROR [com.jackbe.jbp.jems.moe.runtime.JEMSDesignerImpl] - 
       <Error execution Mashup Script : XPath syntax error at char 15 in {aahfn:tryThis()}:
    Cannot find a matching 0-argument function named {java:com.aah.mashups.CustomFunctions}tryThis()>
net.sf.saxon.trans.StaticError: XPath syntax error at char 15 in {aahfn:tryThis()}:
    Cannot find a matching 0-argument function named {java:com.aah.mashups.CustomFunctions}tryThis()


Here's my Groovy code, which I compiled using Groovyc into a class which I then dropped into the WEB-INF/Classes directory:

package com.aah.mashups
import com.jackbe.jbp.jems.client.EMMLUserFunction
public class CustomFunctions extends EMMLUserFunction {
 public static boolean isFatal() { return false }
 public static String tryThis() { return 'hello' }
}

Cheers, Innes

cfff4
0
Your rating: None