Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » KM3 model (how to create a KM3 model for the following rule?)
KM3 model [message #559033] Wed, 15 September 2010 11:33 Go to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
I need ATL transformation to transform user requirements into following rules. Hence, the plan is creating a KM3 model for requirements, and KM3 model for the following rule, and convert them to .ecore models and use ATL transformation.

Could someone tell me how can i model the following rule as a KM3 model? Is there any other approach available?

<rules xsi:schemaLocation="http://www.clixml.org/clix/1.0 clix.xsd"
version="1.1" xmlns="http://www.clixml.org/clix/1.0"
xmlns:macro="http://www.clixml.org/clix/1.0/Macro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<rule id="rule-1">

<report>Cost: %@=$service/Cost%
Currency: %@=$service/Currency%
</report>

<forall var="service" in="/Context/Service">
<or>
<and>
<equal op1="$service/Currency" op2="'GBP'"/>
<lessOrEqual op1="$service/Cost" op2="'0.2'"/>
</and>
<and>
<equal op1="$service/Currency" op2="'Euro'"/>
<lessOrEqual op1="$service/Cost" op2="'0.3'"/>
</and>
</or>
</forall>

</rule>

</rules>
Re: KM3 model [message #559065 is a reply to message #559033] Wed, 15 September 2010 13:45 Go to previous message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
at the moment, I have the followings,

Requirements KM3:

package Requirement{
class Requirement{
attribute Context : String;
attribute compOperator : String;
attribute Value : String;
}
}
package PrimitiveTypes{
datatype String;
}

Constraints KM3:

package Constraint{
class Constraint{
attribute compOperator:String;
attribute op1 : String;
attribute op2 : String;
}
}

package PrimitiveTypes{
datatype String;
}

Requirement2Constraint.ATL:

module Requirement2Constraint; -- Module Template
create OUT : Constraint from IN : Requirement;

rule Requirement{
from
a : Requirement!Requirement
to
b : Constraint!Constraint(
compOperator <- a.compOperator,
op1 <- a.Context,
op2 <- a.Value
)
}

Input in.ecore:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="Requirement">

<Requirement Context="$service/Cost" compOperator="lessThan" Value="'0.5'"/>
<Requirement Context="$service/Currency" compOperator="equal" Value="'USD'"/>

</xmi:XMI>

and finally i get output out.ecore:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns="Constraint">
<Constraint compOperator="lessThan" op1="$service/Cost" op2="'0.5'"/>
<Constraint compOperator="equal" op1="$service/Currency" op2="'USD'"/>
</xmi:XMI>

I want this out.ecore file to be same as the rule defined in the previous post. Here only op1, op2 are same.

your help is appriciated.
Previous Topic:[TCS] Immediate Composite Operation?
Next Topic:[ATL] Model Handler
Goto Forum:
  


Current Time: Fri Apr 26 09:09:21 GMT 2024

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

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

Back to the top