Hello,
I have some models (of Meta-Model A) which partly refer to each other (for example: An element is in model A1, but its children are in model A2). I would like to transfer this into Meta-Model B using ATL. In my opinion, the result should look like this:
<ObjectType Name="myObjectType" id="1002">
<reference IsForward="false" hasSource="//@ObjectType.0" hasTarget="../basemodel/BaseModel.modelb#//@ObjectTypes/@ObjectType.0"/>
</reference>
...
</ObjectType>
For this purpose I have defined the following rules:
create OUT: ModelB from IN: ModelA, BaseModel: ModelB;
rule ObjectTypeRule {
from
input: ModelA!ObjectType
to
output: ModelB!ObjectType (
Id <- input.Id,
...
reference <:= input.References.reference -> collect(e | thisModule.
ReferenceRule(e, input))
)
}
lazy rule ReferenceRule {
from
ref: ModelA!Reference, parent: ModelB!ObjectType
to
output: ModelB!Reference (
IsForward <- ref.IsForward,
hasSource <- parent,
hasTraget <- ModelB!ObjectType.allInstances()-> select(
e |
if e.Id.oclIsUndefined() then
false
else
e.ID.endsWith(ref.Value)
endif
).first()
)
}
But the result of the rule is now, however, as follows:
<ObjectType Name="myObjectType" id="1002">
<reference IsForward="false" hasSource="//@ObjectType.0">
<hasTarget href="../basemodel/Basemodel.modelb#//@ObjectTypes/@ObjectType.0"/>
</reference>
...
</ObjectType>
Can anyone see what is causing this problem and how I can solve it?
Thank you very much
S.Friedl