Home » Archived » M2M (model-to-model transformation) » [ATL]about "inject XML file to XML model(Ecore based)"
[ATL]about "inject XML file to XML model(Ecore based)" [message #47492] |
Tue, 19 June 2007 08:11  |
Eclipse User |
|
|
|
Hi,
With help of AM3 pluglins, I can tramsform a xml filt to xml model by
invoking context memu "inject XML file to XML model(Ecore based)" in AM3
perspective.
Now the question is how to do this transformation programmatically?
Are there any APIs for transforming a XML file to XML model?
Thanks
stephen
|
|
| | |
Re: [ATL]about "inject XML file to XML model(Ecore based)" [message #47684 is a reply to message #47524] |
Wed, 20 June 2007 00:10   |
Eclipse User |
|
|
|
Hello,
That's a great util class. Thanks.
However, I'm confused by the "transformOnetoOther(String InputOneFile,
String OutputOtherFile)" sample method.
For example, I have Model_A which confirms to MetaModel_A,
and Model_B which confirms to MetaModel_B, and I have model_a.xml
represents source Model_A.
I also need the metamodel for XML which is XML.ecore, and how about the
xxx.atl for the transformation? Do I need to write atl file for
XML-->Model_B or for Model_A--->Model_B?
I tried both of them, but failed.
if I create another ATL project and copy the output of "inject xml file to
xml model" and write a transformation file for XML--->Model_A, it works.
What do I do wrongly?
[by debuging the code, I found "inject xml file to xml model" is
successfull.]
However,
Milan Milanovic wrote:
> Hi,
> you can use ATLTransformations class which have support for injecting XML
> file
> into the XML model (and vice-versa).
>
http://wiki.eclipse.org/index.php/ATL_Howtos#How_do_I_launch _transformations_programmatically.3F
> --
> Best regards, Milan Milanovic
> Stephen Yu wrote:
>> Hi,
>> With help of AM3 pluglins, I can tramsform a xml filt to xml model by
>> invoking context memu "inject XML file to XML model(Ecore based)" in AM3
>> perspective.
>> Now the question is how to do this transformation programmatically?
>> Are there any APIs for transforming a XML file to XML model?
>> Thanks
>> stephen
|
|
|
Re: [ATL]about "inject XML file to XML model(Ecore based)" [message #47771 is a reply to message #47684] |
Wed, 20 June 2007 07:21   |
Eclipse User |
|
|
|
Originally posted by: milan.milanovic.org
Hi,
Stephen Yu wrote:
> Hello,
> That's a great util class. Thanks.
> However, I'm confused by the "transformOnetoOther(String InputOneFile,
> String OutputOtherFile)" sample method.
Well, I'm not sure what is the problem, class is well documented and easy
to use. This method accepts input file for your transformation and output
file which is created on the end of the transformation process.
> For example, I have Model_A which confirms to MetaModel_A,
> and Model_B which confirms to MetaModel_B, and I have model_a.xml
> represents source Model_A.
Yes, model_a.xml is the first parameter in the transformOnetoOther method
(or
however you call it), and you can put e.g., model_b.xml as second parameter
for output file. Then you need to change method getOtherMMFromOneMM to
accepts
your input and output (meta)models. Metamodels you define as objects in
top of the class and XML metamodel is already defined. Then you change
getOtherMMFromOneMM method, e.g., getModelBFromModelA(ModelA) {
where modelA is e.g., input XML model injected from model_a.xml by using
injectXMLModelFromFile method (shown as example in transformOnetoOther
method)
return runATLTransformation(mdramh, urlToYourTransformationASM, ModelA,
MetaModel_A_MDR, MetaModel_B_MDR, Collections.EMPTY_MAP,
Collections.EMPTY_MAP);
The return of this method call is transformed model.
> I also need the metamodel for XML which is XML.ecore,
You have this already defined in class and library, xmlMDRmm for MDR and
xmlEMFmm object for EMF.
> and how about the
> xxx.atl for the transformation? Do I need to write atl file for
> XML-->Model_B or for Model_A--->Model_B?
Yes, of course.
> I tried both of them, but failed.
> if I create another ATL project and copy the output of "inject xml file to
> xml model" and write a transformation file for XML--->Model_A, it works.
> What do I do wrongly?
Well, you did something wrong.
> [by debuging the code, I found "inject xml file to xml model" is
> successfull.]
> However,
--
Milan
> Milan Milanovic wrote:
>> Hi,
>> you can use ATLTransformations class which have support for injecting XML
>> file
>> into the XML model (and vice-versa).
>>
>
http://wiki.eclipse.org/index.php/ATL_Howtos#How_do_I_launch _transformations_programmatically.3F
>> --
>> Best regards, Milan Milanovic
>> Stephen Yu wrote:
>>> Hi,
>>> With help of AM3 pluglins, I can tramsform a xml filt to xml model by
>>> invoking context memu "inject XML file to XML model(Ecore based)" in AM3
>>> perspective.
>>> Now the question is how to do this transformation programmatically?
>>> Are there any APIs for transforming a XML file to XML model?
>>> Thanks
>>> stephen
|
|
|
Re: [ATL]about "inject XML file to XML model(Ecore based)" [message #47801 is a reply to message #47771] |
Wed, 20 June 2007 23:37   |
Eclipse User |
|
|
|
Hi,
I'm still confused by the atl file and the metamodel for source model.
I
Milan Milanovic wrote:
> Hi,
> Stephen Yu wrote:
>> Hello,
>> That's a great util class. Thanks.
>> However, I'm confused by the "transformOnetoOther(String InputOneFile,
>> String OutputOtherFile)" sample method.
> Well, I'm not sure what is the problem, class is well documented and easy
> to use. This method accepts input file for your transformation and output
> file which is created on the end of the transformation process.
>> For example, I have Model_A which confirms to MetaModel_A,
>> and Model_B which confirms to MetaModel_B, and I have model_a.xml
>> represents source Model_A.
> Yes, model_a.xml is the first parameter in the transformOnetoOther method
> (or
> however you call it), and you can put e.g., model_b.xml as second parameter
> for output file. Then you need to change method getOtherMMFromOneMM to
> accepts
> your input and output (meta)models. Metamodels you define as objects in
> top of the class and XML metamodel is already defined. Then you change
> getOtherMMFromOneMM method, e.g., getModelBFromModelA(ModelA) {
> where modelA is e.g., input XML model injected from model_a.xml by using
> injectXMLModelFromFile method (shown as example in transformOnetoOther
> method)
> return runATLTransformation(mdramh, urlToYourTransformationASM, ModelA,
> MetaModel_A_MDR, MetaModel_B_MDR, Collections.EMPTY_MAP,
~~~~~~~~~~~~~~~~~~Should it be the metaModel of XML?
at begining, I have following files: sourceModle.xml, XML.ecore (metamodel
for XML), targetMetaModel.ecore, sourceMetaModel.ecore
step one: inject xml file to xml modle (ecore base), So I get another
file: sourceModel.ecore
step two:
there are two problems:
1)When I call
runATLTransformation(emfanh,url4tranformationASM,sourceModel ,[which
metamodel to pass in? sourceMetamodel or XML
metamodel?],targetMetaModel,MetaModel_B_MDR, Collections.EMPTY_MAP),
If I pass in sourceMetaModel and write a ATL file for transformation
sourceModel data to target model, it does not work, I tested within ATL
plugin.
But if I pass in XML metaModel and write a ATL file for transformation XML
data to targetModel, it works.
2)another problem is that to I have to save the output (ASMModel) from
injectXMLModelFromFile(File file) and then load it from the saved file to
the ASMModel, otherwise, the following transformation does not work.
I'm really confused by these stuff.
> Collections.EMPTY_MAP);
> The return of this method call is transformed model.
>> I also need the metamodel for XML which is XML.ecore,
> You have this already defined in class and library, xmlMDRmm for MDR and
> xmlEMFmm object for EMF.
>> and how about the
>> xxx.atl for the transformation? Do I need to write atl file for
>> XML-->Model_B or for Model_A--->Model_B?
> Yes, of course.
>> I tried both of them, but failed.
>> if I create another ATL project and copy the output of "inject xml file to
>> xml model" and write a transformation file for XML--->Model_A, it works.
>> What do I do wrongly?
> Well, you did something wrong.
>> [by debuging the code, I found "inject xml file to xml model" is
>> successfull.]
>> However,
> --
> Milan
>> Milan Milanovic wrote:
>>> Hi,
>>> you can use ATLTransformations class which have support for injecting XML
>>> file
>>> into the XML model (and vice-versa).
>>>
>>
>
http://wiki.eclipse.org/index.php/ATL_Howtos#How_do_I_launch _transformations_programmatically.3F
>>> --
>>> Best regards, Milan Milanovic
>>> Stephen Yu wrote:
>>>> Hi,
>>>> With help of AM3 pluglins, I can tramsform a xml filt to xml model by
>>>> invoking context memu "inject XML file to XML model(Ecore based)" in AM3
>>>> perspective.
>>>> Now the question is how to do this transformation programmatically?
>>>> Are there any APIs for transforming a XML file to XML model?
>>>> Thanks
>>>> stephen
|
|
|
Re: [ATL]about "inject XML file to XML model(Ecore based)" [message #47891 is a reply to message #47801] |
Thu, 21 June 2007 06:39  |
Eclipse User |
|
|
|
Originally posted by: milan.milanovic.org
Hi,
Stephen Yu wrote:
> Hi,
> I'm still confused by the atl file and the metamodel for source model.
> I
> Milan Milanovic wrote:
>> Hi,
>> Stephen Yu wrote:
>>> Hello,
>>> That's a great util class. Thanks.
>>> However, I'm confused by the "transformOnetoOther(String InputOneFile,
>>> String OutputOtherFile)" sample method.
>> Well, I'm not sure what is the problem, class is well documented and easy
>> to use. This method accepts input file for your transformation and output
>> file which is created on the end of the transformation process.
>>> For example, I have Model_A which confirms to MetaModel_A,
>>> and Model_B which confirms to MetaModel_B, and I have model_a.xml
>>> represents source Model_A.
>> Yes, model_a.xml is the first parameter in the transformOnetoOther method
>> (or
>> however you call it), and you can put e.g., model_b.xml as second parameter
>> for output file. Then you need to change method getOtherMMFromOneMM to
>> accepts
>> your input and output (meta)models. Metamodels you define as objects in
>> top of the class and XML metamodel is already defined. Then you change
>> getOtherMMFromOneMM method, e.g., getModelBFromModelA(ModelA) {
>> where modelA is e.g., input XML model injected from model_a.xml by using
>> injectXMLModelFromFile method (shown as example in transformOnetoOther
>> method)
>> return runATLTransformation(mdramh, urlToYourTransformationASM, ModelA,
>> MetaModel_A_MDR, MetaModel_B_MDR, Collections.EMPTY_MAP,
> ~~~~~~~~~~~~~~~~~~Should it be the metaModel of XML?
If you are running transformation XML 2 SomeMetaModel then yes.
> at begining, I have following files: sourceModle.xml, XML.ecore (metamodel
> for XML), targetMetaModel.ecore, sourceMetaModel.ecore
If you are using EMF as model handler, then for XML injection you need to
change in the injectXMLModelFromFile method, mdramh to emfamh, and xmlMDRmm
to xmlEMFmm.
> step one: inject xml file to xml modle (ecore base), So I get another
> file: sourceModel.ecore
> step two:
> there are two problems:
> 1)When I call
> runATLTransformation(emfanh,url4tranformationASM,sourceModel ,[which
> metamodel to pass in? sourceMetamodel or XML
> metamodel?],targetMetaModel,MetaModel_B_MDR, Collections.EMPTY_MAP),
You have documentation for this method (java doc) with this class. You can
see (and also in comment above this method) that you need to put first
input model,
and then in subsequent parameter a input metamodel. If you are running XML
2 SomeMetaModel transformation, then inputMetaModel is XML metamodel
(i.e., xmlEMFmm).
> If I pass in sourceMetaModel and write a ATL file for transformation
> sourceModel data to target model, it does not work, I tested within ATL
> plugin.
> But if I pass in XML metaModel and write a ATL file for transformation XML
> data to targetModel, it works.
Do you want to say than XML 2 SomeMetaModel transformation works, but not
SomeMetaModel 2 SomeOtherMetaModel doesn't ?
> 2)another problem is that to I have to save the output (ASMModel) from
> injectXMLModelFromFile(File file) and then load it from the saved file to
> the ASMModel, otherwise, the following transformation does not work.
No, you don't have to do this. When you inject XML model with
injectXMLModelFromFile method, then you have an ASMModel that can be
inputModel for runATLTransformation method.
> I'm really confused by these stuff.
--
Best regards, Milan Milanovic
>> Collections.EMPTY_MAP);
>> The return of this method call is transformed model.
>>> I also need the metamodel for XML which is XML.ecore,
>> You have this already defined in class and library, xmlMDRmm for MDR and
>> xmlEMFmm object for EMF.
>>> and how about the
>>> xxx.atl for the transformation? Do I need to write atl file for
>>> XML-->Model_B or for Model_A--->Model_B?
>> Yes, of course.
>>> I tried both of them, but failed.
>>> if I create another ATL project and copy the output of "inject xml file to
>>> xml model" and write a transformation file for XML--->Model_A, it works.
>>> What do I do wrongly?
>> Well, you did something wrong.
>>> [by debuging the code, I found "inject xml file to xml model" is
>>> successfull.]
>>> However,
>> --
>> Milan
>>> Milan Milanovic wrote:
>>>> Hi,
>>>> you can use ATLTransformations class which have support for injecting XML
>>>> file
>>>> into the XML model (and vice-versa).
>>>>
>>>
>>
>
http://wiki.eclipse.org/index.php/ATL_Howtos#How_do_I_launch _transformations_programmatically.3F
>>>> --
>>>> Best regards, Milan Milanovic
>>>> Stephen Yu wrote:
>>>>> Hi,
>>>>> With help of AM3 pluglins, I can tramsform a xml filt to xml model by
>>>>> invoking context memu "inject XML file to XML model(Ecore based)" in AM3
>>>>> perspective.
>>>>> Now the question is how to do this transformation programmatically?
>>>>> Are there any APIs for transforming a XML file to XML model?
>>>>> Thanks
>>>>> stephen
|
|
|
Goto Forum:
Current Time: Mon May 05 09:20:46 EDT 2025
Powered by FUDForum. Page generated in 0.06155 seconds
|