multi-reference transformation problem [message #689768] |
Tue, 28 June 2011 10:13 |
Emwedish Endargachew Messages: 27 Registered: April 2011 |
Junior Member |
|
|
Dear All,
I am currently writing a code to make model transformation using ATL. What is currently happening is that, when i try to make transformation which has multiple references, where one classes references to the other class which the other class also is referenced to the other class, and my situation is i have to keep the references respectively. During this transformation, i am getting the following result on my xmi target model,
<attributeTypes attributeType="/0/@types"/> where attributeTypes contains a reference to AttributeType, However the content to the class AttributeType is listed out of the intended class. And btw i do not know where "/0/@types"/ comes from and what it means. The other issue is when i make transformation, there are some attributes which does not show up at the result, and i do not know the reason why they do not show up at the target model. Is there any one who is getting same outputs? Please share what happened and how did solve it. Let me give u the code i am using to make the transformation
rule transfor1
{
from i: XML!Element(i.name = 'XX')
to o: Model2!classA(
attributeTypes <- atypes,
types <- i.children ->select(c|c.oclIsKindOf(XML!Element)) -> asSequence()
),
atypes:Model2!AttributeTypes(
attributeType <- i.children -> select(c|c.oclIsKindOf(XML!Element) ->asSequence()
)
}
rule Types
{
from i:XML!Element(i.name = 'Types')
to o:Model2!Types(
xx <- i.children ->select(c|c.oclIsKindOf(XML!Element) -> asSequence(), --reference
yy <- i.children ->select(c|c.oclIsKindOf(XML!Element) -> asSequence() --this is another reference
)
}
rule AttributeType
{
from i:XML!Element(i.name = 'AttributeType')
to o:Model2!AttributeType(
name <- i.getAttrVal('name'), --- this is an attribute
rr <- i.children -> select(c|c.oclIsKindOf(XML!Element)) -> asSequence --this is another reference
)
}
and the output i am getting is:
<XML:classA>
<type>
<xx/>
<yy/>
</type>
<attributeTypes attributeType="/0/@types"/>
</XML:classA>
<XML:AttributeType name="SDVA"/>
does "/0/@types" mean it is referenced to the last line which is XML:AttributeType name = "SDVA" ? I am not sure how data, nodes and stuff are organized but my guess is that if it was the right one it would have been like
<XML:classA>
<type>
<xx/>
<yy/>
</type>
<attributeTypes>
<AttributeType name="SDVA"/>
<AttributeTypes/>
</XML:classA>
I need it very badly, please help if there is someone with the same problem.
Thanks in advance
|
|
|
Re: multi-reference transformation problem [message #689974 is a reply to message #689768] |
Tue, 28 June 2011 16:42 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 28/06/2011 3:13 AM, Emwedish wrote:
> Dear All,
> I am currently writing a code to make model transformation using ATL.
> What is currently happening is that, when i try to make transformation
> which has multiple references, where one classes references to the
> other class which the other class also is referenced to the other
> class, and my situation is i have to keep the references respectively.
> During this transformation, i am getting the following result on my
> xmi target model, <attributeTypes attributeType="/0/@types"/> where
> attributeTypes contains a reference to AttributeType, However the
> content to the class AttributeType is listed out of the intended
> class. And btw i do not know where "/0/@types"/ comes from and what it
> means.
It's path to navigate the first object at the root of the same resource
and then to the types reference of that object.
> The other issue is when i make transformation, there are some
> attributes which does not show up at the result, and i do not know the
> reason why they do not show up at the target model. Is there any one
> who is getting same outputs? Please share what happened and how did
> solve it. Let me give u the code i am using to make the transformation
>
> rule transfor1
> {
> from i: XML!Element(i.name = 'XX')
> to o: Model2!classA(
> attributeTypes <- atypes,
> types <- i.children ->select(c|c.oclIsKindOf(XML!Element)) ->
> asSequence()
>
> ),
> atypes:Model2!AttributeTypes(
> attributeType <- i.children ->
> select(c|c.oclIsKindOf(XML!Element) ->asSequence() )
>
> }
>
> rule Types
> {
> from i:XML!Element(i.name = 'Types')
> to o:Model2!Types(
> xx <- i.children ->select(c|c.oclIsKindOf(XML!Element) ->
> asSequence(), --reference
> yy <- i.children ->select(c|c.oclIsKindOf(XML!Element) ->
> asSequence() --this is another reference
> )
> }
>
> rule AttributeType
> {
> from i:XML!Element(i.name = 'AttributeType')
> to o:Model2!AttributeType(
> name <- i.getAttrVal('name'), --- this is an attribute
> rr <- i.children -> select(c|c.oclIsKindOf(XML!Element)) ->
> asSequence --this is another reference
> )
> }
>
> and the output i am getting is:
> <XML:classA>
> <type>
> <xx/>
> <yy/>
> </type>
> <attributeTypes attributeType="/0/@types"/>
> </XML:classA>
> <XML:AttributeType name="SDVA"/>
>
> does "/0/@types" mean it is referenced to the last line which is
> XML:AttributeType name = "SDVA" ? I am not sure how data, nodes and
> stuff are organized but my guess is that if it was the right one it
> would have been like
> <XML:classA>
> <type>
> <xx/>
> <yy/>
> </type>
> <attributeTypes>
> <AttributeType name="SDVA"/>
> <AttributeTypes/>
> </XML:classA>
>
>
> I need it very badly, please help if there is someone with the same
> problem.
> Thanks in advance
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10171 seconds