Ontology development diary 05 - strive to understand SWRL

5, XML Concrete Syntax

The specific syntax of XML is the combination of owl Web Ontology Language XML presentation syntax [owl XML] and RuleML XML syntax [RuleML].

  • Any OWL class (for example, description) can be used as a predicate in a rule
  • Rules and ontology axioms can be freely mixed
  • The existing XSLT stylesheet (owlxml2rdf.xsl) can be easily extended to provide mapping to RDF diagrams, thereby extending the OWL RDF/XML exchange syntax
  • It simplifies the interoperability between OWL and RuleML. The existing RuleML tools can adapt to SWRL and are the evolutionary extension path of additional rule expression functions.

The XML schema of SWRL XML specific syntax is swrlx.xsd. Swrlx.xsd currently references a local copy of the XML schema of OWL XML presentation syntax, which has been modified to allow external references to multiple elements and attributes, and defines owlx:datarange, which seems to be a missing part of OWL XML presentation syntax.

swrlx.xsd

Can be copied directly!

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:owlx="http://www.w3.org/2003/05/owl-xml" xmlns:swrlx="http://www.w3.org/2003/11/swrlx" xmlns:ruleml="http://www.w3.org/2003/11/ruleml" targetNamespace="http://www.w3.org/2003/11/swrlx" elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:import namespace="http://www.w3.org/2003/05/owl-xml" schemaLocation="owlx/schema/owl1-dl.xsd"/>
<xsd:import namespace="http://www.w3.org/2003/11/ruleml" schemaLocation="ruleml.xsd"/>
<xsd:annotation>
<xsd:documentation> XML Schema driver for SWRL 0.6 The root element of SWRL documents for the XML Concrete Syntax must be the Ontology element. </xsd:documentation>
</xsd:annotation>
<xsd:element name="Ontology">
<xsd:annotation>
<xsd:documentation> This is the root element of SWRL documents in the XML Concrete Syntax. It extends owlx:Ontology </xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:choice>
<!--  Header elements  -->
<xsd:element ref="owlx:VersionInfo"/>
<xsd:element ref="owlx:PriorVersion"/>
<xsd:element ref="owlx:BackwardCompatibleWith"/>
<xsd:element ref="owlx:IncompatibleWith"/>
<xsd:element ref="owlx:Imports"/>
<xsd:element ref="owlx:Annotation"/>
<!--  Class elements  -->
<xsd:element ref="owlx:Class"/>
<xsd:group ref="owlx:classElements"/>
<!--  Property elements  -->
<xsd:element ref="owlx:DatatypeProperty"/>
<xsd:element ref="owlx:ObjectProperty"/>
<xsd:element ref="owlx:SubPropertyOf"/>
<xsd:element ref="owlx:EquivalentProperties"/>
<!--  Instances  -->
<xsd:element ref="owlx:Individual"/>
<xsd:element ref="owlx:SameIndividual"/>
<xsd:element ref="owlx:DifferentIndividuals"/>
<!--  SWRL extensions  -->
<xsd:element ref="ruleml:imp"/>
<xsd:element ref="ruleml:var"/>
</xsd:choice>
</xsd:sequence>
</xsd:sequence>
<xsd:attribute ref="owlx:name"/>
</xsd:complexType>
<!--  XXX:  clone for rule names, etc.  -->
<xsd:unique name="classNameUniqueness">
<xsd:annotation>
<xsd:documentation> This constraint ensures that every class name is unique in a single OWL document. </xsd:documentation>
</xsd:annotation>
<xsd:selector xpath="owlx:Class"/>
<xsd:field xpath="@owlx:name"/>
</xsd:unique>
</xsd:element>
<xsd:group name="atom">
<xsd:choice>
<xsd:element ref="swrlx:classAtom"/>
<xsd:element ref="swrlx:datarangeAtom"/>
<xsd:element ref="swrlx:individualPropertyAtom"/>
<xsd:element ref="swrlx:datavaluedPropertyAtom"/>
<xsd:element ref="swrlx:sameIndividualAtom"/>
<xsd:element ref="swrlx:differentIndividualsAtom"/>
<xsd:element ref="swrlx:builtinAtom"/>
</xsd:choice>
</xsd:group>
<xsd:element name="classAtom">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="owlx:description"/>
<xsd:group ref="swrlx:iObject"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="datarangeAtom">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="owlx:datarange"/>
<xsd:group ref="swrlx:dObject"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="individualPropertyAtom">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="swrlx:iObject"/>
<xsd:group ref="swrlx:iObject"/>
</xsd:sequence>
<xsd:attribute name="property" type="owlx:IndividualPropertyName" use="required"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="datavaluedPropertyAtom">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="swrlx:iObject"/>
<xsd:group ref="swrlx:dObject"/>
</xsd:sequence>
<xsd:attribute name="property" type="owlx:DataPropertyName" use="required"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="sameIndividualAtom">
<xsd:complexType>
<xsd:sequence minOccurs="2" maxOccurs="2">
<xsd:group ref="swrlx:iObject"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="differentIndividualsAtom">
<xsd:complexType>
<xsd:sequence minOccurs="2" maxOccurs="2">
<xsd:group ref="swrlx:iObject"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="builtinAtom">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="swrlx:dObject" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="builtin" type="swrlx:BuiltinName" use="required"/>
</xsd:complexType>
</xsd:element>
<xsd:group name="iObject">
<xsd:choice>
<xsd:element ref="owlx:Individual"/>
<xsd:element ref="ruleml:var"/>
</xsd:choice>
</xsd:group>
<xsd:group name="dObject">
<xsd:choice>
<xsd:element ref="owlx:DataValue"/>
<xsd:element ref="ruleml:var"/>
</xsd:choice>
</xsd:group>
<xsd:simpleType name="BuiltinName">
<xsd:restriction base="xsd:anyURI"/>
</xsd:simpleType>
</xsd:schema>

