Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Getting Started.
[QVTO] Getting Started. [message #100265] Wed, 18 February 2009 16:21 Go to next message
Klioutchnikov is currently offline KlioutchnikovFriend
Messages: 1
Registered: July 2009
Junior Member
Hello,

I'm new to vqt. I'm trying to run a (very) simple transformation of an
ecore model to another ecore model. I'm sorry to bother with that newbe
issue, but i already spent some time on it and have no clue how to resolve
it.

Here are my models:
---------------------------------------------------------
input model:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="input"
nsURI="http://dot.com/input/1.0" nsPrefix="input">
<eClassifiers xsi:type="ecore:EClass" name="InputModel">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="element"
upperBound="-1"
eType="#//Element" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Element"/>
</ecore:EPackage>
------------------------------------------------------------
output model:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="output"
nsURI="http://dot.com/output/1.0" nsPrefix="output">
<eClassifiers xsi:type="ecore:EClass" name="OutputModel">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="box"
upperBound="-1" eType="#//Box"
containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Box"/>
</ecore:EPackage>
------------------------------------------------------------

And the transformation looks like that:

------------------------------------------------------------ -
modeltype IN uses 'platform:/resource/input/model/input.ecore';
modeltype OUT uses 'platform:/resource/output/model/output.ecore';

transformation TransformationSample(in imodel : IN, out OUT);

main() {
imodel.rootObjects()[IN::InputModel] ->map model2model();
}

mapping IN::InputModel::model2model() : OUT::OutputModel {

name := self.name;
box := self.getElements()->map simple2annotated()->asOrderedSet();
}

mapping IN::Element::simple2annotated () : OUT::Box {
}

query IN::InputModel::getElements() : OrderedSet(IN::Element) {
return self.element[IN::Element]->asOrderedSet()
}
------------------------------------------------------------ -------

I'm not sure my model2model() mapping is correct, but even if I comment
it's code, my transformation should at least produce an instance of the
output.ecore meta-model with at least a OutputModel EClass in it. And this
is not the case:

Input instance:

------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<input:InputModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:input="http://dot.com/input/1.0" name="Names">
<element/>
<element/>
</input:InputModel>
------------------------------------

output result instance:

------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
------------------------------------

The result is even not an instance of the output meta-model.

If you have an idea on what i'm doing wrong, i'd be very much appreciate.
Thank you in advance.
Re: [QVTO] Getting Started. [message #100308 is a reply to message #100265] Thu, 19 February 2009 10:53 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Alexei,

There is no guarantee that your output will always contain an object which
is
instance of a class of your out metamodel, unless you create it.

Your mapping looks fine, but I suspect the input selection query to give
no input objects,

imodel.rootObjects()[IN::InputModel]

as the transf refers to a type which is not identical to the one in your
input model.

Your input and output seem to contain instances of the java generated
metamodels
while your transf refers to metamodels by location of the corresponding
ecore files.

I suggest you refer to metamodels by identity, using the nsURI attribute
value
modeltype IN uses 'http://dot.com/input/1.0';
modeltype OUT uses 'http://dot.com/output/1.0';

and add mapping of nsURI to location URI at the following property page of
your
QVT project - 'QVT Settings/Metamodel mappings'.

By doing so, you will have your transf resolve to ecore files in
development time,
while in deployment time the generated metamodels will used.

Regards,
/Radek


On Wed, 18 Feb 2009 17:21:29 +0100, Alexei
<alexei.klioutchnikov@gmail.com> wrote:

> Hello,
>
> I'm new to vqt. I'm trying to run a (very) simple transformation of an
> ecore model to another ecore model. I'm sorry to bother with that newbe
> issue, but i already spent some time on it and have no clue how to
> resolve it.
>
> Here are my models:
> ---------------------------------------------------------
> input model:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="input"
> nsURI="http://dot.com/input/1.0" nsPrefix="input">
> <eClassifiers xsi:type="ecore:EClass" name="InputModel">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="element"
> upperBound="-1"
> eType="#//Element" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Element"/>
> </ecore:EPackage>
> ------------------------------------------------------------
> output model:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="output"
> nsURI="http://dot.com/output/1.0" nsPrefix="output">
> <eClassifiers xsi:type="ecore:EClass" name="OutputModel">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="box"
> upperBound="-1" eType="#//Box"
> containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Box"/>
> </ecore:EPackage>
> ------------------------------------------------------------
>
> And the transformation looks like that:
>
> ------------------------------------------------------------ -
> modeltype IN uses 'platform:/resource/input/model/input.ecore';
> modeltype OUT uses 'platform:/resource/output/model/output.ecore';
>
> transformation TransformationSample(in imodel : IN, out omodel : OUT);
>
> main() {
> imodel.rootObjects()[IN::InputModel] ->map model2model();
> }
>
> mapping IN::InputModel::model2model() : OUT::OutputModel {
>
> name := self.name;
> box := self.getElements()->map simple2annotated()->asOrderedSet();
> }
>
> mapping IN::Element::simple2annotated () : OUT::Box {
> }
>
> query IN::InputModel::getElements() : OrderedSet(IN::Element) {
> return self.element[IN::Element]->asOrderedSet()
> }
> ------------------------------------------------------------ -------
>
> I'm not sure my model2model() mapping is correct, but even if I comment
> it's code, my transformation should at least produce an instance of the
> output.ecore meta-model with at least a OutputModel EClass in it. And
> this is not the case:
>
> Input instance:
>
> ------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <input:InputModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:input="http://dot.com/input/1.0" name="Names">
> <element/>
> <element/>
> </input:InputModel>
> ------------------------------------
>
> output result instance:
>
> ------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
> ------------------------------------
>
> The result is even not an instance of the output meta-model.
>
> If you have an idea on what i'm doing wrong, i'd be very much appreciate.
> Thank you in advance.
>
Previous Topic:[QVTO] Applying stereotypes to out uml model
Next Topic:[QVTO] inter-model references
Goto Forum:
  


Current Time: Thu Apr 18 21:17:20 GMT 2024

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

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

Back to the top