---
title: "OWL 实例描述"
author: "qq17906"
date: "2009-03-27T00:15:22Z"
tags: ["XML", "制造"]
slug: "owl"
draft: false
lastmod: "2009-03-27T00:15:22Z"
id: 355848
url: "https://badeggs.iteye.com/blog/355848"
---

\-------------------------------------------------------  
rdfs:subClassOf 描述

 &lt;owl:Class rdf:ID="Wine"&gt;  
   &lt;rdfs:subClassOf rdf:resource="&food;PotableLiquid"/&gt;  
   &lt;rdfs:label xml:lang="en"&gt;wine&lt;/rdfs:label&gt;  
   &lt;rdfs:label xml:lang="fr"&gt;vin&lt;/rdfs:label&gt;  
 &lt;/owl:Class&gt;

Wine PotableLiquid  
\--------------------------------------------------------  
ObjectProperty   描述 wine hasWinDescriptor WineDescriptor

 &lt;owl:ObjectProperty rdf:ID="hasWineDescriptor"&gt;  
   &lt;rdfs:domain rdf:resource="#Wine" /&gt;  
   &lt;rdfs:range  rdf:resource="#WineDescriptor" /&gt;  
 &lt;/owl:ObjectProperty&gt;

\-------------------------------------------------------  
DatatypeProperty 描述 VintageYear is 1998

  &lt;owl:DatatypeProperty rdf:ID="yearValue"&gt;  
    &lt;rdfs:domain rdf:resource="#VintageYear" /&gt;     
    &lt;rdfs:range  rdf:resource="&xsd;positiveInteger" /&gt;  
  &lt;/owl:DatatypeProperty&gt;  
   
  &lt;VintageYear rdf:ID="Year1998"&gt;  
    &lt;yearValue rdf:datatype="&xsd;positiveInteger"&gt;1998&lt;/yearValue&gt;  
  &lt;/VintageYear&gt;

  &lt;owl:ObjectProperty rdf:ID="hasVintageYear"&gt;  
    &lt;rdf:type rdf:resource="&owl;FunctionalProperty" /&gt;  
    &lt;rdfs:domain rdf:resource="#Vintage" /&gt;  
    &lt;rdfs:range  rdf:resource="#VintageYear" /&gt;  
  &lt;/owl:ObjectProperty&gt;

Vintage has VintageYear that is 1998 ------ 葡萄酒的年份是1998 或 1998的葡萄酒

\--------------------------------------------------------  
个体(individual) 描述

 &lt;owl:Class rdf:ID="WineGrape"&gt;  
   &lt;rdfs:subClassOf rdf:resource="&food;Grape" /&gt;  
 &lt;/owl:Class&gt;  
 &lt;WineGrape rdf:ID="CabernetSauvignonGrape" /&gt;

CabernetSauvignonGrape is WineGrape ---- 赤霞珠葡萄树

----------------------属性特性------------------------  
TransitiveProperty 描述  
SymmetricProperty  描述

&lt;owl:Class rdf:ID="Region" /&gt;

&lt;owl:ObjectProperty rdf:ID="locatedIn"&gt;  
   &lt;rdf:type rdf:resource="&owl;TransitiveProperty" /&gt;  
   &lt;rdfs:domain rdf:resource="[http://www.w3.org/2002/07/owl#Thing](http://www.w3.org/2002/07/owl#Thing)" /&gt;  
   &lt;rdfs:range rdf:resource="#Region" /&gt;  
&lt;/owl:ObjectProperty&gt;

&lt;owl:ObjectProperty rdf:ID="adjacentRegion"&gt;  
  &lt;rdf:type rdf:resource="&owl;SymmetricProperty" /&gt;  
  &lt;rdfs:domain rdf:resource="#Region" /&gt;  
  &lt;rdfs:range rdf:resource="#Region" /&gt;  
&lt;/owl:ObjectProperty&gt;

\--------------------------------------------  
FunctionalProperty   描述 一个给定的 Vintage个体只能使用hasVintageYear属性与单独一个年份相关联

 &lt;owl:Class rdf:ID="VintageYear" /&gt;  
 &lt;owl:ObjectProperty rdf:ID="hasVintageYear"&gt;  
   &lt;rdf:type rdf:resource="&owl;FunctionalProperty" /&gt;  
   &lt;rdfs:domain rdf:resource="#Vintage" /&gt;  
   &lt;rdfs:range  rdf:resource="#VintageYear" /&gt;  
 &lt;/owl:ObjectProperty&gt;  
