Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL collection and Iteration ?
ATL collection and Iteration ? [message #875817] Wed, 23 May 2012 11:24 Go to next message
Kosala Yapa is currently offline Kosala YapaFriend
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 ? [message #875854 is a reply to message #875817] Wed, 23 May 2012 13:00 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
You're matchin on a pair of elements.
You have 1 DeviceItem and 3 ModuleItem, thus you enter the Rule_DeviceT three times, each time with a different ModuleItem that you don't even use.

Just change the "from" section of the rule by matching only on the DeviceItem.
Re: ATL collection and Iteration ? [message #875891 is a reply to message #875854] Wed, 23 May 2012 14:00 Go to previous message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Many thanks Sylvain. sorted out !
Previous Topic:[ATL] referencing to element created from a lazy rule
Next Topic:Revive public to private
Goto Forum:
  


Current Time: Fri Dec 19 14:30:00 GMT 2014

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

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