为什么我们需要使用rdf:parseType ="Collection"与owl:intersectionOf? [英] Why do we need to use rdf:parseType="Collection" with owl:intersectionOf?

查看:108
本文介绍了为什么我们需要使用rdf:parseType ="Collection"与owl:intersectionOf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下示例,该示例取自 http://www.w3. org/TR/owl-ref/#intersectionOf-def .

Conside the following example taken from, http://www.w3.org/TR/owl-ref/#intersectionOf-def.

<owl:Class>
  <owl:intersectionOf rdf:parseType="Collection">
    <owl:Class>
      <owl:oneOf rdf:parseType="Collection">
        <owl:Thing rdf:about="#Tosca" />
        <owl:Thing rdf:about="#Salome" />
      </owl:oneOf>
    </owl:Class>
    <owl:Class>
      <owl:oneOf rdf:parseType="Collection">
        <owl:Thing rdf:about="#Turandot" />
        <owl:Thing rdf:about="#Tosca" />
      </owl:oneOf>
    </owl:Class>
  </owl:intersectionOf>
</owl:Class>

虽然我们了解第二个和第三个rdf:parseType="Collection"的用法,但在owl:intersectionOf之后,我对第一个用法有些困惑.

While we understand the usage of the second and third rdf:parseType="Collection", I am somewhat confused about the first usage, just after owl:intersectionOf.

在此示例中,owl:intersectionOf的值是两个类描述的列表,即两个枚举,都用两个人描述了一个类.结果交集是一个具有一个个体的类,即Tosca,因为这是两个枚举所共有的唯一个体.

In this example the value of owl:intersectionOf is a list of two class descriptions, namely two enumerations, both describing a class with two individuals. The resulting intersection is a class with one individual, namely Tosca, as this is the only individual that is common to both enumerations.

如果我们省略第一个rdf:parseType="Collection"会发生什么?

What would have happened if we left out the first rdf:parseType="Collection"?

如果相交的类不是 集合,我们还需要使用第一个rdf:parseType="Collection"吗?

Do we still need to use the first rdf:parseType="Collection", if the intersecting classes are not collections?

推荐答案

owl:intersectionOf的值应该是RDF列表. RDF列表是链接列表,其中node的元素由rdf:first指示,列表的尾部由rdf:rest指示,空列表由rdf:nil指示.可以想象,这很快变得非常冗长.使用 parseType集合属性.它不是三元组,而是RDF/XML序列化的简写.

The value of owl:intersectionOf is supposed to be an RDF list. RDF lists are linked lists, where the element of node is indicated by rdf:first and the tail of the list by rdf:rest, and the empty list is indicated by rdf:nil. As you can imagine, that quickly becomes very verbose. The serialization can be shorter by using the parseType Collection attribute. It's not a triple, it's just a shorthand in the RDF/XML serialization.

以下是您的代码段的完整版本:

Here's a complete version of your snippet:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <owl:Class>
    <owl:intersectionOf rdf:parseType="Collection">
      <owl:Class>
        <owl:oneOf rdf:parseType="Collection">
          <owl:Thing rdf:about="urn:ex#Tosca"/>
          <owl:Thing rdf:about="urn:ex#Salome"/>
        </owl:oneOf>
      </owl:Class>
      <owl:Class>
        <owl:oneOf rdf:parseType="Collection">
          <owl:Thing rdf:about="urn:ex#Turandot"/>
          <owl:Thing rdf:about="urn:ex#Tosca"/>
        </owl:oneOf>
      </owl:Class>
    </owl:intersectionOf>
  </owl:Class>
</rdf:RDF>

如果在N-Triples中进行序列化,则可以看到所有实际的三元组:

You can see all the actual triples if you serialize in N-Triples:

