当前位置:网站首页>本体开发日记05-努力理解SWRL(下)

本体开发日记05-努力理解SWRL(下)

2022-08-09 09:13:00 「已注销」

五、XML 具体语法XML Concrete Syntax

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

  • 任意 OWL 类(例如,描述)可以用作规则中的谓词
  • 规则和本体公理可以自由混合
  • 现有的 XSLT 样式表 ( owlxml2rdf.xsl ) 可以很容易地扩展以提供到 RDF 图的映射,从而扩展了 OWL RDF/XML 交换语法
  • 简化了 OWL 和 RuleML 之间的互操作性,现有的 RuleML 工具可以适应 SWRL,并且是附加规则表达功能的进化扩展路径。

SWRL XML 具体语法的 XML 模式是 swrlx.xsd。 swrlx.xsd 当前引用了 OWL XML 表示语法的 XML 模式的本地副本,该副本已修改为允许对其多个元素和属性进行外部引用,并定义 owlx:datarange,这似乎是 OWL XML 表示语法的一个缺失部分。

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 具体语法使用命名空间 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:上面的链接没有一个能打开的!Q~Q)
OWL XML 表示语法的本体根元素被扩展为包括在 RuleML 的规则库根下找到的“ imp ”(implication 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 - 指的是这个本体的名称,它是这个元素的基本 URI。
Note: 这是 XML 表示语法中 OWL 文档的根元素,而rdf:RDF在 RDF/XML 中用作 OWL 的文档根。
然后我们只需要为变量和规则添加相关的语法。变量 (var) 公理是关于变量的语句,表示给定的字符串要用作变量。var 公理简单地定义了变量的存在。这取自 RuleML 命名空间。
(PS:我思考了一个问题!我为什么要看这些东西!我是为了什么!突然我就想明白了!我要找一个东西!没有的话!这些就都不用看了!)
在这里插入图片描述

5.1

在这里插入图片描述
在这里插入图片描述
该元素允许人们说,满足规则的 _body 的每个绑定也必须满足规则的 _head。
可以选择使用 URI 来命名规则公理。
在这里插入图片描述
_body 和 _head 都是原子列表,并被视为组成原子的结合。在这里插入图片描述
在这里插入图片描述
原子可以由一元谓词(类)、二元谓词(属性)、等式或不等式构成。
在这里插入图片描述
类原子由描述和单个名称或变量名称组成。
在这里插入图片描述

5.2

类原子中的描述可能是类名,也可能是使用布尔组合、限制等的复杂描述。

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

数据范围原子由数据范围和文字或变量名称组成。
在这里插入图片描述

5.3

数据范围原子中的描述可能是数据类型 ID,也可能是一组文字。

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

属性原子由一个属性名称和两个元素组成,这些元素可以是单独的名称、变量名称或数据值。
在这里插入图片描述
在这里插入图片描述

5.4

由于 OWL 不支持复杂的属性描述,因此属性原子只需要一个属性名称。

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

相同(不同)的个体原子在个体名称和变量名称的集合之间断言相等(不等)。
在这里插入图片描述
在这里插入图片描述

5.5

可以在变量名称和单个名称的组合之间断言(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> 

内置原子提供了内置函数的接口。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
此元素仅用于引用变量 ID,与var axiom不同,它实际上并未定义任何变量 。

5.6 规则示例

1.使用 SWRL 来断言hasParent 和hasBrother属性的组合意味着hasUncle属性。

<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.该规则表达了这样一个事实,即,在了解某些 ULAN 艺术家(例如,梵高是印象派画家)的 AAT 风格的情况下,我们可以从艺术对象的创建者的值(由 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.它表达了这样一个事实:对于每个机场,都有一个地图Point与机场具有相同的 位置(纬度和经度),并且它是“图层”(地图 DrawingLayer)的对象。此外,该地图点将机场作为 底层对象,并将机场名称作为其 标签。

<!-- 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.本体翻译示例显示了使用内置函数转换度量单位。

<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:感谢360网页翻译的大力支持!

原网站

版权声明
本文为[「已注销」]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45799003/article/details/121013934