Home » Modeling » M2T (model-to-text transformation) » Extending the JET2 TagLibrary 
| Extending the JET2 TagLibrary [message #50907] | 
Sun, 28 September 2008 19:20   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi all again, 
 
additional to my problem concerning the extension of an user-definied xpath  
function, i have the same problems with the extension of a TagLibrary. I  
introspected the plugin.xml of the jet-plugin, looked into the Extension  
point description, created the required TagFactory- and TagImplementation,  
but I didn't get it work. IMHO, the way of implementing the extension point  
is not very difficulty and is great stuff, if it works. 
 
My problem is, that the translation from main.jet (or any other jet file)  
into Java code didn't include the new defined tag library. I added manually  
the following code snippet into the generated template java file: 
 
Java2TagFactory ff = new Java2TagFactory(); 
CustomTag f = ff.createCustomTag("op"); //$NON-NLS-1$ //$NON-NLS-2$ 
f.setOut(out); 
f.setTagInfo(xyz); 
f.setContext(context); 
((GenerateOperationName)f).doAction(xyz, context, out); 
 
That work's fine. My main.jet looks like this: 
 
.... 
%@taglib id="de.wendland.jet2.xtags" prefix="w"% 
.... 
<w:op operation="eClassifier"/> 
.... 
 
In the JET2 Editor, the w:op isn't highlighted, so, i think it won't be  
located from the plugin. You know, my plugin.xml looks like this: 
 
<extension point="org.eclipse.jet.tagLibraries"> 
    <tagLibrary id="de.wendland.jet2.xtags" name="Extra Wendland Tag"  
standardPrefix="w"  
tagFactory="de.wendland.tfh.se.jet2.dpr.function.Java2TagFactory "> 
        <emptyTag  
class="de.wendland.tfh.se.jet2.dpr.function.GenerateOperationName " name="op"  
whenContainingLineIsEmpty="preserve"> 
            <attribute name="operation" type="string" use="required"> 
            </attribute> 
        </emptyTag> 
    </tagLibrary> 
</extension> 
 
I think, everything is so, as the extension point wants it. I have no idea,  
how to solve this. It is not feasible to add this in the translated  
_jet_main.java file. Does anyone have any idea, why the template engine  
didn't register the tag library? 
 
Thx in advance 
Timothy
 |  
 |  
  |   |  
| Re: Extending the JET2 TagLibrary [message #51019 is a reply to message #50991] | 
Mon, 29 September 2008 13:47    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Dear Paul, 
 
the extension mechanism drives my crazy. It doesn't work at all. 
I have two plugins. 
 
1. de.wendland.jet2.extensions -> for the tagLibraries. 
    the id in the extension of library is:  
de.wendland.jet2.extensions.de.wendland.tags 
    The plugin.xml looks like this: 
<extension point="org.eclipse.jet.tagLibraries"> 
<tagLibrary id="de.wendland.tfh.se.jet2.extensions.de.wendland.dprTags"  
name="Java2" standardPrefix="dpr"  
tagFactory="de.wendland.tfh.se.jet2.extensions.Java2TagFactory "> 
<emptyTag class="de.wendland.tfh.se.jet2.extensions.GenerateOperationName "  
name="computeOperationSignature" whenContainingLineIsEmpty="remove"> 
<attribute name="operation" type="string" use="required"> 
</attribute> 
</emptyTag> 
</tagLibrary> 
</extension> 
 
I've exported this plugin as an deployable plugin via the export wizard,  
copied this into the eclipse plugins directory and restarted eclipse. 
 
 
2. de.wendland.jet2.scenario where i want to use the library. Its plugin.xml  
looks like this: 
<extension id="" name="" point="org.eclipse.jet.transform"> 
<transform modelLoader="org.eclipse.jet.emf"  
startTemplate="templates/main.jet"  
templateLoaderClass="de.wendland.tfh.se.jet2.dpr.compiled._jet_transformation "> 
<description></description> 
<tagLibraries> 
<importLibrary id="org.eclipse.jet.controlTags" usePrefix="c"  
autoImport="true"/> 
<importLibrary id="org.eclipse.jet.javaTags" usePrefix="java"  
autoImport="true"/> 
<importLibrary id="org.eclipse.jet.formatTags" usePrefix="f"  
autoImport="true"/> 
<importLibrary id="org.eclipse.jet.workspaceTags" usePrefix="ws"  
autoImport="false"/> 
<importLibrary autoImport="true" id="de.wendland.tags" usePrefix="dpr"> 
</importLibrary> 
</tagLibraries> 
</transform> 
</extension> 
 
In the main.jet, i use the tag as follows: 
 
        <dpr:computeOperationSignature operation="operationname"/> 
 
but it is ignored and printed directly as output into the generated  
artefacts. In contrast to the well known tags, the newly defined one won't  
be highlighted in the editor. 
 
I've tried every of your possibility, but i didn't get the tag run. With the  
XPath functions i have a similar problem. In the same plugin as the library  
tag, i've defined two XPath functions. Strangely, only one of these  
functions will be found be the environment without running it inside a  
runtime workbench. Well, both functions are found, if it runs inside a  
runtime workbench, but the tag library won't work. Neither when i installed  
the plugin, nor by running it inside a runtime workbench. 
 
Actually, i have no more ideas for configuration variants. 
 
Hope, you have the idea :) 
Timothy 
 
 
"Paul Elder" <pelder@ca.ibm.com> schrieb im Newsbeitrag  
news:gbqubq$s1i$1@build.eclipse.org... 
> Timothy: 
> 
> Three things: 
> 
> 1) the ID of your tag library is the plug-in ID defining it + the ID you  
> declare. So, the correct ID for your library is: 
> 
> your-plugin-id-goes-here.de.wendland.jet2.xtags 
> 
> 2) JET does some magic to execute a JET transformation/plug-in that  
> resides in your workspace. But there are limitations. The most important  
> is that JET will NOT load dependant plug-in projects (such as your tag  
> library). You have a couple of choices: 
> 
> a) install the tag library plug-in in your workbench 
> b) run/test your JET transformation from a runtime workbench (which is  
> configured with the JET tag library and JET plug-ins) 
> c) define the tag library directly in the JET plug-in. 
> 
> 3) The tagFactory attribute is optional. Declaring it (and implementing it  
> properly) can improve performance when you are creating lots of tags. 
> 
> There is a JET transformation in the CVS repository that will create the  
> tag factory class, given a plugin.xml that defines a tag library. Here's  
> the CVS location. 
> 
>  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2t/org .eclipse.jet/transforms/org.eclipse.jet.transforms.tagfactor y/?root=Modeling_Project 
> 
> Paul 
>
 |  
 |  
  |   |   |   |  
