Home » Modeling » M2T (model-to-text transformation) » JET: navigating to references for EMF-models
|
Re: JET: navigating to references for EMF-models [message #61292 is a reply to message #61221] |
Fri, 15 May 2009 13:32 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Usul wrote:
> snip...
> In my template, that works: <c:get select="//car[1]/@name" /> .
>
> But that does not work: - <c:get select="//car[2]/wheels[1]/@name" />
>
> So how can I navigate to instances, which are references by EReference
> in the metamodel? Do I maybe have to let JET know the .ecore metamodel
> somehow? Or is there no easy way to navigate and I misunderstood the
> tutorial?
>
My guess is that JET did not find your .ecore model. When JET attempts
to load an EMF model, it uses the file extension to search in the EMF
Resource.Factory.Registry.INSTANCE to find a resource factory. Factories
specify to individual file extensions can be registered via the
org.eclipse.emf.ecore.extension_parser extension point.
But, for ECore models serialized as XMI (such as yours), this is often
unnecessary. If a extension specific factory is not found, JET will use
a generic XMI resource factory.
The generic XMI resource factory looks that the namespace URI in your
model, and attempts to find it in the EPackage.Registry.INSTANCE. If
you have generated Java code form your .ecore model (and that plug-in is
installed), your package is registered.
But, if your .ecore model is 'under development', and lives in your
workspace along with your JET transformation, then EMF will not find the
namespace URI in the Package registry. In that case, EMF make use of XSI
schema location information in the root element in the document.
<carpool:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:carpool="http://de/tuberlin/swt/car.ecore"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://de/tuberlin/swt/car.ecore
your-location-for-car.ecore"
>
Failing all this, I think EMF may just treat the XMI as a plan XML document.
What happens if you evaluate:
<c:get select="//car[2]/@wheels" />
If you are getting a result, then that's an indication that the .ecore
package information wasn't found.
Hope this helps,
Paul
|
|
|
Re: JET: navigating to references for EMF-models [message #62410 is a reply to message #61292] |
Tue, 09 June 2009 15:42 |
Miguel Angel Garcia de Dios Messages: 22 Registered: July 2009 |
Junior Member |
|
|
Hi everyone,
I am try to apply your solution, I mean, I have my gui.ecore model and,
after de classical process of generating code automatically and
launching it as an Eclipse Application, I also have generated my
bank.gui model (which is an instance of my gui.ecore built sing the
generated editor). Now, in that Eclipse aplication launched from my
original Eclipse. When i launch the JET Transformation, I set bank.gui
as transformation input and I receive this message:
"Error: Feature 'version' not found.
(platform:/resource/jet.example/models/bank.gui, 2, 146)"
The XMI file of my model instance is this:
<?xml version="1.0" encoding="UTF-8"?>
<gui:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gui="http://gui/1.0">
<allWidgets xsi:type="gui:Window" label="MainMenuWindow"
widgetActions="//@allGActions.0" contained="//@allWidgets.2
//@allWidgets.3 //@allWidgets.1"/>
<allWidgets xsi:type="gui:Button" label="UserMenuMainMenuButton"
widgetEvents="//@allEvents.0" container="//@allWidgets.0"/>
<allWidgets xsi:type="gui:Button" label="AccountMenuMainMenuButton"
widgetEvents="//@allEvents.1" container="//@allWidgets.0"/>
<allWidgets xsi:type="gui:Button" label="ExitMainMenuButton"
widgetEvents="//@allEvents.2" container="//@allWidgets.0"/>
<allWidgets xsi:type="gui:Window" label="UserMenuWindow"
widgetActions="//@allGActions.1 //@allGActions.2"
contained="//@allWidgets.8 //@allWidgets.5 //@allWidgets.7
//@allWidgets.6"/>
<allWidgets xsi:type="gui:Button" label="CreateUserUserMenuButton"
widgetEvents="//@allEvents.3" container="//@allWidgets.4"/>
<allWidgets xsi:type="gui:Button" label="EditUserUserMenuButton"
widgetEvents="//@allEvents.4" container="//@allWidgets.4"/>
<allWidgets xsi:type="gui:Button" label="DeleteUserUserMenuButton"
widgetEvents="//@allEvents.5" container="//@allWidgets.4"/>
<allWidgets xsi:type="gui:Button" label="BackUserMenuButton"
widgetEvents="//@allEvents.6" container="//@allWidgets.4"/>
<allWidgets xsi:type="gui:Window" label="CreateUserWindow"
widgetActions="//@allGActions.3 //@allGActions.4"
contained="//@allWidgets.12 //@allWidgets.10 //@allWidgets.11"/>
<allWidgets xsi:type="gui:Button"
label="CreateCashierCreateUserButton" widgetEvents="//@allEvents.7"
container="//@allWidgets.9"/>
<allWidgets xsi:type="gui:Button"
label="CreateClientCreateUserButton" widgetEvents="//@allEvents.8"
container="//@allWidgets.9"/>
<allWidgets xsi:type="gui:Button" label="BackCreateUserButton"
widgetEvents="//@allEvents.9" container="//@allWidgets.9"/>
<allWidgets xsi:type="gui:Window" label="CreateCashierWindow"
widgetActions="//@allGActions.9 //@allGActions.10"
contained="//@allWidgets.17 //@allWidgets.16 //@allWidgets.14
//@allWidgets.15"/>
....
Thank you
Paul Elder wrote:
>
>
> Usul wrote:
>> snip...
>
>> In my template, that works: <c:get select="//car[1]/@name" /> .
>>
>> But that does not work: - <c:get select="//car[2]/wheels[1]/@name" />
>>
>> So how can I navigate to instances, which are references by EReference
>> in the metamodel? Do I maybe have to let JET know the .ecore
>> metamodel somehow? Or is there no easy way to navigate and I
>> misunderstood the tutorial?
>>
>
> My guess is that JET did not find your .ecore model. When JET attempts
> to load an EMF model, it uses the file extension to search in the EMF
> Resource.Factory.Registry.INSTANCE to find a resource factory. Factories
> specify to individual file extensions can be registered via the
> org.eclipse.emf.ecore.extension_parser extension point.
>
> But, for ECore models serialized as XMI (such as yours), this is often
> unnecessary. If a extension specific factory is not found, JET will use
> a generic XMI resource factory.
>
> The generic XMI resource factory looks that the namespace URI in your
> model, and attempts to find it in the EPackage.Registry.INSTANCE. If
> you have generated Java code form your .ecore model (and that plug-in is
> installed), your package is registered.
>
> But, if your .ecore model is 'under development', and lives in your
> workspace along with your JET transformation, then EMF will not find the
> namespace URI in the Package registry. In that case, EMF make use of XSI
> schema location information in the root element in the document.
>
> <carpool:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:carpool="http://de/tuberlin/swt/car.ecore"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://de/tuberlin/swt/car.ecore
> your-location-for-car.ecore"
> >
>
> Failing all this, I think EMF may just treat the XMI as a plan XML
> document.
>
> What happens if you evaluate:
> <c:get select="//car[2]/@wheels" />
>
> If you are getting a result, then that's an indication that the .ecore
> package information wasn't found.
>
> Hope this helps,
>
> Paul
|
|
|
Goto Forum:
Current Time: Thu Sep 19 13:26:31 GMT 2024
Powered by FUDForum. Page generated in 0.04725 seconds
|