当前位置:网站首页>Ontology Development Diary 05-Strive to Understand SWRL (Part 2)

Ontology Development Diary 05-Strive to Understand SWRL (Part 2)

2022-08-09 09:30:00 "Cancelled"

五、XML 具体语法XML Concrete Syntax

XML 具体语法是 OWL Web Ontology Language XML Presentation Syntax [ OWL XML ] 与 RuleML XML 语法 [ RuleML ] 的组合.

  • 任意 OWL 类(例如,描述)Can be used as a predicate in rules
  • Rules and ontological axioms can be freely mixed
  • 现有的 XSLT 样式表 ( owlxml2rdf.xsl ) Can be easily extended to provide RDF Graph map,从而扩展了 OWL RDF/XML exchange syntax
  • 简化了 OWL 和 RuleML 之间的互操作性,现有的 RuleML Tools can adapt SWRL,And it is an evolutionary expansion path for additional rule expression functions.

SWRL XML specific grammar XML 模式是 swrlx.xsd. swrlx.xsd Currently cited OWL XML grammatical XML A local copy of the schema,The copy has been modified to allow external references to several of its elements and attributes,并定义 owlx:datarange,这似乎是 OWL XML Indicates a missing part of the grammar.

swrlx.xsd

可直接复制!

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 The concrete 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) 和 http://www.w3.org/2001/XMLSchema (xsd).
(PS:None of the links above can be opened!Q~Q)
OWL XML The ontology root element representing the grammar is expanded to include in RuleML found under the root of the rulebase“ imp ”(implication ruleimplication rule)和“ var ”(variable declaration变量声明)公理.

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>

在这里插入图片描述
属性: swrlx:name - Refers to the name of this ontology,It is the base of this element URI.
Note: 这是 XML expressed in grammar OWL 文档的根元素,而rdf:RDF在 RDF/XML 中用作 OWL document root.
Then we just need to add the relevant syntax for variables and rules.变量 (var) Axioms are statements about variables,Indicates that the given string is to be used as a variable.var Axioms simply define the existence of variables.这取自 RuleML 命名空间.
(PS:我思考了一个问题!Why am I looking at these things!What am I for!Suddenly I figured it out!我要找一个东西!没有的话!No need to look at these!)
在这里插入图片描述

5.1

在这里插入图片描述
在这里插入图片描述
This element allows people to say,meet the rules _body Every binding must also satisfy the rules _head.
可以选择使用 URI to name the rule axioms.
在这里插入图片描述
_body 和 _head Both are lists of atoms,and is seen as a combination of constituent atoms.在这里插入图片描述
在这里插入图片描述
Atoms can be represented by unary predicates(类)、二元谓词(属性)、Equality or inequality composition.
在这里插入图片描述
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,It is also possible to use a boolean combination、Complex descriptions of restrictions, 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 literal or variable name.
在这里插入图片描述

5.3

The description in the data range atom may be the data type ID,It could also be 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,These elements can have individual names、Variable name or data value.
在这里插入图片描述
在这里插入图片描述

5.4

由于 OWL Complex property descriptions are not supported,So property atoms only need one property 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 individual atoms of , assert equality between the collection of individual names and variable names(不等).
在这里插入图片描述
在这里插入图片描述

5.5

Assertions can be made between variable names and combinations of individual names(in)相等.

<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 an interface to built-in functions.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
This element is only used to refer to variables ID,与var axiom不同,It doesn't actually define any variables .

5.6 规则示例

1.使用 SWRL 来断言hasParent 和hasBrotherThe combination of properties meanshasUncle属性.

<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:如果 x1 hasParent x2,x2 hasSibling x3和x3 hasSex male,则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.The rule expresses such a fact,即,knowing something ULAN 艺术家(例如,Van Gogh was an Impressionist painter)的 AAT case of style,We can get the value from the creator of the art object(由 VRA 元素“creator”表示,它是 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 such a fact:对于每个机场,There is a mapPointSame as the airport 位置(纬度和经度),并且它是“图层”(地图 DrawingLayer)的对象.此外,The map point will be the airport as 底层对象,and take the airport name as it 标签.

<!-- 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> 

补充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:感谢360Great support for web translation!

原网站

版权声明
本文为["Cancelled"]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090913281065.html