\---------------------------------------------  
 inverseOf  描述 各种葡萄酒都有制造商

 &lt;owl:ObjectProperty rdf:ID="hasMaker"&gt;  
   &lt;rdf:type rdf:resource="&owl;FunctionalProperty" /&gt;  
 &lt;/owl:ObjectProperty&gt;    
 &lt;owl:ObjectProperty rdf:ID="producesWine"&gt;  
   &lt;owl:inverseOf rdf:resource="#hasMaker" /&gt;  
 &lt;/owl:ObjectProperty&gt;

\---------------------------------------------  
 InverseFunctionalProperty 

 &lt;owl:ObjectProperty rdf:ID="hasMaker" /&gt;  
 &lt;owl:ObjectProperty rdf:ID="producesWine"&gt;  
   &lt;rdf:type rdf:resource="&owl;InverseFunctionalProperty" /&gt;  
   &lt;owl:inverseOf rdf:resource="#hasMaker" /&gt;  
 &lt;/owl:ObjectProperty&gt;

 owl:InverseFunctional意味着属性的值域中的元素为定义域中的每个元素提供了一个唯一的标识

 ---属性限制------  
 -------------------------  
 allValuesFrom   描述 Wine的制造商必须是Winery。  
 owl:someValuesFrom替换owl:allValuesFrom，那就意味着至少有一个Wine类实例的hasMaker属性是指向一个Winery类的个体的。

 &lt;owl:Class rdf:ID="Wine"&gt;  
   &lt;rdfs:subClassOf rdf:resource="&food;PotableLiquid" /&gt;  
   ...  
   &lt;rdfs:subClassOf&gt;  
     &lt;owl:Restriction&gt;  
       &lt;owl:onProperty rdf:resource="#hasMaker" /&gt;  
       &lt;owl:allValuesFrom rdf:resource="#Winery" /&gt;  
     &lt;/owl:Restriction&gt;  
   &lt;/rdfs:subClassOf&gt;  
    
   ...  
 &lt;/owl:Class&gt;

 -------------------------------------------------------  
 owl:cardinality  描述  允许对一个关系中的元素数目作出精确的限制

  &lt;owl:Class rdf:ID="Vintage"&gt;  
   &lt;rdfs:subClassOf&gt;  
     &lt;owl:Restriction&gt;  
       &lt;owl:onProperty rdf:resource="#hasVintageYear"/&gt;  
       &lt;owl:cardinality rdf:datatype="&xsd;nonNegativeInteger"&gt;1&lt;/owl:cardinality&gt;  
     &lt;/owl:Restriction&gt;  
   &lt;/rdfs:subClassOf&gt;  
 &lt;/owl:Class&gt;

 每瓶葡萄酒只有一个年度

 -------------------------------------------------------  
 hasValue  描述 一个个体只要至少有“一个”属性值等于hasValue的资源，这一个体就是该类的成员。

  &lt;owl:Class rdf:ID="Burgundy"&gt;  
   ...  
   &lt;rdfs:subClassOf&gt;  
     &lt;owl:Restriction&gt;  
       &lt;owl:onProperty rdf:resource="#hasSugar" /&gt;  
       &lt;owl:hasValue rdf:resource="#Dry" /&gt;  
     &lt;/owl:Restriction&gt;  
   &lt;/rdfs:subClassOf&gt;  
 &lt;/owl:Class&gt;

 所有的Burgundy酒都是干(dry)的酒。也即，它们的hasSugar属性必须至少有一个是值等于Dry（干的）

\------------------------------------------------------  
 本体映射  
 类和属性之间的等价关系－－equivalentClass, equivalentProperty

 &lt;owl:Class rdf:ID="TexasThings"&gt;  
   &lt;owl:equivalentClass&gt;  
     &lt;owl:Restriction&gt;  
       &lt;owl:onProperty rdf:resource="#locatedIn" /&gt;  
       &lt;owl:someValuesFrom rdf:resource="#TexasRegion" /&gt;  
     &lt;/owl:Restriction&gt;  
   &lt;/owl:equivalentClass&gt;  
 &lt;/owl:Class&gt;

 TexasThings指的是那些恰好位于TexasRegion的事物。使用owl:equivalentClass 和使用rdfs:subClassOf 的不同就像必要条件和充要条件的不同一样。如果是使用subClassOf的话，位于TexasRegion的事物不一定是TexasThings。但是，如果使用owl:equivalentClass，位于TexasRegion的事物一定属于TexasThings类。

\------------------------------------------------------  
个体间的同一性 －sameAs

 &lt;Wine rdf:ID="MikesFavoriteWine&gt;  
     &lt;owl:sameAs rdf:resource="#StGenevieveTexasWhite" /&gt;  
 &lt;/Wine&gt;

 修饰（或引用）两个类用sameAs还是用equivalentClass效果是不同的。用sameAs的时候，把一个类解释为一个个体，就像在OWL Full中一样，这有利于对本体进行分类。

