Home » Archived » M2M (model-to-model transformation) » ATL Tranformation of XML
| |
Re: ATL Tranformation of XML [message #98381 is a reply to message #98352] |
Mon, 26 January 2009 14:50 |
Michael Igler Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hello Freddy,
I am closer to the solution, but not yet there.
The OUTPUT of the rule
rule svh2subject
{
from s: SDW!"SDW-svh"
to r : RTR!"RTR-subject"
(
name <- s.name,
description <- s.description,
"RTR-attribute" <- Set {o} -- changed it
),
o : RTR!"RTR-attribute"
(
name <- s.name
)
}
IS:
<RTR-subject xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR" name="KND"
description="Kunde">
<RTR-attribute name="KND"/>
</RTR-subject>
But I need as many RTR-attributes inside the RTR-subject as in the SDW-svh.
The METAMODELS are:
package RTR
{
class "RTR-subject"
{
attribute name : String;
attribute description : String;
reference "RTR-attribute"[*] container : "RTR-attribute";
}
class "RTR-attribute"
{
attribute name : String;
attribute alter : String;
attribute optional : String;
attribute dataType : String;
attribute dataLength : String;
}
}
package PrimitiveTypes
{
datatype String;
}
AND
package SDW
{
class "SDW-svh"
{
attribute name : String;
attribute description : String;
reference "SDW-attribute"[*] container : "SDW-attribute";
}
class "SDW-attribute"
{
attribute name : String;
attribute alter : String;
attribute optional : String;
attribute dataType : String;
attribute dataLength : String;
}
}
package PrimitiveTypes
{
datatype String;
}
Thanx,
Mike
Freddy Allilaire wrote:
> Hi Michael,
> ATL doesn't manage XMI serialisation of your model. This is done by "EMF
> XMI writer/reader". So you cannot tune by default XML/XMI serialisation.
> But in your case to have your expected result, it seems to miss the
> containment reference between "RTR-subject" and "RTR-attribute".
> I don't know your metamodel but it should be something like this:
> rule svh2subject {
> from s: SDW!"SDW-svh"
> to r : RTR!"RTR-subject" (
> name <- s.name,
> description <- s.description,
> attributes <- Set {o} -- new line added
> ),
> o : RTR!"RTR-attribute" (
> name <- s.name
> )
> }
> HTH
> Regards,
> Freddy.
> Michael Igler a écrit :
>> Hello,
>>
>> I'd like to to a XML Tranformation with ATL. Modeled my things in KM3
>> and injected everything.
>> Now I do the transformation in an ATL file, but I do not get a nested
>> XML Element:
>>
>> Here are my ruels:
>>
>> module SDW2RTR;
>> create OUT : RTR from IN : SDW;
>>
>> rule svh2subject
>> {
>> from s: SDW!"SDW-svh"
>>
>> to r : RTR!"RTR-subject"
>> (
>> name <- s.name,
>> description <- s.description
>> ),
>>
>> o : RTR!"RTR-attribute"
>> (
>> name <- s.name
>>
>> )
>> }
>>
>>
>>
>> The output is:
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <xmi:XMI xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR">
>> <RTR-subject name="KND" description="Kunde"/>
>> <RTR-attribute name="KND"/>
>> </xmi:XMI>
>>
>>
>>
>> BUT WHAT I NEED IS:
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <xmi:XMI xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR">
>> <RTR-subject name="KND" description="Kunde">
>> <RTR-attribute name="KND"/>
>> <RTR-subject>
>> </xmi:XMI>
>>
>>
>>
>> Thanks for your help and I hope I am right in this group,
>>
>> Mike
>>
>>
>>
>>Hi Freddy
|
|
| |
Re: ATL Tranformation of XML [message #98527 is a reply to message #98468] |
Tue, 27 January 2009 15:18 |
Michael Igler Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hello Freddy,
that's it. Thanx.
I could extend my models and comprehend now more how it works.
The next (hope simple) problem that occurs:
I want 2 RTR-control elements per SDW-attribute with different naming in
the
name <- s.name of RTR!"RTR-control" - rule: The second has a special
string prefix.
Is that possible?
I have extended the RTR as following:
package RTR
{
class "RTR-subject"
{
attribute name : String;
attribute description : String;
reference "RTR-attribute"[*] container : "RTR-subject-attribute";
}
class "RTR-subject-attribute"
{
attribute name : String;
attribute alter : String;
attribute optional : String;
attribute dataType : String;
attribute dataLength : String;
}
class "RTR-control"
{
attribute name : String;
attribute type : String;
attribute description : String;
attribute attributeReference : String;
attribute dataType : String;
attribute dataLength : String;
}
}
AND the ATL-file:
module SDW2RTR; -- Module Template
create OUT : RTR from IN : SDW;
rule svh2subject
{
from s: SDW!"SDW-svh"
to r : RTR!"RTR-subject"
(
name <- s.name,
description <- s.description,
"RTR-attribute" <- s."SDW-attribute"
)
}
rule attribute2attribute
{
from s : SDW!"SDW-attribute"
to r : RTR!"RTR-subject-attribute"
(
name <- s.name,
alter <- s.alter,
optional <- s.optional,
dataType <- s.dataType,
dataLength <- s.dataLength
),
k : RTR!"RTR-control"
(
name <- s.name,
type <- 'Edit',
description <- '',
attributeReference <- '',
dataType <- s.dataType,
dataLength <- s.dataLength
)
}
Many thanks for helping,
Mike
Freddy Allilaire wrote:
> Hi Mike,
> Ok so you need to transform each SDW-attribute in RTR-attribute.
> You can try the following transformation:
> rule svh2subject {
> from s: SDW!"SDW-svh"
> to r : RTR!"RTR-subject" (
> name <- s.name,
> description <- s.description,
> "RTR-attribute" <- s."SDW-attribute"
> )
> }
> rule attribute2attribute {
> from s : SDW!"SDW-attribute"
> to r : RTR!"RTR-attribute" (
> name <- s.name
> )
> }
> Regards,
> Freddy.
> Michael Igler a écrit :
>> Hello Freddy,
>>
>> I am closer to the solution, but not yet there.
>>
>> The OUTPUT of the rule
>>
>> rule svh2subject {
>> from s: SDW!"SDW-svh"
>> to r : RTR!"RTR-subject" (
>> name <- s.name,
>> description <- s.description,
>> "RTR-attribute" <- Set {o} -- changed it
>> ),
>> o : RTR!"RTR-attribute" (
>> name <- s.name
>> )
>> }
>>
>> IS:
>>
>> <RTR-subject xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR" name="KND"
>> description="Kunde">
>> <RTR-attribute name="KND"/>
>> </RTR-subject>
>>
>> But I need as many RTR-attributes inside the RTR-subject as in the SDW-svh.
>>
>>
>> The METAMODELS are:
>>
>> package RTR
>> {
>> class "RTR-subject"
>> {
>> attribute name : String;
>> attribute description : String;
>> reference "RTR-attribute"[*] container : "RTR-attribute";
>> }
>>
>> class "RTR-attribute" {
>> attribute name : String;
>> attribute alter : String;
>> attribute optional : String;
>> attribute dataType : String;
>> attribute dataLength : String;
>> }
>> }
>>
>> package PrimitiveTypes
>> {
>> datatype String;
>> }
>>
>>
>>
>> AND
>>
>>
>> package SDW
>> {
>> class "SDW-svh"
>> {
>> attribute name : String;
>> attribute description : String;
>> reference "SDW-attribute"[*] container : "SDW-attribute";
>> }
>>
>>
>> class "SDW-attribute" {
>> attribute name : String;
>> attribute alter : String;
>> attribute optional : String;
>> attribute dataType : String;
>> attribute dataLength : String;
>> }
>> }
>>
>> package PrimitiveTypes
>> {
>> datatype String;
>> }
>>
>> Thanx,
>>
>> Mike
>>
>>
>> Freddy Allilaire wrote:
>>
>>> Hi Michael,
>>
>>> ATL doesn't manage XMI serialisation of your model. This is done by
>>> "EMF XMI writer/reader". So you cannot tune by default XML/XMI
>>> serialisation.
>>
>>> But in your case to have your expected result, it seems to miss the
>>> containment reference between "RTR-subject" and "RTR-attribute".
>>
>>> I don't know your metamodel but it should be something like this:
>>
>>> rule svh2subject {
>>> from s: SDW!"SDW-svh"
>>> to r : RTR!"RTR-subject" (
>>> name <- s.name,
>>> description <- s.description,
>>> attributes <- Set {o} -- new line added
>>> ),
>>> o : RTR!"RTR-attribute" (
>>> name <- s.name
>>> )
>>> }
>>
>>> HTH
>>
>>> Regards,
>>> Freddy.
>>
>>> Michael Igler a écrit :
>>>> Hello,
>>>>
>>>> I'd like to to a XML Tranformation with ATL. Modeled my things in KM3
>>>> and injected everything.
>>>> Now I do the transformation in an ATL file, but I do not get a nested
>>>> XML Element:
>>>>
>>>> Here are my ruels:
>>>>
>>>> module SDW2RTR;
>>>> create OUT : RTR from IN : SDW;
>>>>
>>>> rule svh2subject
>>>> {
>>>> from s: SDW!"SDW-svh"
>>>> to r : RTR!"RTR-subject"
>>>> (
>>>> name <- s.name,
>>>> description <- s.description
>>>> ),
>>>> o : RTR!"RTR-attribute"
>>>> (
>>>> name <- s.name )
>>>> }
>>>>
>>>>
>>>>
>>>> The output is:
>>>>
>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>> <xmi:XMI xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR">
>>>> <RTR-subject name="KND" description="Kunde"/>
>>>> <RTR-attribute name="KND"/>
>>>> </xmi:XMI>
>>>>
>>>>
>>>>
>>>> BUT WHAT I NEED IS:
>>>>
>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>> <xmi:XMI xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR">
>>>> <RTR-subject name="KND" description="Kunde">
>>>> <RTR-attribute name="KND"/>
>>>> <RTR-subject>
>>>> </xmi:XMI>
>>>>
>>>>
>>>>
>>>> Thanks for your help and I hope I am right in this group,
>>>>
>>>> Mike
>>>>
>>>>
>>>>
>>>> Hi Freddy
>>
|
|
|
Re: ATL Tranformation of XML [message #98571 is a reply to message #98527] |
Wed, 28 January 2009 09:56 |
Freddy Allilaire Messages: 130 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030704060705010303080403
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hi Mike,
You could extend your metamodel and transformation as follow:
Metamodel:
------------------------------------------
class "RTR-subject-attribute" {
attribute name : String;
attribute alter : String;
attribute optional : String;
attribute dataType : String;
attribute dataLength : String;
reference controls[0-2] container : "RTR-control";
}
------------------------------------------
Transformation
------------------------------------------
rule attribute2attribute {
from s : SDW!"SDW-attribute"
to r : RTR!"RTR-subject-attribute" (
name <- s.name,
alter <- s.alter,
optional <- s.optional,
dataType <- s.dataType,
dataLength <- s.dataLength,
controls <- Set {k1, k2}
),
k1 : RTR!"RTR-control" (
name <- 'Special_Prefix_1_' + s.name + '_Special_Suffix_1',
type <- 'Edit',
description <- '',
attributeReference <- '',
dataType <- s.dataType,
dataLength <- s.dataLength
),
k2 : RTR!"RTR-control" (
name <- 'Special_Prefix_2_' + s.name + '_Special_Suffix_2',
type <- 'Edit',
description <- '',
attributeReference <- '',
dataType <- s.dataType,
dataLength <- s.dataLength
)
}
------------------------------------------
Regards,
Freddy.
Michael Igler a
|
|
|
Re: ATL Tranformation of XML [message #98673 is a reply to message #98571] |
Thu, 29 January 2009 09:17 |
Michael Igler Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hello Freddy,
thanks for the code. I post you the XML that should come out:
<RTR>
...
<RTR-control name="KND_ident" type="Edit" description="ID"
attributeReference="/RTR-subject/KND/ident" dataType="str"
dataLength="80" />
<RTR-control name="KND_name" type="Edit" description="name"
attributeReference="/RTR-subject/KND/name" dataType="str"
dataLength="80" />
<RTR-control name="searchKND_ident" type="Edit" description="ID"
attributeReference="/RTR-subject/KND/ident" dataType="str"
dataLength="80" />
<RTR-control name="searchKND_name" type="Edit" description="name"
attributeReference="/RTR-subject/KND/name" dataType="str"
dataLength="80" />
...
The problem is, that RTR has no elements, only attributes and another
thing is that
I have no idea how to handle that beside the first two have KND_ as prefix
and the
second two have searchKND_ as prefix, the description is alternating (ID,
name, ID, name, ...)
Do you know how difficult it is to do the reverse, I mean coming from RTR
back to SDW again?
Read in the PDF's that only the rules have to be switched and the helpers
need to be adjusted (don't
have any at the moment).
Thanks,
Mike
Freddy Allilaire wrote:
> Hi Mike,
> You could extend your metamodel and transformation as follow:
> Metamodel:
> ------------------------------------------
> class "RTR-subject-attribute" {
> attribute name : String;
> attribute alter : String;
> attribute optional : String;
> attribute dataType : String;
> attribute dataLength : String;
> reference controls[0-2] container : "RTR-control";
> }
> ------------------------------------------
> Transformation
> ------------------------------------------
> rule attribute2attribute {
> from s : SDW!"SDW-attribute"
> to r : RTR!"RTR-subject-attribute" (
> name <- s.name,
> alter <- s.alter,
> optional <- s.optional,
> dataType <- s.dataType,
> dataLength <- s.dataLength,
> controls <- Set {k1, k2}
> ),
> k1 : RTR!"RTR-control" (
> name <- 'Special_Prefix_1_' + s.name + '_Special_Suffix_1',
> type <- 'Edit',
> description <- '',
> attributeReference <- '',
> dataType <- s.dataType,
> dataLength <- s.dataLength
> ),
> k2 : RTR!"RTR-control" (
> name <- 'Special_Prefix_2_' + s.name + '_Special_Suffix_2',
> type <- 'Edit',
> description <- '',
> attributeReference <- '',
> dataType <- s.dataType,
> dataLength <- s.dataLength
> )
> }
> ------------------------------------------
> Regards,
> Freddy.
> Michael Igler a écrit :
>> Hello Freddy,
>>
>> that's it. Thanx.
>>
>> I could extend my models and comprehend now more how it works.
>> The next (hope simple) problem that occurs:
>>
>> I want 2 RTR-control elements per SDW-attribute with different naming in
>> the
>> name <- s.name of RTR!"RTR-control" - rule: The second has a special
>> string prefix.
>> Is that possible?
>>
>>
>> I have extended the RTR as following:
>> package RTR
>> {
>> class "RTR-subject"
>> {
>> attribute name : String;
>> attribute description : String;
>> reference "RTR-attribute"[*] container :
>> "RTR-subject-attribute";
>> }
>>
>> class "RTR-subject-attribute" {
>> attribute name : String;
>> attribute alter : String;
>> attribute optional : String;
>> attribute dataType : String;
>> attribute dataLength : String;
>> }
>>
>> class "RTR-control"
>> {
>> attribute name : String;
>> attribute type : String;
>> attribute description : String;
>> attribute attributeReference : String;
>> attribute dataType : String;
>> attribute dataLength : String;
>> }
>> }
>>
>> AND the ATL-file:
>>
>> module SDW2RTR; -- Module Template
>> create OUT : RTR from IN : SDW;
>>
>> rule svh2subject {
>> from s: SDW!"SDW-svh"
>> to r : RTR!"RTR-subject" (
>> name <- s.name,
>> description <- s.description,
>> "RTR-attribute" <- s."SDW-attribute"
>> )
>> }
>>
>> rule attribute2attribute {
>> from s : SDW!"SDW-attribute"
>> to r : RTR!"RTR-subject-attribute" (
>> name <- s.name,
>> alter <- s.alter,
>> optional <- s.optional,
>> dataType <- s.dataType,
>> dataLength <- s.dataLength
>> ),
>> k : RTR!"RTR-control"
>> (
>> name <- s.name,
>> type <- 'Edit',
>> description <- '',
>> attributeReference <- '',
>> dataType <- s.dataType,
>> dataLength <- s.dataLength
>> )
>> }
>>
>> Many thanks for helping,
>>
>> Mike
>>
>>
>>
>> Freddy Allilaire wrote:
>>
>>> Hi Mike,
>>
>>> Ok so you need to transform each SDW-attribute in RTR-attribute.
>>
>>> You can try the following transformation:
>>
>>> rule svh2subject {
>>> from s: SDW!"SDW-svh"
>>> to r : RTR!"RTR-subject" (
>>> name <- s.name,
>>> description <- s.description,
>>> "RTR-attribute" <- s."SDW-attribute"
>>> )
>>> }
>>
>>> rule attribute2attribute {
>>> from s : SDW!"SDW-attribute"
>>> to r : RTR!"RTR-attribute" (
>>> name <- s.name
>>> )
>>> }
>>
>>> Regards,
>>> Freddy.
>>
>>> Michael Igler a écrit :
>>>> Hello Freddy,
>>>>
>>>> I am closer to the solution, but not yet there.
>>>>
>>>> The OUTPUT of the rule
>>>>
>>>> rule svh2subject {
>>>> from s: SDW!"SDW-svh"
>>>> to r : RTR!"RTR-subject" (
>>>> name <- s.name,
>>>> description <- s.description,
>>>> "RTR-attribute" <- Set {o} -- changed it
>>>> ),
>>>> o : RTR!"RTR-attribute" (
>>>> name <- s.name
>>>> )
>>>> }
>>>>
>>>> IS:
>>>>
>>>> <RTR-subject xmi:version="2.0"
>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR" name="KND"
>>>> description="Kunde">
>>>> <RTR-attribute name="KND"/>
>>>> </RTR-subject>
>>>>
>>>> But I need as many RTR-attributes inside the RTR-subject as in the
>>>> SDW-svh.
>>>>
>>>>
>>>> The METAMODELS are:
>>>>
>>>> package RTR
>>>> {
>>>> class "RTR-subject"
>>>> {
>>>> attribute name : String;
>>>> attribute description : String; reference
>>>> "RTR-attribute"[*] container : "RTR-attribute";
>>>> }
>>>> class "RTR-attribute" {
>>>> attribute name : String;
>>>> attribute alter : String;
>>>> attribute optional : String;
>>>> attribute dataType : String;
>>>> attribute dataLength : String; }
>>>> }
>>>>
>>>> package PrimitiveTypes
>>>> {
>>>> datatype String;
>>>> }
>>>>
>>>>
>>>>
>>>> AND
>>>>
>>>>
>>>> package SDW
>>>> {
>>>> class "SDW-svh"
>>>> {
>>>> attribute name : String;
>>>> attribute description : String;
>>>> reference "SDW-attribute"[*] container : "SDW-attribute";
>>>> }
>>>> class "SDW-attribute" {
>>>> attribute name : String;
>>>> attribute alter : String;
>>>> attribute optional : String;
>>>> attribute dataType : String;
>>>> attribute dataLength : String; }
>>>> }
>>>>
>>>> package PrimitiveTypes
>>>> {
>>>> datatype String;
>>>> }
>>>>
>>>> Thanx,
>>>>
>>>> Mike
>>>>
>>>>
>>>> Freddy Allilaire wrote:
>>>>
>>>>> Hi Michael,
>>>>
>>>>> ATL doesn't manage XMI serialisation of your model. This is done by
>>>>> "EMF XMI writer/reader". So you cannot tune by default XML/XMI
>>>>> serialisation.
>>>>
>>>>> But in your case to have your expected result, it seems to miss the
>>>>> containment reference between "RTR-subject" and "RTR-attribute".
>>>>
>>>>> I don't know your metamodel but it should be something like this:
>>>>
>>>>> rule svh2subject {
>>>>> from s: SDW!"SDW-svh"
>>>>> to r : RTR!"RTR-subject" (
>>>>> name <- s.name,
>>>>> description <- s.description,
>>>>> attributes <- Set {o} -- new line added
>>>>> ),
>>>>> o : RTR!"RTR-attribute" (
>>>>> name <- s.name
>>>>> )
>>>>> }
>>>>
>>>>> HTH
>>>>
>>>>> Regards,
>>>>> Freddy.
>>>>
>>>>> Michael Igler a écrit :
>>>>>> Hello,
>>>>>>
>>>>>> I'd like to to a XML Tranformation with ATL. Modeled my things in
>>>>>> KM3 and injected everything.
>>>>>> Now I do the transformation in an ATL file, but I do not get a
>>>>>> nested XML Element:
>>>>>>
>>>>>> Here are my ruels:
>>>>>>
>>>>>> module SDW2RTR;
>>>>>> create OUT : RTR from IN : SDW;
>>>>>>
>>>>>> rule svh2subject
>>>>>> {
>>>>>> from s: SDW!"SDW-svh"
>>>>>> to r : RTR!"RTR-subject"
>>>>>> (
>>>>>> name <- s.name,
>>>>>> description <- s.description
>>>>>> ),
>>>>>> o : RTR!"RTR-attribute"
>>>>>> (
>>>>>> name <- s.name )
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> The output is:
>>>>>>
>>>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>>>> <xmi:XMI xmi:version="2.0"
>>>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR">
>>>>>> <RTR-subject name="KND" description="Kunde"/>
>>>>>> <RTR-attribute name="KND"/>
>>>>>> </xmi:XMI>
>>>>>>
>>>>>>
>>>>>>
>>>>>> BUT WHAT I NEED IS:
>>>>>>
>>>>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>>>>> <xmi:XMI xmi:version="2.0"
>>>>>> xmlns:xmi="http://www.omg.org/XMI" xmlns="RTR">
>>>>>> <RTR-subject name="KND" description="Kunde">
>>>>>> <RTR-attribute name="KND"/>
>>>>>> <RTR-subject>
>>>>>> </xmi:XMI>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks for your help and I hope I am right in this group,
>>>>>>
>>>>>> Mike
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi Freddy
>>>>
>>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 22:13:12 GMT 2024
Powered by FUDForum. Page generated in 0.03399 seconds
|