SWRL XML specific syntax uses namespaces http://www.w3.org/2003/11/swrlx , http://www.w3.org/2003/11/ruleml , http://www.w3.org/ 2003 / 05 / Owl XML (owlx) and http://www.w3.org/2001/XMLSchema (xsd).
(PS: none of the above links can be opened! Q~Q)
The ontology root element of OWL XML representation syntax is extended to include "imp" (implication rule implication rule) and "var" (variable declaration variable declaration) axioms found under the rule base root of RuleML.

element Ontology

<swrlx:Ontology
  swrlx:name = xsd:anyURI 
>
  Content: (owlx:VersionInfo | owlx:PriorVersion | owlx:BackwardCompatibleWith | 
            owlx:IncompatibleWith | owlx:Imports | owlx:Annotation | 
            owlx:Class[axiom] | owlx:EnumeratedClass(D,F) | 
            owlx:SubClassOf(D,F) | owlx:EquivalentClasses | owlx:DisjointClasses(D,F) | 
            owlx:DatatypeProperty | owlx:ObjectProperty | 
            owlx:SubPropertyOf | owlx:EquivalentProperties | 
            owlx:Individual[axiom] | owlx:SameIndividual | owlx:DifferentIndividuals |
            ruleml:imp[axiom] | ruleml:var[axiom])* 
</swrlx:Ontology>


