Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » ATL collection and Iteration error?
ATL collection and Iteration error? [message #875807] Wed, 23 May 2012 06:54 Go to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
Hi there,


Input file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi=".../XMI" xmlns="source">
<DeviceList>
<DeviceItem
Name="PSSuniversal22222"
DeviceCommReference= "001417C3-00000003-001417B3-00000002-00112001-0000013A"
DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">

<ModuleList>
<ModuleItem
Name="PSSu E F PS (PROFIsafe)"
IsSelected="false"
ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}">
</ModuleItem>
<ModuleItem
Name="PSSuES4DO0.5_1"
ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107">
</ModuleItem>
<ModuleItem
Name="PSSuES4DO0.5_2"
ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108">
</ModuleItem>

</ModuleList>

</DeviceItem>

</DeviceList>

</xmi:XMI>



Output file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi=".../XMI" xmlns="target">
<Device name="PSSuniversal22222">
<Module name="PSSu E F PS (PROFIsafe)" s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"/>
<Module name="PSSuES4DO0.5_1" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"/>
<Module name="PSSuES4DO0.5_2" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"/>
</Device>
<Device name="PSSuniversal22222">
<Module name="PSSu E F PS (PROFIsafe)" s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"/>
<Module name="PSSuES4DO0.5_1" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"/>
<Module name="PSSuES4DO0.5_2" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"/>
</Device>
<Device name="PSSuniversal22222">
<Module name="PSSu E F PS (PROFIsafe)" s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"/>
<Module name="PSSuES4DO0.5_1" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"/>
<Module name="PSSuES4DO0.5_2" s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"/>
</Device>
</xmi:XMI>



ATL program:
-- @path source=file:/C:/.../source.ecore
-- @path target=file:/C:/.../target.ecore

module tpf3;
create OUT : target from IN : source;

rule Rule_DeviceT{
from
a: source!DeviceItem,
c:source!ModuleItem
to
p:target!Device(
name <- a.Name,
Module<-a.ModuleList.ModuleItem->collect(e|thisModule.Rule_ModuleT(e))
)
}


lazy rule Rule_ModuleT{
from
b:source!ModuleItem

to
d:target!Module(
name <- b.Name,
s7ModuleReference <- b.ModuleReference
)
}


Problem: How to remove the data repetition in output file? This is because something wrong with "Module<-a.ModuleList.ModuleItem->collect(e|thisModule.Rule_ModuleT(e))" in the ATL file. Can someone support me to solve this issue?

Thanks in advance.
Kosala
Re: ATL collection and Iteration error? [message #875821 is a reply to message #875807] Wed, 23 May 2012 07:35 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
HI

You have posted this to the ATL newsgroup. Please refrain from spamming
others.

Regards

Ed Willink

On 23/05/2012 11:54, Kosala Yapa wrote:
> Hi there,
>
>
> Input file:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi=".../XMI" xmlns="source">
> <DeviceList>
> <DeviceItem Name="PSSuniversal22222" DeviceCommReference=
> "001417C3-00000003-001417B3-00000002-00112001-0000013A"
> DeviceReference="{7F6AC5F1-E8E0-49E5-ABA1-26E4A6A74175}{001417C3-00000003-001417B3-00000002-00112001-00000107}{SD_example1}">
>
> <ModuleList>
> <ModuleItem Name="PSSu E F PS (PROFIsafe)"
> IsSelected="false"
> ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}">
> </ModuleItem>
> <ModuleItem Name="PSSuES4DO0.5_1"
> ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107">
> </ModuleItem>
> <ModuleItem Name="PSSuES4DO0.5_2"
> ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108">
> </ModuleItem>
>
> </ModuleList>
>
> </DeviceItem>
> </DeviceList>
>
> </xmi:XMI>
>
>
>
> Output file:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi=".../XMI" xmlns="target">
> <Device name="PSSuniversal22222">
> <Module name="PSSu E F PS (PROFIsafe)"
> s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"/>
> <Module name="PSSuES4DO0.5_1"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"/>
> <Module name="PSSuES4DO0.5_2"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"/>
> </Device>
> <Device name="PSSuniversal22222">
> <Module name="PSSu E F PS (PROFIsafe)"
> s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"/>
> <Module name="PSSuES4DO0.5_1"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"/>
> <Module name="PSSuES4DO0.5_2"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"/>
> </Device>
> <Device name="PSSuniversal22222">
> <Module name="PSSu E F PS (PROFIsafe)"
> s7ModuleReference="{9A856DAC-1D0A-46F7-B69F-40E2DC6511DD}{001417C5-0000002F-001417C3-0000002A-00112001-00000107}{SD_example1}"/>
> <Module name="PSSuES4DO0.5_1"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000107"/>
> <Module name="PSSuES4DO0.5_2"
> s7ModuleReference="CFAF3ED5-37E4-476B-AE64-94FDD6429D1E}{001417C5-00000009-001417C3-00000003-00112001-00000108"/>
> </Device>
> </xmi:XMI>
>
>
>
> ATL program:
> -- @path source=file:/C:/.../source.ecore
> -- @path target=file:/C:/.../target.ecore
>
> module tpf3;
> create OUT : target from IN : source;
>
> rule Rule_DeviceT{
> from
> a: source!DeviceItem,
> c:source!ModuleItem
> to
> p:target!Device(
> name <- a.Name,
>
> Module<-a.ModuleList.ModuleItem->collect(e|thisModule.Rule_ModuleT(e))
> )
> }
>
>
> lazy rule Rule_ModuleT{
> from
> b:source!ModuleItem
>
> to
> d:target!Module(
> name <- b.Name,
> s7ModuleReference <- b.ModuleReference
> )
> }
>
>
> Problem: How to remove the data repetition in output file? This is
> because something wrong with
> "Module<-a.ModuleList.ModuleItem->collect(e|thisModule.Rule_ModuleT(e))"
> in the ATL file. Can someone support me to solve this issue?
>
> Thanks in advance.
> Kosala
Previous Topic:Acceleo with my Metamodel
Next Topic:Creating an Eclipse Builder with Xpand
Goto Forum:
  


Current Time: Thu Jul 31 15:51:24 EDT 2014

Powered by FUDForum. Page generated in 0.02307 seconds