Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET2 custom XPath function(There must be something missing from the JET FAQ regarding custom XPath functions)
JET2 custom XPath function [message #1008554] Wed, 13 February 2013 00:21 Go to next message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
So I'm trying to create a custom xpath function for use in some JET2 templates.

I've followed the JET FAQ - http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath_Function%3F

however when I try to use the function in my templates I get an error saying 'Unknown function name'.

So I'm wondering if there's a step missing from the end of the FAQ saying how to point your transformation to your custom xpath functions, or if the first step where it says create a new plugin project in fact means to say 'do the following in your transformation project'.

Could also be some unmentioned naming convention?

Any ideas?
Re: JET2 custom XPath function [message #1008555 is a reply to message #1008554] Wed, 13 February 2013 00:27 Go to previous messageGo to next message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
Slightly embarrassingly I almost immediately found my answer.

Could definitely be made clearer that the project containing the custom xpath function has to be packaged up and installed into Eclipse (unlike the transformation projects).

It seems a big omission from the FAQ
Re: JET2 custom XPath function [message #1008666 is a reply to message #1008554] Wed, 13 February 2013 14:15 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Here is what I think is happening:

You declared your function in a plug-in other than your JET transformation. (This is what the FAQ suggests.) Then you run the JET transformation (which is a project in your workspace). In this case, JET will fail to find your custom function. The reason:

* JET does some fancy manipulation of your environment to temporarily load the JET project as a plug-in. But, JET does not load any other workspace projects, so at run time, JET cannot find your function. (This was be design - resolving plug-ins correctly is a hard problem. What JET does is a 'hack' to allow quick testing.)

There are several ways to work around this:

1) Instead of launching the JET transformation from your development environment, use the Run menu to start an Eclipse Application instance. The default configuration of this 'inner' Eclipse instance will include your JET transformation along with any other plug-ins in your workspace. Once this second Eclipse instance is running, create a project with your test data, and create a launch configuration to run it through your JET transformation.

2) Define the function in your JET project.
a) Start by making the Java packages visible in that project: Drop down the Package Explorer 'view menu' (this little white downward pointing triangle), and choose Filters. Then, clear the 'Java elements from JET Transformation projects' check box and click OK.
b) Open plugin.xml in the JET project, and add the function declaration.
c) Create the function implementation in a Java package in your project.
d) Test.

Paul
Re: JET2 custom XPath function [message #1009375 is a reply to message #1008666] Fri, 15 February 2013 02:15 Go to previous message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
So if JET doesn't load any other workspace plugins then I'm guessing the transformation project can't have any dependencies on other projects.

Is there any way to get around that so that, for example scriptlets could use classes defined in other bundles?
Previous Topic:Xpand with Unit test
Next Topic:[Acceleo] How to load two models as input for generation?
Goto Forum:
  


Current Time: Sat Dec 20 00:12:29 GMT 2014

Powered by FUDForum. Page generated in 0.06032 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software