_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffd <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffe .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffd <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff9 .
<urn:ex#Tosca> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <urn:ex#Turandot> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff7 .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffb <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <urn:ex#Salome> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffb <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffe <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffe <http://www.w3.org/2002/07/owl#oneOf> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffc .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffc <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <urn:ex#Tosca> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffc <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffb .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffa .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
<urn:ex#Turandot> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
<urn:ex#Salome> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <urn:ex#Tosca> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffa <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffa <http://www.w3.org/2002/07/owl#oneOf> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ff8 .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7fff <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
_:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7fff <http://www.w3.org/2002/07/owl#intersectionOf> _:BX2D2b2d7d1aX3A1526aea91dcX3AX2D7ffd .

很多rdf:first和rdf:rest三元组.如果未在RDF/XML中使用该缩写,则会得到相同的结果:

That's a lot of rdf:first and rdf:rest triples. You get the same if you don't use that abbreviation in RDF/XML:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > 
  <rdf:Description rdf:nodeID="A0">
    <rdf:first rdf:resource="urn:ex#Tosca"/>
    <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A1">
    <rdf:first rdf:resource="urn:ex#Turandot"/>
    <rdf:rest rdf:nodeID="A0"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A2">
    <rdf:first rdf:nodeID="A3"/>
    <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
  </rdf:Description>
  <rdf:Description rdf:about="urn:ex#Salome">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
  </rdf:Description>
  <rdf:Description rdf:about="urn:ex#Tosca">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
  </rdf:Description>
  <rdf:Description rdf:about="urn:ex#Turandot">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A3">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
    <owl:oneOf rdf:nodeID="A1"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A4">
    <rdf:first rdf:resource="urn:ex#Salome"/>
    <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A5">
    <rdf:first rdf:resource="urn:ex#Tosca"/>
    <rdf:rest rdf:nodeID="A4"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A6">
    <rdf:first rdf:nodeID="A7"/>
    <rdf:rest rdf:nodeID="A2"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A7">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
    <owl:oneOf rdf:nodeID="A5"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A8">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
    <owl:intersectionOf rdf:nodeID="A6"/>
  </rdf:Description>
</rdf:RDF>

因此,我们使用了简洁的速记,RDF/XML的parseType集合或Turtle的括号:

As a result, we use nice shorthands, RDF/XML's parseType collection, or Turtle's parentheses:

@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<urn:ex#Tosca>  a  owl:Thing .

