0

There are similar questions and answers. However, none of previous gave examples.

Here is rdfs code.

<?xml version="1.0"?>

<rdf:RDF 
xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base=  "localhost:3000/animal#">

<rdfs:Class rdf:ID="animal" />

<rdfs:Class rdf:ID="horse">
  <rdfs:subClassOf rdf:resource="#animal"/>
</rdfs:Class>

</rdf:RDF>

It was hosted on localhost:3000/animal.

Here is rdf code.

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns:animal="localhost:3000/animal#">

<rdf:Description
 rdf:about="http://www.recshop.fake/things">
  <animal:horse>abc</animal:horse>
</rdf:Description>


</rdf:RDF>

It was hosted on localhost:3000/horseinstance.

Is this the right way how rdfs and rdf related?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
AlexWei
  • 1,093
  • 2
  • 8
  • 32

1 Answers1

2

Is this the right way how rdfs and rdf related?

This part of the question is a bit unclear. RDF is a data representation based on triples of the form (subject, predicate, object), where a subject is an IRI or blank node, predicate is an IRI, and object is an IRI, blank node, or literal. The RDF standard prescribes some special meaning for some certain IRIs, but that's the meaning that everyone has agreed to let them mean. RDFS is a schema language for RDF. It's just some more assigned meanings for some more IRIs, like rdfs:subClassOf and rdfs:Class.

Based on the RDF snippets you've shown us, I think you're asking us whether, based on the RDFS you've shown, the RDF uses the RDFS schema in an appropriate or conventional way. The answer there is "not really." It might be easier if you look at the triples of your data, rather than the RDF/XML serialization of them. The RDFS file has three triples:

<localhost:3000/animal#animal> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<localhost:3000/animal#horse> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<localhost:3000/animal#horse> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <localhost:3000/animal#animal> .

Your RDF file has one:

<http://www.recshop.fake/things> <localhost:3000/animal#horse> "abc" .

It's all legal RDF, so in that sense, it's "OK", but your RDFS declared horse and animal as classes, and that horse is a subclass of animal. You're now using horse as predicate that relates the resource things to the literal "abc". Typically, you'd use a declared class, like horse, as the object of a triple whose predicate is rdf:type, to indicate that the subject is a member of that class. E.g., you'd say something like:

<http://example.org/BlackBeauty> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <localhost:3000/animal#horse> .

In RDF/XML, that would look like:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:animal="localhost:3000/animal#">
  <animal:horse rdf:about="http://example.org/BlackBeauty"/>
</rdf:RDF>

or this (since the same RDF graph can be serialized in RDF/XML in a number of ways):

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:animal="localhost:3000/animal#" > 
  <rdf:Description rdf:about="http://example.org/BlackBeauty">
    <rdf:type rdf:resource="localhost:3000/animal#horse"/>
  </rdf:Description>
</rdf:RDF>
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353