| Re: Extending the JET2 TagLibrary [message #51236 is a reply to message #51211] | 
Tue, 30 September 2008 17:04   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Dear Paul, 
 
i realy appreciated your help. Now it works and it will be highlighted in  
the Editor. Thank you very, very much. But i think, further questions will  
came up soon. 
 
Timothy 
 
 
"Paul Elder" <pelder@ca.ibm.com> schrieb im Newsbeitrag  
news:gbtvbv$13e$1@build.eclipse.org... 
> Timothy: 
> 
> That the tag is being written out in the output is a sure sign that we  
> still haven't got the taglibrary id correct. 
> 
> Open META-INF/MANIFEST.MF in the plug-in project that defines the tag  
> library. In the Overview pane, note the value for 'ID'. The tag library id  
> is that value plus a period, plus the text 'dprTags'. 
> 
> 
> 
> Paul 
> 
> "Timothy Marc" <timothymarc@freenet.de> wrote in message  
> news:gbtluq$4mi$1@build.eclipse.org... 
>> Paul, 
>> sorry for bothering you, but even your variant doesn't work. The  
>> <dpr:computeOperationSignature /"> empty tag will always be written out  
>> as plaintext. 
>> I started the transformation from within a runtime workspace, using your  
>> suggestions concerning the extensions. 
>> Timothy 
>> 
>> "Paul Elder" <pelder@ca.ibm.com> schrieb im Newsbeitrag  
>> news:gbte7e$slj$1@build.eclipse.org... 
>>> In the plugin.xml for de.wendland.jet2.extensions, set the tag library  
>>> ID as: 
>>> 
>>> <extension point="org.eclipse.jet.tagLibraries"> 
>>> 
>>> <tagLibrary id="dprTags" 
>>> 
>>> name="Java2" standardPrefix="dpr" 
>>> tagFactory="de.wendland.tfh.se.jet2.extensions.Java2TagFactory "> 
>>> <emptyTag  
>>> class="de.wendland.tfh.se.jet2.extensions.GenerateOperationName " 
>>> name="computeOperationSignature" whenContainingLineIsEmpty="remove"> 
>>> <attribute name="operation" type="string" use="required"> 
>>> </attribute> 
>>> </emptyTag> 
>>> </tagLibrary> 
>>> </extension> 
>>> 
>>> In your JET project, reference the tag library as: 
>>> 
>>> <importLibrary autoImport="true"  
>>> id="de.wendland.jet2.extensions.dprTags" usePrefix="dpr"> 
>>> </importLibrary> 
>>> 
>>> Paul 
>>> 
>> 
>> 
> 
>
 |  
 |  
  |   
Goto Forum:
 
 Current Time: Mon Nov 03 22:57:51 EST 2025 
 Powered by  FUDForum. Page generated in 0.05241 seconds  
 |