3

I come cross a books ontology, in the bottom of the document, we have:

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

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 ?

ps: I fully read RDF/XML part that specifies the use of xml:base and rdf:ID and checked in the answer here, just I need further clarification in the context of the ontology defined in the above gist.

quote from 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.

Community
  • 1
  • 1
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
  • Hard to say without knowing the use case. But as an (un-)educated guess, I'd say `isReserved` and `isNotReserved` are business logic properties that are only meant to be used internally and not exported. – dhke Nov 20 '15 at 12:15
  • That's mean that I can't refer to an `rdf:ID` element outside of the scope of the document ? – Salah Eddine Taouririt Nov 20 '15 at 12:16
  • That is the recommendation given by some, yes. But it's not a formal constraint. Both `rdf:about` and `rdf:ID` are global. `rdf:ID` is always relative to `xml:base#`, whereas `rdf:about` can be absolute. If it is relative, it too is resolved against `xml:base` (but without the `#`). I.e. the above is the same as `rdf:about='#isNotReserved'`. Without more information, there is no definitive way to tell if the author used that convention or if it is just an artifact. – dhke Nov 20 '15 at 12:23
  • The attributes rdf:ID and rdf:about aren't actually part of RDF; they're part of the XML serialization of RDF, called RDF/XML. Since you should be processing RDF documents using RDF libraries, and not depending specifically on the RDF/XML serialization (e.g., see [this answer](http://stackoverflow.com/a/17052385/1281433)), you should determine what you want the actual *RDF* to be, and then let the RDF/XML serializer take care of producing it, whether it uses rdf:ID or rdf:about. – Joshua Taylor Nov 20 '15 at 13:15
  • @JoshuaTaylor so should I treat them interchangeably ? if they lead to the same concept why should we have two different syntax for the same concept, it's a little bit confusing !? – Salah Eddine Taouririt Nov 20 '15 at 13:19
  • @tarrsalah The RDF/XML serialization *is* very complex, and contains a lot of different ways of doing the same thing. I think it only became so popular because lots of people already had XML processing tools when RDF was getting started. I go into more detail in my answer. – Joshua Taylor Nov 20 '15 at 13:22
  • 1
    For all that it matters, it is probably a good idea to avoid OWL/RDF for "pure" OWL ontologies altogether if you don't have a good reason to use it. Because --frankly-- RDF/XML is unreadable and quite often unteachable. – dhke Nov 20 '15 at 13:33
  • @dhke There are plenty of other much more readable syntaxes for RDF, though. That said, with OWL, there are two levels of translation. First, the OWL ontology gets mapped to an RDF graph (which is just a collection of triples). Then that RDF graph gets serialized in some particular format (e.g., RDF/XML (yuck), Turtle (nice), or N-Triples (no comment)). Since there are two layers of translation, it *does* get ugly, but much more so with RDF/XML than with other RDF serializations. That said, if there's no need for RDF, using a pure OWL serialization like OWL/XML or OWL/FSS can be nicer. – Joshua Taylor Nov 20 '15 at 13:37

1 Answers1

3

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 ?

It shouldn't really matter. Ideally, the author wasn't manipulating the RDF/XML by hand anyway, and was using a library to write the serialization. The rdf:ID and rdf:about properties aren't actually part of the RDF graph; they're just used in the XML serialization of RDF called RDF/XML. Tools shouldn't depend on the particular structure of the RDF/XML serialization, since the same RDF graph can be written in RDF/XML in various ways. See, e.g., this answer to How to access OWL documents using XPath in Java? for some examples.

For instance, I downloaded the books.owl file and read it in with Jena and wrote it back out in XML. My new books.owl shows the results. There's no rdf:ID in it at all, but it's exactly the same RDF graph. An RDF processing tool sees exactly the same graph, i.e., the same collection of triples. One of the properties that used rdf:ID is now serialized as

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

Although, in practice, you might prefer to use rdf:about in preference to rdf:ID, it's not officially deprecated or anything. It's still used in the RDF/XML 1.1 spec, for instance, as described in §2.14 Abbreviating URIs: rdf:ID and xml:base.

In practice, it's probably a better idea to use a more human-readable and human-writable syntax, like Turtle. The same Gist shows the results of rewriting the ontology in Turtle, books.ttl. With Turtle, you get to write the triples directly, and don't have to worry about rdf:ID or rdf:about. In Turtle, that property declaration becomes:

:isNotReserved a owl:ObjectProperty ;
    rdfs:comment "The given book is available in the library."^^<http://www.w3.org/2001/XMLSchema#string> ;
    rdfs:domain :Book .
Community
  • 1
  • 1
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • can we say just that using rdf:ID is deprecated ? – Salah Eddine Taouririt Nov 20 '15 at 13:23
  • 2
    @tarrsalah You can avoid using it if you like, but you can't say it's deprecated. It's still officially supported, and mentioned in the spec. I updated my answer. – Joshua Taylor Nov 20 '15 at 13:25
  • It's not deprecated, it's just - in this case - an equivalent alternative. It's a serialization detail which can be ignored in the vast majority of situations. – Ignazio Nov 20 '15 at 19:01