我什么时候应该使用 rdf:ID 而不是 rdf:about?

When should I use rdf:ID instead of rdf:about?

我来翻阅一份books ontology, in the bottom of the 文档,我们有:

<!-- Object Properties -->
<owl:ObjectProperty rdf:about="#contains"/>
<owl:ObjectProperty rdf:about="#datePublished"/>
<owl:ObjectProperty rdf:about="#hasGenre"/>
<owl:ObjectProperty rdf:about="#hasGrade"/>
<owl:ObjectProperty rdf:about="#hasName"/>
<owl:ObjectProperty rdf:about="#hasSize"/>
<owl:ObjectProperty rdf:about="#hasType"/>
<owl:ObjectProperty rdf:about="#isTitled"/>
<owl:ObjectProperty rdf:about="#publishedBy"/>
<owl:ObjectProperty rdf:about="#timePublished"/>
<owl:ObjectProperty rdf:about="#writtenBy"/> 
<owl:ObjectProperty rdf:ID="isReserved">
<rdfs:domain rdf:resource="#Book"/>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>A reservation has been made by a person for a book.</rdfs:comment>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="isNotReserved">
<rdfs:domain rdf:resource="#Book"/>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>The given book is available in the library.</rdfs:comment>
</owl:ObjectProperty>
</rdf:RDF>

我只是不明白为什么这个ontology的作者选择在最后两个owl:ObjectPropertyisReservedisNotReserved) 而不是像其他的那样只使用 rdf:about ?

ps:我完全阅读了 RDF/XML part that specifies the use of xml:base and rdf:ID and checked in the answer here,只是我需要在上述要点中定义的 ontology 的上下文中进一步说明.

引自RDF/XML specs

The rdf:ID attribute on a node element (not property element, that has another meaning) can be used instead of rdf:about and gives a relative IRI equivalent to # concatenated with the rdf:ID attribute value. So for example if rdf:ID="name", that would be equivalent to rdf:about="#name". rdf:ID provides an additional check since the same name can only appear once in the scope of an xml:base value (or document, if none is given), so is useful for defining a set of distinct, related terms relative to the same IRI.

I just can't understand why the author of this ontology choose to use rdf:ID in in the last two owl:ObjectProperty (isReserved and isNotReserved) instead of just using rdf:about like the rest ?

应该没什么大不了的。理想情况下,作者无论如何都不会手动操作 RDF/XML,而是使用库来编写序列化。 rdf:ID 和 rdf:about 属性实际上并不是 RDF 图的一部分;它们仅用于称为 RDF/XML 的 XML RDF 序列化。工具不应依赖于 RDF/XML 序列化的特定结构,因为可以用多种方式将相同的 RDF 图写入 RDF/XML。例如,请参阅 this answer to How to access OWL documents using XPath in Java? 以获取一些示例。

例如,我下载了 books.owl 文件并用 Jena 读入,然后在 XML 中写回。我的新 books.owl 显示了结果。其中根本没有 rdf:ID,但 完全 相同的 RDF 图。 RDF 处理工具看到完全相同的图,即相同的三元组集合。使用 rdf:ID 的属性之一现在序列化为

<owl:ObjectProperty rdf:about="http://127.0.0.1:3001/ontology/books.owl#isNotReserved">
  <rdfs:domain rdf:resource="http://127.0.0.1:3001/ontology/books.owl#Book"/>
  <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
  >The given book is available in the library.</rdfs:comment>
</owl:ObjectProperty>

尽管在实践中,您可能更喜欢使用 rdf:about 而不是 rdf:ID,但它并未正式弃用或其他任何东西。它仍在 RDF/XML 1.1 规范中使用,例如,如 §2.14 Abbreviating URIs: rdf:ID and xml:base.

中所述

在实践中,使用更易于阅读和编写的语法(如 Turtle)可能是更好的主意。同样的 Gist 显示了在 Turtle books.ttl 中重写 ontology 的结果。使用 Turtle,您可以直接编写三元组,而不必担心 rdf:ID 或 rdf:about。在 Turtle 中,属性 声明变为:

:isNotReserved a owl:ObjectProperty ;
    rdfs:comment "The given book is available in the library."^^<http://www.w3.org/2001/XMLSchema#string> ;
    rdfs:domain :Book .