From: Mike Dean ([email protected])
Date: 01/06/04
Here are updates to my previous examples from [1] based on our 16 December telecon: <!-- free shipping on orders over $50 --> <ruleml:imp> <ruleml:_body> <swrlx:classAtom> <owlx:Class owlx:name="Order"/> <ruleml:var>order</ruleml:var> </swrlx:classAtom> <swrlx:datavaluedPropertyAtom swrlx:property="cost"> <ruleml:var>order</ruleml:var> <ruleml:var>cost</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:operationAtom swrlx:op="&op;numeric-greater-than"> <ruleml:var>cost</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">50</owlx:DataValue> </swrlx:comparisonAtom> </ruleml:_body> <ruleml:_head> <swrlx:datavaluedPropertyAtom swrlx:property="shipping"> <ruleml:var>order</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">0</owlx:DataValue> </swrlx:datavaluedPropertyAtom> </ruleml:_head> </ruleml:imp> <!-- convert temperature from Fahrenheit to Celsius --> <ruleml:imp> <ruleml:_body> <swrlx:datavaluedPropertyAtom swrlx:property="fahrenheitTemp"> <ruleml:var>x</ruleml:var> <ruleml:var>f</ruleml:var> </swrlx:datavaluedPropertyAtom> <swrlx:operationAtom swrlx:op="&op;numeric-subtract"> <ruleml:var>i1</ruleml:var> <ruleml:var>f</ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">32</owlx:DataValue> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-multiply"> <ruleml:var>i2</ruleml:var> <ruleml:var>i1/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">5</owlx:DataValue> </swrlx:operationAtom> <swrlx:operationAtom swrlx:op="&op;numeric-integer-divide"> <ruleml:var>c</ruleml:var> <ruleml:var>i2/ruleml:var> <owlx:DataValue owlx:datatype="&xsd;integer">9</owlx:DataValue> </swrlx:operationAtom> </ruleml:_body> <ruleml:_head> <swrlx:datavaluedPropertyAtom swrlx:property="celsiusTemp"> <ruleml:var>x</ruleml:var> <ruleml:var>c</ruleml:var> </swrlx:datavaluedPropertyAtom> </ruleml:_head> </ruleml:imp> This assumes that the binding pattern for each "operator" will be defined in our documentation - implementations may also allow user-defined operators. By convention, the arithmetic operators use the first binding for the result of the calculation. Each operator will also return true or false to indicate the success or failure of the swrlx:operationAtom (false might be used in the arithmetic operators to report overflow, divide by zero, etc.). Since swrlx:operationAtom can return false, it should only appear within ruleml:_body. Corresponding executable examples in N3 are now available at [2] and [3]. Mike [1] http://www.daml.org/listarchive/joint-committee/1580.html [2] http://www.daml.org/2003/06/ruletests/comparison-1.n3 [3] http://www.daml.org/2003/06/ruletests/translation-4.n3
This archive was generated by hypermail 2.1.4 : 01/06/04 EST