[ATL] How to transform a Model contain in a XML document [message #41329] |
Thu, 24 May 2007 13:47 |
Eclipse User |
|
|
|
Originally posted by: erik_becker.gmx.de
Hi,
After having reproduced the Starter Guide I tried to make my own
transformation of a model specified by a normal XML document (no XMI).
And surprise, surprise it unfortunately doesn't work. ;-)
I'm think my problem is that I haven't really understood what I 've to
do with the input XML to be able to read it with ATL Tools.
Here's what I did:
0) Create xml document for model (input.xml)
1) Created a meta model (e.g. input.km3) for the input model / the XML
document with KM3.
2) Produced a Ecore model (e.g. input.ecore) from the KM3
3) Created a meta model for the output model (e.g. output.km3)
4) Produced a Ecore model (e.g. output.ecore) from the KM3
5) Wrote an atl file.
6) Created a 'Lunch Configuration': IN -> input.xml (MM input)
OUT -> output.xml (MM output)
7) Run
I've I do so I get an error message that the transformation failed.
I tried already to 'Inject XML file to XML model' with the input XML.
Now the error message disappeared, but it doesn' t work as well, because
only my called entrypoint rule is executed.
If I understood correct that because now my input XML is in the form of
the XML meta model used in ATL and there a no matching elements found.
Is that right?
What is to do transform a model in XML to another?
What I'm doing wrong?
How do get a ATL readable model form the XML specifying my model?
Thanks & Regards
Erik
|
|
|
Re: [ATL] How to transform a Model contain in a XML document [message #41391 is a reply to message #41329] |
Thu, 24 May 2007 14:05 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
> After having reproduced the Starter Guide I tried to make my own
> transformation of a model specified by a normal XML document (no XMI).
>
> And surprise, surprise it unfortunately doesn't work. ;-)
.... yet ;-).
> I'm think my problem is that I haven't really understood what I 've to
> do with the input XML to be able to read it with ATL Tools.
Yes, it seems so. But you seem to have understood the problem (i.e.,
injecting an XML document results in a model conforming to the XML
metamodel). You just have not found the solution yet. But your are
lucky: I am giving it to you below ;-).
> Here's what I did:
> 0) Create xml document for model (input.xml)
> 1) Created a meta model (e.g. input.km3) for the input model / the XML
> document with KM3.
> 2) Produced a Ecore model (e.g. input.ecore) from the KM3
> 3) Created a meta model for the output model (e.g. output.km3)
> 4) Produced a Ecore model (e.g. output.ecore) from the KM3
> 5) Wrote an atl file.
> 6) Created a 'Lunch Configuration': IN -> input.xml (MM input)
> OUT -> output.xml (MM output)
> 7) Run
>
> I've I do so I get an error message that the transformation failed.
This is normal, because the launch configuration only lets you use XMI
files as input.
BTW, I was wondering what a "Lunch Configuration" could be. Is this a
menu that you find in a restaurant? ;-)
> I tried already to 'Inject XML file to XML model' with the input XML.
> Now the error message disappeared, but it doesn' t work as well, because
> only my called entrypoint rule is executed.
> If I understood correct that because now my input XML is in the form of
> the XML meta model used in ATL and there a no matching elements found.
> Is that right?
Exactly. Your injected XMI file contains a model conforming to the XML
metamodel.
> What is to do transform a model in XML to another?
> What I'm doing wrong?
> How do get a ATL readable model form the XML specifying my model?
You just need to write an ATL transformation ;-).
For instance:
module XML2MyMM;
create OUT : MyMM from IN : XML;
rule Test {
from
s : XML!Element (
s.name = 'test'
)
to
t : MyMM!Test (
name <- s.getAttrVal('name')
)
}
where getAttrVal would be a helper that gets the value of an attribute
of an XML!Element.
The following Howto entry highlights the main points and links to
examples about dealing with XML files:
http://wiki.eclipse.org/index.php/ATL_Howtos#How_can_I_handl e_arbitrary_XML_documents.3F
Please, feel free to contribute to it if you feel it is not detailed
enough yet ;-).
Best regards,
Frédéric Jouault
|
|
|
Re: [ATL] How to transform a Model contain in a XML document [message #41598 is a reply to message #41391] |
Fri, 25 May 2007 08:33 |
Eclipse User |
|
|
|
Originally posted by: erik_becker.gmx.de
Hi Frédéric,
thanks for your answer. Unfortunately it's not that easy as hoped.
The XML document I want to transform is nested and quite complex.
I decided to transform its as instance of the XML meta model instead to
transform it first into 'My meta model', but this is really difficult.
Isn't there another possibility to get a ATL-readable version of a XML
document?
While my explorations I encountered some problems:
1) I want to create a structure in my target model which is like this:
<Package ..>
<WorkflowProcesses>
<WorkflowProcess ...> </WorkflowProcess>
<WorkflowProcess ...> </WorkflowProcess>
...
</WorkflowProcesses>
</Package>
I thought if I bind WorkflowProcess elements to a reference
WorkflowProcess this would work. Unfortunately it don't. I get something
like this ...
<Package ..>
<WorkflowProcesses ..> </WorkflowProcesses>
<WorkflowProcesses ..> </WorkflowProcesses>
...
</Package>
2) As you my already know I create an instance of the XPDL MM form the
Atlantic zoo. The output of my transformation looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns="XPDL" ..>
...
</Package>
I expected to receive something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="XPDL">
<Package ..>
...
</Package>
Additionally I get an empty XML document if I use the XML extractor to
create a XML form my traget model. What I'm doing wrong?
Thanks and Greetings
Erik
|
|
|
|
Powered by
FUDForum. Page generated in 0.02847 seconds