Translator
: R2ML to JBoss Rules
for R2ML version 0.4
Examples:
R2ML
,
Contact:
Adrian Giurca
and Jens Werner (jens.werner {at} tu-cottbus.de)
<?xml version="1.0" encoding="UTF-8"?> <!-- This example file is based on the Version 0.4 of R2ML --> <r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.rewerse.net/I1/2006/R2ML http://oxygen.informatik.tu-cottbus.de/R2ML/0.4/R2ML.xsd" xmlns:examples="http://oxygen.informatik.tu-cottbus.de/R2ML/0.3/"> <r2ml:ProductionRuleSet r2ml:ruleSetID="org.drools.examples"> <r2ml:ProductionRule xmlns:ex="org.drools.examples.TroubleTicketExample" r2ml:ruleID="Platinum_Priority"> <r2ml:Documentation> <dc:creator>Adrian Giurca</dc:creator> <r2ml:SourceCode r2ml:language="JBossRules"> package org.drools.examples import org.drools.examples.TroubleTicketExample.Customer; import org.drools.examples.TroubleTicketExample.Ticket; rule "Platinum Priority" when customer : Customer( subscription == "Platinum" ) ticket : Ticket( customer == customer, status == "New" ) then; ticket.setStatus( "Escalate" ); modify( ticket ); end </r2ml:SourceCode> </r2ml:Documentation> <r2ml:conditions> <r2ml:ObjectDescriptionAtom r2ml:classID="ex:Customer"> <r2ml:subject> <r2ml:ObjectVariable r2ml:name="customer"/> </r2ml:subject> <r2ml:DataSlot r2ml:attributeID="ex:subscription"> <r2ml:value> <r2ml:TypedLiteral r2ml:lexicalValue="Platinum" r2ml:datatypeID="xs:string"/> </r2ml:value> </r2ml:DataSlot> </r2ml:ObjectDescriptionAtom> <r2ml:ObjectDescriptionAtom r2ml:classID="ex:Ticket"> <r2ml:subject> <r2ml:ObjectVariable r2ml:name="ticket"/> </r2ml:subject> <r2ml:ObjectSlot r2ml:referencePropertyID="customer"> <r2ml:object> <r2ml:ObjectVariable r2ml:name="customer"/> </r2ml:object> </r2ml:ObjectSlot> <r2ml:DataSlot r2ml:attributeID="ex:status"> <r2ml:value> <r2ml:TypedLiteral r2ml:lexicalValue="New" r2ml:datatypeID="xs:string"/> </r2ml:value> </r2ml:DataSlot> </r2ml:ObjectDescriptionAtom> </r2ml:conditions> <r2ml:producedAction> <r2ml:AssignActionExpression r2ml:propertyID="status"> <r2ml:contextArgument> <r2ml:ObjectVariable r2ml:name="ticket"/> </r2ml:contextArgument> <r2ml:TypedLiteral r2ml:lexicalValue="Escalate" r2ml:datatypeID="xs:string"/> </r2ml:AssignActionExpression> </r2ml:producedAction> </r2ml:ProductionRule> <r2ml:ProductionRule r2ml:ruleID="aRule" xmlns:swrlb="http://www.w3.org/2003/11/swrlb"> <r2ml:Documentation> <r2ml:RuleText r2ml:textFormat="plain">If a person has a male sibling and the sibling is older then the person, the person has an older brother.</r2ml:RuleText> <r2ml:SourceCode r2ml:language="JESS"> (defrule aRule (Person (name ?x))(Man (name ?y)) (hasSibling ?x ?y)(hasAge ?x ?a1) (hasAge ?y ?a2)(test (&gt; ?age2 ?age1)) =&gt; (assert (hasOlderBrother ?x ?y)) </r2ml:SourceCode> <dc:creator>Adrian Giurca</dc:creator> <dc:source>http://www.med.univ-rennes1.fr/~cgolb/Protege2005/SWRLJessOConnor.pdf</dc:source> <dc:date>2006-05-05</dc:date> </r2ml:Documentation> <r2ml:conditions> <r2ml:ReferencePropertyAtom r2ml:referencePropertyID="hasSibling"> <r2ml:subject> <r2ml:ObjectVariable r2ml:name="x" r2ml:classID="Person"/> </r2ml:subject> <r2ml:object> <r2ml:ObjectVariable r2ml:name="y" r2ml:classID="Man"/> </r2ml:object> </r2ml:ReferencePropertyAtom> <r2ml:ObjectDescriptionAtom r2ml:classID="Person"> <r2ml:subject> <r2ml:ObjectVariable r2ml:name="x"/> </r2ml:subject> <r2ml:DataSlot r2ml:attributeID="hasAge"> <r2ml:value> <r2ml:DataVariable r2ml:name="a1"/> </r2ml:value> </r2ml:DataSlot> </r2ml:ObjectDescriptionAtom> <r2ml:ObjectDescriptionAtom r2ml:classID="Man"> <r2ml:subject> <r2ml:ObjectVariable r2ml:name="y"/> </r2ml:subject> <r2ml:DataSlot r2ml:attributeID="hasAge"> <r2ml:value> <r2ml:DataVariable r2ml:name="a2"/> </r2ml:value> </r2ml:DataSlot> </r2ml:ObjectDescriptionAtom> <r2ml:DatatypePredicateAtom r2ml:datatypePredicateID="swrlb:greaterThan"> <r2ml:dataArguments> <r2ml:DataVariable r2ml:name="a2"/> <r2ml:DataVariable r2ml:name="a1"/> </r2ml:dataArguments> </r2ml:DatatypePredicateAtom> </r2ml:conditions> <r2ml:producedAction> <r2ml:AssignActionExpression r2ml:propertyID="hasOlderBrother"> <r2ml:contextArgument> <r2ml:ObjectVariable r2ml:name="x"/> </r2ml:contextArgument> <r2ml:ObjectVariable r2ml:name="y"/> </r2ml:AssignActionExpression> </r2ml:producedAction> </r2ml:ProductionRule> </r2ml:ProductionRuleSet> </r2ml:RuleBase>
With this web
translator
we give you the ability to test your R2ML markup and generate
JBoss Rules
output.