_:b0    a          owl:Class ;
        owl:oneOf  ( <urn:ex#Tosca> <urn:ex#Salome> ) .

[ a                   owl:Class ;
  owl:intersectionOf  ( _:b0 _:b1 )
] .

_:b1    a          owl:Class ;
        owl:oneOf  ( <urn:ex#Turandot> <urn:ex#Tosca> ) .

<urn:ex#Turandot>  a  owl:Thing .

<urn:ex#Salome>  a  owl:Thing .

如果没有属性会发生什么

如果我们省略第一个rdf:parseType="Collection"会发生什么?

从有关解析类型集合的文档中:

From the documentation on parse type collection:

RDF/XML允许属性元素上的rdf:parseType ="Collection"属性使其包含多个节点元素.

RDF/XML allows an rdf:parseType="Collection" attribute on a property element to let it contain multiple node elements.

这表明没有解析类型集合属性,则属性元素不应包含多个元素.您想阅读 2.2节点元素和属性元素,以了解典型的语法.一般来说,这个想法是代表三元组

That suggests that without a parse type collection attribute, then a property element shouldn't contain more than one element. You'd want to read in 2.2 Node Elements and Property Elements to see what the typical syntax is. In general, the idea is that to represent the triples

x:s  x:p1  x:q1 .
x:s  x:p2  x:q2 .

您最终得到的XML像:

you end up with XML like:

<rdf:Description rdf:about="...s">        <!-- a node element -->
  <x:p1>                                  <!-- a property element -->
    <rdf:Description rdf:about="...q1"/>  <!-- a node element -->
  </x:p1>
</rdf:Description>
<rdf:Description rdf:about="...s">        <!-- a node element -->
  <x:p2>                                  <!-- a property element -->
    <rdf:Description rdf:about="...q2"/>  <!-- a node element -->
  </x:p2>
</rdf:Description>

现在,有一个简写可以让您在节点元素中使用多个属性元素. 2.3多个属性元素,然后让您执行此操作:

Now, there's a shorthand that lets you use multiple property elements within a node element. That's described in 2.3 Multiple Property Elements, and lets you do this instead:

<rdf:Description rdf:about="...s">        <!-- a node element -->
  <x:p1>                                  <!-- a property element -->
    <rdf:Description rdf:about="...q1"/>  <!-- a node element -->
  </x:p1>
  <x:p2>                                  <!-- a property element -->
    <rdf:Description rdf:about="...q2"/>  <!-- a node element -->
  </x:p2>
</rdf:Description>

但是,没有这样的简写可以让您在单个属性元素中添加多个对象.也就是说,您不能缩写三元组

However, there's no such shorthand to let you add multiple objects within a single property element. That is, you cannot abbreviate the triples

x:s  x:p1  x:q1 .
x:s  x:p1  x:q2 .

作者

<rdf:Description rdf:about="...s">        <!-- a node element -->
  <x:p1>                                  <!-- a property element -->
    <rdf:Description rdf:about="...q1"/>  <!-- a node element -->
    <rdf:Description rdf:about="...q2"/>  <!-- a node element -->
  </x:p1>
</rdf:Description>

如果您有一个集合,然后从其中删除了解析类型集合属性,那将是最终的结果.我想这本来是个不错的功能,但也许它的标准中还有其他部分会与之冲突.无论如何,这就是为什么您尝试时会收到警告的原因;这是不合法的.

That's what you would end up with if you had a collection and then removed the parse type collection attribute from it. It would have been a nice feature I suppose, but maybe there's some other part of the standard that it would conflict with. Anyhow, that's why you get a warning when you try; it's not legal.

如果相交的类不是集合,是否还需要使用第一个rdf:parseType ="Collection"?

Do we still need to use the first rdf:parseType="Collection", if the intersecting classes are not collections?

如上所述,RDF/XML是RDF的序列化,而RDF是抽象数据模型(只是三倍). RDF/XML增加了许多您不必担心的复杂性.使用OWL文件这一事实使事情变得更加复杂,因为OWL是另一种抽象表示形式(仅是公理).从OWL到RDF都有一个映射,这很复杂.因此,您正在查看具有两层编码的内容:

As I noted above, RDF/XML is a serialization of RDF, and RDF is an abstract data model (it's just triples). RDF/XML adds lots of complexity that you shouldn't have to worry about. The fact that you're working with an OWL file makes things even more complex, because OWL is another abstract representation (it's just axioms). There's a mapping from OWL to RDF, which is kind of complicated. So you're looking at something that's got two layers of encoding:

    OWL(轴)⇒ RDF(三倍)⇒ RDF/XML

    OWL (axioms) ⇒ RDF (triples) ⇒ RDF/XML

OWL对解析类型集合和RDF/XML序列化一无所知,只知道OWL.有一个映射了解OWL和RDF,这就是产生RDF三元组的原因. RDF对解析类型集合一无所知.从RDF到XML的映射都知道这一点.您的RDF必须是合法的RDF,期限.

OWL doesn't know anything about parse type collection and RDF/XML serialization, it just knows about OWL. There's a mapping that knows about OWL and about RDF, and that's what produces the RDF triples. RDF doesn't know anything about parse type collection. There's a mapping from RDF to XML that knows about it. Your RDF needs to be legal RDF, period.

如果您正在使用OWL,请使用OWL工具.
如果您使用的是RDF,请使用RDF工具.
如果您使用的是XML,请使用XML工具.

If you're working with OWL, use OWL tools.
If you're working with RDF, use RDF tools.
If you're working with XML, use XML tools.

这篇关于为什么我们需要使用rdf:parseType ="Collection"与owl:intersectionOf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