\-----------------------------------------------------  
 不同的个体  
\------------------------------------------------------  
differentFrom

 &lt;WineSugar rdf:ID="Dry" /&gt;  
   
 &lt;WineSugar rdf:ID="Sweet"&gt;  
   &lt;owl:differentFrom rdf:resource="#Dry"/&gt;   
 &lt;/WineSugar&gt;  
   
 &lt;WineSugar rdf:ID="OffDry"&gt;  
   &lt;owl:differentFrom rdf:resource="#Dry"/&gt;  
   &lt;owl:differentFrom rdf:resource="#Sweet"/&gt;  
 &lt;/WineSugar&gt;

 ---------------------------------------------------  
AllDifferent

 &lt;owl:AllDifferent&gt;  
   &lt;owl:distinctMembers rdf:parseType="Collection"&gt;  
     &lt;vin:WineColor rdf:about="#Red" /&gt;  
     &lt;vin:WineColor rdf:about="#White" /&gt;  
     &lt;vin:WineColor rdf:about="#Rose" /&gt;  
   &lt;/owl:distinctMembers&gt;  
 &lt;/owl:AllDifferent&gt;

 owl:distinctMembers属性声明只能和owl:AllDifferent属性声明一起结合使用。

 -----------------------------------------------------  
 intersectionOf

 &lt;owl:Class rdf:ID="WhiteWine"&gt;  
   &lt;owl:intersectionOf rdf:parseType="Collection"&gt;  
     &lt;owl:Class rdf:about="#Wine" /&gt;  
     &lt;owl:Restriction&gt;  
       &lt;owl:onProperty rdf:resource="#hasColor" /&gt;  
       &lt;owl:hasValue rdf:resource="#White" /&gt;  
     &lt;/owl:Restriction&gt;  
   &lt;/owl:intersectionOf&gt;  
 &lt;/owl:Class&gt;

 WhiteWine恰好是类Wine与所有颜色是白色的事物的集合的交集

 -----------------------------------------------------  
 unionOf

 &lt;owl:Class rdf:ID="Fruit"&gt;  
   &lt;owl:unionOf rdf:parseType="Collection"&gt;  
     &lt;owl:Class rdf:about="#SweetFruit" /&gt;  
     &lt;owl:Class rdf:about="#NonSweetFruit" /&gt;  
   &lt;/owl:unionOf&gt;  
 &lt;/owl:Class&gt;

 ------------------------------------------------------  
 complementOf 从某个论域(domain of discourse)选出不属于某个类的所有个体

 &lt;owl:Class rdf:ID="NonFrenchWine"&gt;  
   &lt;owl:intersectionOf rdf:parseType="Collection"&gt;  
     &lt;owl:Class rdf:about="#Wine"/&gt;  
      
     &lt;owl:Class&gt;  
       &lt;owl:complementOf&gt;  
         &lt;owl:Restriction&gt;  
           &lt;owl:onProperty rdf:resource="#locatedIn" /&gt;  
           &lt;owl:hasValue rdf:resource="#FrenchRegion" /&gt;  
         &lt;/owl:Restriction&gt;  
       &lt;/owl:complementOf&gt;  
     &lt;/owl:Class&gt;  
   &lt;/owl:intersectionOf&gt;  
 &lt;/owl:Class&gt;

 -----------------------------------------------------------  
 oneOf  枚举

 &lt;owl:Class rdf:ID="WineColor"&gt;  
   &lt;rdfs:subClassOf rdf:resource="#WineDescriptor"/&gt;  
   &lt;owl:oneOf rdf:parseType="Collection"&gt;  
     &lt;owl:Thing rdf:about="#White"/&gt;  
     &lt;owl:Thing rdf:about="#Rose"/&gt;  
     &lt;owl:Thing rdf:about="#Red"/&gt;  
   &lt;/owl:oneOf&gt;  
 &lt;/owl:Class&gt;

 有效的个体声明

 -----------------------------------------------------------  
 disjointWith  不相交类  保证了属于某一个类的个体不能同时又是另一个指定类的实例

 &lt;owl:Class rdf:ID="Pasta"&gt;  
   &lt;rdfs:subClassOf rdf:resource="#EdibleThing"/&gt;  
   &lt;owl:disjointWith rdf:resource="#Meat"/&gt;  
   &lt;owl:disjointWith rdf:resource="#Fowl"/&gt;  
   &lt;owl:disjointWith rdf:resource="#Seafood"/&gt;  
   &lt;owl:disjointWith rdf:resource="#Dessert"/&gt;  
   &lt;owl:disjointWith rdf:resource="#Fruit"/&gt;  
 &lt;/owl:Class&gt;

Pasta与其它所有类是不相交的。例如，它并没有保证Meat和Fruit是不相交的