rdfrdf-xml

Why are there triples with rdf:type predicates for my RDF graph?


This is my RDF graph represented in RDF/XML fromat:

<?xml version="1.0" ?>
<rdf:RDF 
   xmlns:ex="http://www.example#" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xml:base="http://www.test#">
   
   <ex:cat rdf:ID="_101">
      <ex:name>Milk</ex:name>
   </ex:cat>
   <ex:dog rdf:ID="_2001">
      <ex:name>Lub</ex:name>
   </ex:dog>
</rdf:RDF>

These are the triples I get when I parse it with w3.org/RDF/Validator:

Number   Subject                Predicate   Object
1        http://www.test#_101   rdf:type    ex:cat
2        http://www.test#_101   ex:name     "Milk"
3        http://www.test#_2001  rdf:type    ex:dog
4        http://www.test#_2001  ex:name     "Lub"

My question is why are there triples with rdf:type predicate? Which parts of my RDF/XML get mapped to those triples?


Solution

  • Let's analyse the following RDF/XML syntax:

    <ex:cat rdf:ID="_101">
       <ex:name>Milk</ex:name>
    </ex:cat>
    

    In says that entity with id http://www.test#_101 of type ex:cat exists and that it has a property ex:name, with value "Milk". Thats why you get triples

    http://www.test#_101   rdf:type    ex:cat
    http://www.test#_101   ex:name     "Milk"
    

    Whenever you have statement about an entity in RDF/XML it would start with

    <TYPE_URI rdf:ID=ENTITY_ID>
    

    which translates to a triple

    TYPE  rdf:type  ENTITY_ID
    

    proceeding with statements about property-value pairs for that entity. At the end you get the standard XML closing tag </TYPE_URI>.