Home » Archived » M2M (model-to-model transformation) » [QVTO] Running my first QVTO Transformation produces empty model, but why?
|
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #490919 is a reply to message #490909] |
Mon, 12 October 2009 11:45 |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
Hi Tassilo,
Use your metamodel package nsURI instead of ecore file location uri
in modeltype declarations.
You have to configure mapping of nsURI to corresponding ecore file in the
property page of your QVTO project. See 'QVT Properties/Metamodel mapping'.
At development time, your ecore files are not part of the global package
registry
visible to the QVTO compiler, but have to be involved using the mapping
mechanism
mentioned above.
Regards,
/Radek
On Mon, 12 Oct 2009 13:20:30 +0200, Tassilo Horn <thorn@fastmail.fm> wrote:
> Hi all,
>
> here's my transformation.
>
> --8<---------------cut here---------------start------------->8---
> modeltype Persons uses
> "platform:/resource/Persons/metamodel/Persons.ecore";
> modeltype Families uses
> "platform:/resource/Families/metamodel/Families.ecore";
>
> transformation Families2Persons(in src:Families, out dst:Persons);
>
> main() {
> src.objectsOfType(FamilyTree) -> map familyTree2Genealogy();
> }
>
> mapping FamilyTree::familyTree2Genealogy() : Genealogy {
> persons := self.members -> map member2Person();
> }
>
> query Member::familyName() : String {
> if (self.familyFather <> null) then return self.familyFather.lastName
> endif;
> if (self.familyMother <> null) then return self.familyMother.lastName
> endif;
> if (self.familySon <> null) then return self.familySon.lastName
> endif;
> if (self.familyDaughter <> null) then return
> self.familyDaughter.lastName
> endif;
> return 'NoName';
> }
>
> query Member::isFemale() : Boolean =
> self.familyMother <> null or self.familyDaughter <> null;
>
> mapping Member::member2Person() : Person
> disjuncts Member::member2Female, Member::member2Male {}
>
> mapping Member::member2Female() : Female
> when {self.isFemale();}
> {
> fullName := self.firstName + ' ' + self.familyName();
> }
>
> mapping Member::member2Male() : Male
> when {not self.isFemale();}
> {
> fullName := self.firstName + ' ' + self.familyName();
> }
> --8<---------------cut here---------------end--------------->8---
>
> When I run the transformation and specify an existing families model as
> input and a new persons model as output, the latter is mostly empty and
> not specific to the target metamodel.
>
> --8<---------------cut here---------------start------------->8---
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
> --8<---------------cut here---------------end--------------->8---
>
> Also the QVTO trace file contains any help what's wrong:
>
> --8<---------------cut here---------------start------------->8---
> <?xml version="1.0" encoding="UTF-8"?>
> <trace:Trace xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:trace="http:///www.eclipse.org/m2m/qvt/operational/trace.ecore"/>
> --8<---------------cut here---------------end--------------->8---
>
> There's no output in the Error Log, Problems or Console view, too.
>
> Here's the input model:
>
> --8<---------------cut here---------------start------------->8---
> <?xml version="1.0" encoding="UTF-8"?>
> <families:FamilyTree xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI" xmlns:families="http://families/1.0">
> <families father="//@members.1" mother="//@members.2"
> sons="//@members.3 //@members.4 //@members.5" daughters="//@members.0"
> lastName="Smith"/>
> <families father="//@members.5" mother="//@members.8"
> sons="//@members.7" daughters="//@members.6" lastName="Smith"/>
> <families father="//@members.9" mother="//@members.10"
> daughters="//@members.8 //@members.11 //@members.12" lastName="Carter"/>
> <members firstName="Stella" familyDaughter="//@families.0"/>
> <members firstName="Steve" familyFather="//@families.0"/>
> <members firstName="Stephanie" familyMother="//@families.0"/>
> <members firstName="Stu" familySon="//@families.0"/>
> <members firstName="Sven" familySon="//@families.0"/>
> <members firstName="Dennis" familyFather="//@families.1"
> familySon="//@families.0"/>
> <members firstName="Diana" familyDaughter="//@families.1"/>
> <members firstName="Doug" familySon="//@families.1"/>
> <members firstName="Debby" familyMother="//@families.1"
> familyDaughter="//@families.2"/>
> <members firstName="Chris" familyFather="//@families.2"/>
> <members firstName="Christy" familyMother="//@families.2"/>
> <members firstName="Carol" familyDaughter="//@families.2"/>
> <members firstName="Conzuela" familyDaughter="//@families.2"/>
> </families:FamilyTree>
> --8<---------------cut here---------------end--------------->8---
>
> So there is one FamilyTree with many members. So I think the output
> model should have one Genealogy + Females and Males according to my
> mappings.
>
> How do I debug what's going wrong?
>
> Bye,
> Tassilo
|
|
|
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #491013 is a reply to message #490919] |
Mon, 12 October 2009 19:20 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
"radek dvorak" <dvorak.radek@gmail.com> writes:
Hi Radek,
> Use your metamodel package nsURI instead of ecore file location uri in
> modeltype declarations.
> You have to configure mapping of nsURI to corresponding ecore file in
> the property page of your QVTO project. See 'QVT Properties/Metamodel
> mapping'.
Ok, now I have
Source Model URI | Target Model URI
---------------------+----------------------------------
http://families/1.0 | platform:/.../Families.ecore
http://persons/1.0 | platform:/.../Persons.ecore
and use the modeltype definitions
modeltype Persons uses "http://persons/1.0";
modeltype Families uses "http://families/1.0";
in the transformation. In the Run Configuration, the source and target
model are specified as platform:/... URIs.
In the meantime I also found out about the log() function, so I added
some outputs to main() and all mappings.
--8<---------------cut here---------------start------------->8---
main() {
log("Starting Transformation...");
log("FamilyTree", src.objectsOfType(FamilyTree));
src.objectsOfType(FamilyTree) -> map familyTree2Genealogy();
log("Finished...");
}
mapping FamilyTree::familyTree2Genealogy() : Genealogy {
log("In FamilyTree::familyTree2Genealogy() : Genealogy");
persons := self.members -> map member2Person();
}
--8<---------------cut here---------------end--------------->8---
Unfortunately, the second log() outputs "data: []" and the mapping is
never executed, although there's one FamilyTree in the source model I
specified in the Run Config. So I guess I'm still doing something
wrong...
I'm really sorry to keep asking those boring questions, but I cannot
find some documentation about how to setup all the infrastructural
stuff. So feel free to scream "RTFM at URL" at me. :-)
Again, thanks a lot!
Tassilo
|
|
|
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #491317 is a reply to message #491013] |
Wed, 14 October 2009 06:52 |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
On Mon, 12 Oct 2009 21:20:44 +0200, Tassilo Horn <thorn@fastmail.fm> wrote:
> "radek dvorak" <dvorak.radek@gmail.com> writes:
>
> Hi Radek,
>
>> Use your metamodel package nsURI instead of ecore file location uri in
>> modeltype declarations.
>> You have to configure mapping of nsURI to corresponding ecore file in
>> the property page of your QVTO project. See 'QVT Properties/Metamodel
>> mapping'.
>
> Ok, now I have
>
> Source Model URI | Target Model URI
> ---------------------+----------------------------------
> http://families/1.0 | platform:/.../Families.ecore
> http://persons/1.0 | platform:/.../Persons.ecore
>
> and use the modeltype definitions
>
> modeltype Persons uses "http://persons/1.0";
> modeltype Families uses "http://families/1.0";
>
> in the transformation. In the Run Configuration, the source and target
> model are specified as platform:/... URIs.
>
> In the meantime I also found out about the log() function, so I added
> some outputs to main() and all mappings.
>
> --8<---------------cut here---------------start------------->8---
> main() {
> log("Starting Transformation...");
> log("FamilyTree", src.objectsOfType(FamilyTree));
> src.objectsOfType(FamilyTree) -> map familyTree2Genealogy();
> log("Finished...");
> }
>
> mapping FamilyTree::familyTree2Genealogy() : Genealogy {
> log("In FamilyTree::familyTree2Genealogy() : Genealogy");
> persons := self.members -> map member2Person();
> }
> --8<---------------cut here---------------end--------------->8---
>
> Unfortunately, the second log() outputs "data: []" and the mapping is
> never executed, although there's one FamilyTree in the source model I
> specified in the Run Config. So I guess I'm still doing something
> wrong...
>
> I'm really sorry to keep asking those boring questions, but I cannot
> find some documentation about how to setup all the infrastructural
> stuff. So feel free to scream "RTFM at URL" at me. :-)
>
> Again, thanks a lot!
> Tassilo
|
|
|
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #491320 is a reply to message #491013] |
Wed, 14 October 2009 07:04 |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
Hi Tassilo,
I suspect that your configuration mix the generated Java metamodel with
the one in workspace, though having the same identity they result in
different
EPackage instances. One resolved by QVTO parser and the other referenced
by your input
model.
Could you post the XMI of your input model
or your QVTO project skeleton if it's not confidential?
PS: Sorry for the empty post sent by mistake ;-)
Regards,
/Radek
On Mon, 12 Oct 2009 21:20:44 +0200, Tassilo Horn <thorn@fastmail.fm> wrote:
> "radek dvorak" <dvorak.radek@gmail.com> writes:
>
> Hi Radek,
>
>> Use your metamodel package nsURI instead of ecore file location uri in
>> modeltype declarations.
>> You have to configure mapping of nsURI to corresponding ecore file in
>> the property page of your QVTO project. See 'QVT Properties/Metamodel
>> mapping'.
>
> Ok, now I have
>
> Source Model URI | Target Model URI
> ---------------------+----------------------------------
> http://families/1.0 | platform:/.../Families.ecore
> http://persons/1.0 | platform:/.../Persons.ecore
>
> and use the modeltype definitions
>
> modeltype Persons uses "http://persons/1.0";
> modeltype Families uses "http://families/1.0";
>
> in the transformation. In the Run Configuration, the source and target
> model are specified as platform:/... URIs.
>
> In the meantime I also found out about the log() function, so I added
> some outputs to main() and all mappings.
>
> --8<---------------cut here---------------start------------->8---
> main() {
> log("Starting Transformation...");
> log("FamilyTree", src.objectsOfType(FamilyTree));
> src.objectsOfType(FamilyTree) -> map familyTree2Genealogy();
> log("Finished...");
> }
>
> mapping FamilyTree::familyTree2Genealogy() : Genealogy {
> log("In FamilyTree::familyTree2Genealogy() : Genealogy");
> persons := self.members -> map member2Person();
> }
> --8<---------------cut here---------------end--------------->8---
>
> Unfortunately, the second log() outputs "data: []" and the mapping is
> never executed, although there's one FamilyTree in the source model I
> specified in the Run Config. So I guess I'm still doing something
> wrong...
>
> I'm really sorry to keep asking those boring questions, but I cannot
> find some documentation about how to setup all the infrastructural
> stuff. So feel free to scream "RTFM at URL" at me. :-)
>
> Again, thanks a lot!
> Tassilo
|
|
| |
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #491360 is a reply to message #491354] |
Wed, 14 October 2009 10:32 |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
Hi,
You have to decide which metamodel you want to reference.
Your input model references its metamodel by nsURI, resolved
via the global package registry in your running platform instance.
If you want to develop the metamodel and QVTO transformation in workspace
at the same time, you also have to create a dynamic instance of your model
(see EMF),
which references the metamodel ecore file.
See the example bellow, a dynamic instance in
org.eclipse.m2m.qvt.oml.mmodel.urimap:
<?xml version="1.0" encoding="ASCII"?>
<uriMap:MappingContainer xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:uriMap="http:///www.eclipse.org/m2m/qvt/oml/MModelUriMap/1.0.0"
xsi:schemaLocation="http:///www.eclipse.org/m2m/qvt/oml/MModelUriMap/1.0.0
MModelURIMap.ecore"/>
see the difference against the package registry based one, you have posted
(xsi:schemaLocation).
If your metamodel is always installed in the platform global package
registry,
you do not need to setup a metamodel mapping and can directly use the
metamodel's
nsURI in the modeltype declaration. In your case "http://families/1.0".
It's all the trick and is more or less EMF basics, not QVTO.
Just see where the QVTO editor hyperlinks on a metamodel reference
navigates within
the metamodel browser and check what you reference in your models.
Regards,
/Radek
> This is the source model:
>
> --8<---------------cut here---------------start------------->8---
> <?xml version="1.0" encoding="UTF-8"?>
> <families:FamilyTree xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI" xmlns:families="http://families/1.0">
> <families father="//@members.1" mother="//@members.2"
> sons="//@members.3 //@members.4 //@members.5" daughters="//@members.0"
> lastName="Smith"/>
> <families father="//@members.5" mother="//@members.8"
> sons="//@members.7" daughters="//@members.6" lastName="Smith"/>
> <families father="//@members.9" mother="//@members.10"
> daughters="//@members.8 //@members.11 //@members.12" lastName="Carter"/>
> <members firstName="Stella" familyDaughter="//@families.0"/>
> <members firstName="Steve" familyFather="//@families.0"/>
> <members firstName="Stephanie" familyMother="//@families.0"/>
> <members firstName="Stu" familySon="//@families.0"/>
> <members firstName="Sven" familySon="//@families.0"/>
> <members firstName="Dennis" familyFather="//@families.1"
> familySon="//@families.0"/>
> <members firstName="Diana" familyDaughter="//@families.1"/>
> <members firstName="Doug" familySon="//@families.1"/>
> <members firstName="Debby" familyMother="//@families.1"
> familyDaughter="//@families.2"/>
> <members firstName="Chris" familyFather="//@families.2"/>
> <members firstName="Christy" familyMother="//@families.2"/>
> <members firstName="Carol" familyDaughter="//@families.2"/>
> <members firstName="Conzuela" familyDaughter="//@families.2"/>
> </families:FamilyTree>
> --8<---------------cut here---------------end--------------->8---
>
> And this is the contents of org.eclipse.m2m.qvt.oml.mmodel.urimap in the
> .settings folder. I hope that's what you meant with "project skeleton".
>
> --8<---------------cut here---------------start------------->8---
> <?xml version="1.0" encoding="ASCII"?>
> <uriMap:MappingContainer xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:uriMap="http:///www.eclipse.org/m2m/qvt/oml/MModelUriMap/1.0.0">
> <mapping sourceURI="http://families/1.0"
> targetURI="platform:/resource/Families/metamodel/Families.ecore "/>
> <mapping sourceURI="http://persons/1.0"
> targetURI="platform:/resource/Persons/metamodel/Persons.ecore "/>
> </uriMap:MappingContainer>
> --8<---------------cut here---------------end--------------->8---
>
> Beside that, there's only the .project file declaring the QVTO nature,
> and the transformation itself in transforms/Families2Persons.qvto.
>
|
|
|
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #494126 is a reply to message #490909] |
Thu, 29 October 2009 10:06 |
Baptiste Mesta Messages: 31 Registered: September 2009 |
Member |
|
|
Hi!
I think I have a problem similar to Tassilo's but I'm running the script in a Eclipse RCP by invoking it through java code.
My problem is the same: when i run the script while giving him an non empty EObject it return me an empty resource and it seems that it is not finding my objects because the .rootObjects return an empty array. here is my main method of the qvto script:
transformation Form2Xhtml(in form : FORM, out xhtml : Xhtml);
main() {
log ("entering main",form,1);
log ("roots",form.rootObjects(),1);
log ("all",form.objects(),1);
form.rootObjects()[FORM::Form]->map form2Xhtml();
log ("exiting main",form,1);
}
i used the code from here to invoke it:
http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava
the code below seems to compile and execute my qvto file correctly:
ExecutionDiagnostic result = executor.execute(context, input, output);
even if it can find anything in my object
also there is the transformation in my plugin.xml:
<extension
point="org.eclipse.m2m.qvt.oml.runtime.qvtTransformation">
<transformation
file="transforms/Form2Xhtml.qvto"
id="org.my.plugin.form2xhtml">
<input
metaclass="form/Form"
metamodel="http://my.rcp/ns/form">
</input>
<output
metaclass="xhtml/DocumentRoot"
metamodel="http://www.w3.org/1999/xhtml">
</output>
</transformation>
</extension>
i have the same namespace in the xmi of my input model.
where should i look to solve this?
Thanks in advance for any advices you can give me
Baptiste Mesta
http://www.bonitasoft.com/
|
|
|
Re: [QVTO] Running my first QVTO Transformation produces empty model, but why? [message #494159 is a reply to message #494126] |
Thu, 29 October 2009 12:21 |
Eclipse User |
|
|
|
Originally posted by: dvorak.radek.gmail.com
Hi Baptiste,
If 'form.rootObjects()' gives an empty collection, you must have passed an
empty input.
If 'form.rootObjects()[FORM::Form]' gives an empty collection, it's most
likely caused
by different instances of the same metamodel referenced by your input
model and the QVTO
transf. This typically happens when using dynamic models. See newsgroup
for that topic.
The invocation API does not solve this issue in the Galileo release, but
we have fixed this
for Helios, where you can pass your custom EPackage.Registry that keeps
metamodels to be
used by QVTO transformation.
You can try the 3.0.0M2 build at
http://www.eclipse.org/modeling/download.php?file=/modeling/ m2m/qvtoml/downloads/drops/3.0.0/S200909301018/m2m-qvtoml-Up date-3.0.0M2.zip
Regards,
/Radek
On Thu, 29 Oct 2009 11:06:37 +0100, Baptiste Mesta
<baptiste.mesta@gmail.com> wrote:
> Hi!
>
> I think I have a problem similar to Tassilo's but I'm running the script
> in a Eclipse RCP by invoking it through java code.
>
> My problem is the same: when i run the script while giving him an non
> empty EObject it return me an empty resource and it seems that it is not
> finding my objects because the .rootObjects return an empty array. here
> is my main method of the qvto script:
> transformation Form2Xhtml(in form : FORM, out xhtml : Xhtml);
>
> main() {
> log ("entering main",form,1);
>
> log ("roots",form.rootObjects(),1);
> log ("all",form.objects(),1);
>
> form.rootObjects()[FORM::Form]->map form2Xhtml();
> log ("exiting main",form,1);
> }
>
> i used the code from here to invoke it:
> http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava
>
> the code below seems to compile and execute my qvto file correctly:
> ExecutionDiagnostic result = executor.execute(context, input, output);
> even if it can find anything in my object
> also there is the transformation in my plugin.xml:
> <extension
> point="org.eclipse.m2m.qvt.oml.runtime.qvtTransformation">
> <transformation
> file="transforms/Form2Xhtml.qvto"
> id="org.my.plugin.form2xhtml">
> <input
> metaclass="form/Form"
> metamodel="http://my.rcp/ns/form">
> </input>
> <output
> metaclass="xhtml/DocumentRoot"
> metamodel="http://www.w3.org/1999/xhtml">
> </output>
> </transformation>
> </extension>
>
> i have the same namespace in the xmi of my input model.
>
> where should i look to solve this?
>
> Thanks in advance for any advices you can give me :)
>
>
>
>
>
|
|
| |
Goto Forum:
Current Time: Sun Jan 26 09:38:40 GMT 2025
Powered by FUDForum. Page generated in 0.04383 seconds
|