Attribute: swrlx:name - refers to the name of the ontology, which is the basic URI of the element.
Note: This is the root element of OWL document in XML representation syntax, and rdf:RDF is used as the document root of OWL in RDF/XML.
Then we just need to add relevant syntax for variables and rules. The variable (var) axiom is a statement about variables, indicating that a given string is to be used as a variable. The var axiom simply defines the existence of variables. This is taken from the RuleML namespace.
(PS: I thought about a question! Why should I look at these things! What am I doing for? Suddenly I figured out! I want to find something! If not, I don't have to look at them!)

5.1



This element allows people to say that the rules are met_ Each binding of body must also meet the requirements of the rule_ head.
You can choose to use URI s to name rule axioms.

_ body and_ Heads are lists of atoms and are regarded as combinations of constituent atoms.

Atoms can be composed of unary predicates (classes), binary predicates (attributes), equations or inequalities.

A class atom consists of a description and a single name or variable name.

5.2

The description in the class atom may be the class name, or it may be a complex description using Boolean combination, restriction, etc.

<swrlx:classAtom> 
  <owlx:Class owlx:name="Person" />
  <ruleml:var>x1</ruleml:var>
</swrlx:classAtom> 

<swrlx:classAtom> 
  <owlx:IntersectionOf>
    <owlx:Class owlx:name="Person" />
    <owlx:ObjectRestriction owlx:property="hasParent"> 
      <owlx:someValuesFrom owlx:class="Physician" />
    </owlx:ObjectRestriction> 
  </owlx:IntersectionOf>
  <ruleml:var>x2</ruleml:var>
</swrlx:classAtom> 

A data range atom consists of a data range and a text or variable name.

5.3

The description in the data range atom may be a data type ID or a set of text.

<swrlx:datarangeAtom> 
  <owlx:Datatype owlx:name="&xsd;int" />
  <ruleml:var>x1</ruleml:var>
</swrlx:datarangeAtom> 

<swrlx:datarangeAtom> 
  <owlx:OneOf>
    <owlx:DataValue owlx:datatype="&xsd;int">5</owlx:DataValue>
    <owlx:DataValue owlx:datatype="&xsd;int">10</owlx:DataValue>
  </owlx:OneOf>
  <ruleml:var>x2</ruleml:var>
</swrlx:datarangeAtom> 

An attribute atom consists of an attribute name and two elements, which can be separate names, variable names, or data values.

5.4

Because OWL does not support complex attribute descriptions, attribute atoms only need one attribute name.

<swrlx:individualPropertyAtom  swrlx:property="hasParent"> 
  <ruleml:var>x1</ruleml:var>
  <owlx:Individual owlx:name="John" />
</swrlx:individualPropertyAtom> 

<swrlx:datavaluedPropertyAtom  swrlx:property="grade"> 
  <ruleml:var>x1</ruleml:var>
  <owlx:DataValue owlx:datatype="&xsd;int">4</owlx:DataValue>
</swrlx:datavaluedPropertyAtom> 

The same (different) individual atom asserts equality (inequality) between the set of individual names and variable names.

5.5

You can assert (in) equality between a combination of variable names and individual names.

<swrlx:sameIndividualAtom> 
  <ruleml:var>x1</ruleml:var>
  <ruleml:var>x2</ruleml:var>
</swrlx:sameIndividualAtom> 
<swrlx:sameIndividualAtom> 
  <ruleml:var>x1</ruleml:var>
  <owlx:Individual owlx:name="Bill_Clinton" />
</swrlx:sameIndividualAtom> 
<swrlx:sameIndividualAtom> 
  <owlx:Individual owlx:name="Clinton" />
  <owlx:Individual owlx:name="Bill_Clinton" />
</swrlx:sameIndividualAtom> 

Built in atoms provide interfaces to built-in functions.




This element is only used to reference the variable ID. unlike var axiom, it does not actually define any variables.

5.6 rule examples

1. Use SWRL to assert that the combination of hasParent and hasBrother attributes means hasUncle attribute.

<ruleml:imp> 
  <ruleml:_rlab ruleml:href="#example1"/> 
  <ruleml:_body> 
    <swrlx:individualPropertyAtom swrlx:property="hasParent"> 
      <ruleml:var>x1</ruleml:var> 
      <ruleml :var>x2</ruleml:var> 
    </swrlx:individualPropertyAtom> 
    <swrlx:individualPropertyAtom swrlx:property="hasBrother"> 
      <ruleml:var>x2</ruleml:var> 
      <ruleml:var>x3</ruleml: var> 
    </swrlx:individualPropertyAtom> 
  </ruleml:_body> 
  <ruleml:_head> 
    <swrlx:individualPropertyAtom swrlx:property="hasUncle"> 
      <ruleml:var>x1</ruleml:var> 
      <ruleml:var>x3</ruleml:var> 
    </swrlx:individualPropertyAtom>
  </ruleml:_head> 
</ruleml:imp>

2.Assert: if x1 hasParent x2, x2 hasSibling x3 and x3 hasSex male, then x1 hasUncle x3.

<ruleml:imp> 
  <ruleml:_rlab ruleml:href="#example2"/>
  <ruleml:_body> 
    <swrlx:individualPropertyAtom  swrlx:property="hasParent"> 
      <ruleml:var>x1</ruleml:var>
      <ruleml:var>x2</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="hasSibling"> 
      <ruleml:var>x2</ruleml:var>
      <ruleml:var>x3</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="hasSex"> 
      <ruleml:var>x3</ruleml:var>
      <owlx:Individual owlx:name="#male" />
    </swrlx:individualPropertyAtom> 
  </ruleml:_body> 
  <ruleml:_head> 
    <swrlx:individualPropertyAtom  swrlx:property="hasUncle"> 
      <ruleml:var>x1</ruleml:var>
      <ruleml:var>x3</ruleml:var>
    </swrlx:individualPropertyAtom> 
  </ruleml:_head> 
</ruleml:imp> 

3. This rule expresses the fact that when we understand the AAT style of some ULAN artists (for example, Van Gogh is an impressionist painter), we can start from the value of the creator of the art object (represented by the VRA element "creator", which is a sub attribute of dc:creator)

<ruleml:imp> 
  <ruleml:_body> 
    <swrlx:classAtom> 
      <owlx:Class owlx:name="&ulan;Artist" />
      <ruleml:var>x</ruleml:var>
    </swrlx:classAtom> 
    <swrlx:classAtom> 
      <owlx:Class owlx:name="&aat;Style" />
      <ruleml:var>y</ruleml:var>
    </swrlx:classAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="&aatulan;artistStyle"> 
      <ruleml:var>x</ruleml:var>
      <ruleml:var>y</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="&vra;creator"> 
      <ruleml:var>x</ruleml:var>
      <ruleml:var>z</ruleml:var>
    </swrlx:individualPropertyAtom> 
  </ruleml:_body> 
  <ruleml:_head> 
    <swrlx:individualPropertyAtom  swrlx:property="&vra;style/period"> 
      <ruleml:var>z</ruleml:var>
      <ruleml:var>y</ruleml:var>
    </swrlx:individualPropertyAtom> 
  </ruleml:_head> 
</ruleml:imp> 

4. It expresses the fact that for each airport, there is a map Point with the same location (latitude and longitude) as the airport, and it is the object of the "drawing layer". In addition, the map Point takes the airport as the underlying object and the airport name as its label.

<!--
Background knowledge about airports and maps:
-->

<owlx:DatatypeProperty owlx:name="latitude"/>
<owlx:DatatypeProperty owlx:name="longitude"/>

<owlx:SubClassOf> 
  <owlx:sub> 
    <owlx:Class owlx:name="Location" />
  </owlx:sub> 
  <owlx:super> 
    <owlx:IntersectionOf>
      <owlx:DataRestriction owlx:property="latitude"> 
        <owlx:allValuesFrom owlx:datatype="&xsd;double"/>
      </owlx:DataRestriction> 
      <owlx:DataRestriction owlx:property="longitude"> 
        <owlx:allValuesFrom owlx:datatype="&xsd;double"/>
      </owlx:DataRestriction> 
    </owlx:IntersectionOf>
  </owlx:super> 
</owlx:SubClassOf> 

<owlx:Individual owlx:name="&airport;GEG">
  <owlx:type owlx:name="&airport-ont;Airport" /> 
  <owlx:DataPropertyValue owlx:property="airport-ont:name">
    <owlx:DataValue owlx:datatype="&xsd;string">Spokane Intl</owlx:DataValue> 
  </owlx:DataPropertyValue>
  <owlx:ObjectPropertyValue owlx:property="location">
    <owlx:Individual>
      <owlx:DataPropertyValue owlx:property="latitude">
        <owlx:DataValue>47.6197</owlx:DataValue> 
      </owlx:DataPropertyValue>
      <owlx:DataPropertyValue owlx:property="longitude">
        <owlx:DataValue>-117.5336</owlx:DataValue> 
      </owlx:DataPropertyValue>
    </owlx:Individual>
  </owlx:ObjectPropertyValue>
</owlx:Individual>
 
<owlx:Individual owlx:name="layer">
  <owlx:type owlx:name="&map;DrawingLayer" /> 
</owlx:Individual>
 
<owlx:Individual owlx:name="map">
  <owlx:type owlx:name="&map;Map" /> 
  <owlx:DataPropertyValue owlx:property="&map;name">
    <owlx:DataValue owlx:datatype="&xsd;string">Airports</owlx:DataValue> 
  </owlx:DataPropertyValue>
  <owlx:ObjectPropertyValue owlx:property="map:layer">
    <owlx:Individual owlx:name="layer"/>
  </owlx:ObjectPropertyValue>
</owlx:Individual>

<!--
A map:Location has latitude and longitude, both of which are doubles:
-->

<owlx:SubClassOf> 
  <owlx:sub> 
    <owlx:Class owlx:name="&map;Location" />
  </owlx:sub> 
  <owlx:super> 
    <owlx:IntersectionOf>
      <owlx:DataRestriction owlx:property="&map;latitude"> 
        <owlx:someValuesFrom owlx:datatype="&xsd;double"/>
      </owlx:DataRestriction> 
      <owlx:DataRestriction owlx:property="&map;latitude"> 
        <owlx:allValuesFrom owlx:datatype="&xsd;double"/>
      </owlx:DataRestriction> 
      <owlx:DataRestriction owlx:property="&map;longitude"> 
        <owlx:someValuesFrom owlx:datatype="&xsd;double"/>
      </owlx:DataRestriction> 
      <owlx:DataRestriction owlx:property="&map;longitude"> 
        <owlx:allValuesFrom owlx:datatype="&xsd;double"/>
      </owlx:DataRestriction> 
    </owlx:IntersectionOf>
  </owlx:super> 
</owlx:SubClassOf> 

<!--
If a map:Location is the sameLocation as another location, 
then it has the same values for latitude and longitude.
-->

<ruleml:imp> 
  <ruleml:_body> 
    <swrlx:classAtom> 
      <owlx:Class owlx:name="&map;Location" />
      <ruleml:var>maploc</ruleml:var>
    </swrlx:classAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="sameLocation"> 
      <ruleml:var>loc</ruleml:var>
      <ruleml:var>maploc</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="latitude"> 
      <ruleml:var>loc</ruleml:var>
      <ruleml:var>lat</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="longitude"> 
      <ruleml:var>loc</ruleml:var>
      <ruleml:var>lon</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_body> 
  <ruleml:_head> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&map;latitude"> 
      <ruleml:var>maploc</ruleml:var>
      <ruleml:var>lat</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&map;longitude"> 
      <ruleml:var>maploc</ruleml:var>
      <ruleml:var>lon</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_head> 
</ruleml:imp> 

<!--
Wherever an Airport is located, there is some map:Location
that is the sameLocation as the Airport's location, and that
is the location of a map Point that is an object of the
map:DrawingLayer "layer":
-->

<owlx:ObjectProperty owlx:name="&map;location" owlx:inverseOf="&map;isLocationOf" />
<owlx:ObjectProperty owlx:name="&map;object" owlx:inverseOf="&map;isObjectOf" />

<ruleml:imp> 
  <ruleml:_body> 
    <swrlx:classAtom> 
      <owlx:Class owlx:name="&airport-ont;Airport" />
      <ruleml:var>airport</ruleml:var>
    </swrlx:classAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="location"> 
      <ruleml:var>airport</ruleml:var>
      <ruleml:var>loc</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="latitude"> 
      <ruleml:var>loc</ruleml:var>
      <ruleml:var>lat</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="longitude"> 
      <ruleml:var>loc</ruleml:var>
      <ruleml:var>lon</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_body> 
  <ruleml:_head> 
    <swrlx:classAtom> 
      <owlx:ObjectRestriction owlx:property="sameLocation"> 
        <owlx:someValuesFrom>
          <owlx:IntersectionOf>
            <owlx:Class owlx:name="&map;Location" />
            <owlx:ObjectRestriction owlx:property="&map;isLocationOf"> 
              <owlx:someValuesFrom>
                <owlx:IntersectionOf>
                  <owlx:Class owlx:name="&map;Point" />
                  <owlx:ObjectRestriction owlx:property="&map;isObjectOf"> 
                    <owlx:someValuesFrom>
                      <owlx:OneOf>
                        <owlx:Individual owlx:name="#layer" /> 
                      </owlx:OneOf>
                    </owlx:someValuesFrom>
                  </owlx:ObjectRestriction>
                </owlx:IntersectionOf>
              </owlx:someValuesFrom>
            </owlx:ObjectRestriction>
          </owlx:IntersectionOf>
        </owlx:someValuesFrom>
      </owlx:ObjectRestriction> 
      <ruleml:var>loc</ruleml:var>
    </swrlx:classAtom> 
  </ruleml:_head> 
</ruleml:imp> 

<!--
The map:Point whose map:location is the map:Location of an Airport 
has the airport as a map:underlyingObject and has a map:label 
which is the name of the Airport.
-->

<ruleml:imp> 
  <ruleml:_body> 
    <swrlx:classAtom> 
      <owlx:Class owlx:name="&airport-ont;Airport" />
      <ruleml:var>airport</ruleml:var>
    </swrlx:classAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="location"> 
      <ruleml:var>airport</ruleml:var>
      <ruleml:var>loc</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="sameLocation"> 
      <ruleml:var>loc</ruleml:var>
      <ruleml:var>maploc</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:individualPropertyAtom  swrlx:property="&map;location"> 
      <ruleml:var>point</ruleml:var>
      <ruleml:var>maploc</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&airport-ont;name"> 
      <ruleml:var>airport</ruleml:var>
      <ruleml:var>name</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_body> 
  <ruleml:_head> 
    <swrlx:individualPropertyAtom  swrlx:property="&map;underlyingObject"> 
      <ruleml:var>point</ruleml:var>
      <ruleml:var>airport</ruleml:var>
    </swrlx:individualPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&map;label"> 
      <ruleml:var>point</ruleml:var>
      <ruleml:var>name</ruleml:var>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_head> 
</ruleml:imp> 

5. The ontology translation example shows the use of built-in functions to convert units of measure.

<ruleml:imp>
  <ruleml:_rlab ruleml:href="#convertLength"/>
  <owlx:Annotation>
    <owlx:Documentation>ex2:lengthInInches = ex1:lengthInFeet * 12</owlx:Documentation>
  </owlx:Annotation>
  <ruleml:_body>
    <swrlx:datavaluedPropertyAtom swrlx:property="&ex1;#lengthInFeet">
      <ruleml:var>instance</ruleml:var>
      <ruleml:var>feet</ruleml:var>
    </swrlx:datavaluedPropertyAtom>
  </ruleml:_body>
  <ruleml:_head>
    <swrlx:builtinAtom swrlx:builtin="&swrlb;#multiply">
      <ruleml:var>inches</ruleml:var>
      <ruleml:var>feet</ruleml:var>
      <owlx:DataValue owlx:datatype="&xsd;#int">12</owlx:DataValue>
    </swrlx:builtinAtom>
    <swrlx:datavaluedPropertyAtom swrlx:property="&ex2;#lengthInInches">
      <ruleml:var>instance</ruleml:var>
      <ruleml:var>inches</ruleml:var>
    </swrlx:datavaluedPropertyAtom>
  </ruleml:_head>
</ruleml:imp>
<ruleml:imp> 
  <ruleml:_rlab ruleml:href="#goldDiscount"/>
  <owlx:Annotation>
    <owlx:Documentation>Gold customers get a 10% discount on purchases of $500 or more</owlx:Documentation>
  </owlx:Annotation>
  <ruleml:_body> 
    <swrlx:individualPropertyAtom  swrlx:property="&ex;#hasStatus"> 
      <ruleml:var>customer</ruleml:var>
      <owlx:Individual owlx:name="&ex;#gold"/>
    </swrlx:individualPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&ex;#hasTotalPurchase"> 
      <ruleml:var>customer</ruleml:var>
      <ruleml:var>total</ruleml:var>
    </swrlx:datavaluedPropertyAtom>
    <swrlx:builtinAtom  swrlx:builtin="&swrlb;#greaterThanOrEqual">
      <ruleml:var>total</ruleml:var>
      <owlx:DataValue owlx:datatype="&xsd;#int">500</owlx:DataValue>
    </swrlx:builtinAtom>
  </ruleml:_body>
  <ruleml:_head> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&ex;#hasDiscount"> 
      <ruleml:var>customer</ruleml:var>
      <owlx:DataValue owlx:datatype="&xsd;#int">10</owlx:DataValue>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_head> 
</ruleml:imp> 

Supplement example5.1-6.swrlx

<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE swrlx:Ontology [
	 <!ENTITY swrlb 'http://www.w3.org/2003/11/swrlb'>
	 <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema'>
	 <!ENTITY ex 'http://www.example.org/example-ont'>
]>

<swrlx:Ontology
  xmlns:owlx="http://www.w3.org/2003/05/owl-xml"
  xmlns:swrlx="http://www.w3.org/2003/11/swrlx"
  xmlns:ruleml="http://www.w3.org/2003/11/ruleml">
  <owlx:Annotation>
    <owlx:Documentation>SWRL Builtins Example 5.1-6</owlx:Documentation>
  </owlx:Annotation>
  <owlx:VersionInfo>$Id: example5.1-6.swrlx,v 1.3 2004/06/21 08:09:37 mdean Exp $</owlx:VersionInfo>

<ruleml:var>customer</ruleml:var>
<ruleml:var>total</ruleml:var>

<!--
If a customer has a gold status and has a total purchase greater than or equal to 500 dollars
Then the customer gets a 10 percent discount.
-->

<ruleml:imp> 
  <ruleml:_rlab ruleml:href="#goldDiscount"/>
  <owlx:Annotation>
    <owlx:Documentation>Gold customers get a 10% discount on purchases of $500 or more</owlx:Documentation>
  </owlx:Annotation>
  <ruleml:_body> 
    <swrlx:individualPropertyAtom  swrlx:property="&ex;#hasStatus"> 
      <ruleml:var>customer</ruleml:var>
      <owlx:Individual owlx:name="&ex;#gold"/>
    </swrlx:individualPropertyAtom> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&ex;#hasTotalPurchase"> 
      <ruleml:var>customer</ruleml:var>
      <ruleml:var>total</ruleml:var>
    </swrlx:datavaluedPropertyAtom>
    <swrlx:builtinAtom  swrlx:builtin="&swrlb;#greaterThanOrEqual">
      <ruleml:var>total</ruleml:var>
      <owlx:DataValue owlx:datatype="&xsd;#int">500</owlx:DataValue>
    </swrlx:builtinAtom>
  </ruleml:_body>
  <ruleml:_head> 
    <swrlx:datavaluedPropertyAtom  swrlx:property="&ex;#hasDiscount"> 
      <ruleml:var>customer</ruleml:var>
      <owlx:DataValue owlx:datatype="&xsd;#int">10</owlx:DataValue>
    </swrlx:datavaluedPropertyAtom> 
  </ruleml:_head> 
</ruleml:imp> 

</swrlx:Ontology>

PS: thanks for the strong support of 360 web page translation!

Posted by j_smith123 on Wed, 27 Oct 2021 23:24:18 -0700