KM3 model [message #559033] |
Wed, 15 September 2010 07:33  |
Eclipse User |
|
|
|
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 09:45  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03470 seconds