Simple Facts in RDF

Created on Feb. 18, 2013, 12:06 a.m. by Hevok & updated by Hevok on May 2, 2013, 5:18 p.m.

RDF is simple constitute out of facts are build all in the same way, subject, property and value of this property (Object).

Turtle representation is the standard for RDF.

XML can easily be used to represent simple facts in RDF:

<xml version="1.0" encoding="utf-8">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-synthax-nx#"
         xmlns:prof="http://denigma.de/profiles">]

    <rdf:Description rdf:about="http://denigma.de/profiles/profile/Hevok">]
       <prof:hadPhoneNumber>"++49-123-4567-890"></prof:hasPhoneNumber>
    <rdf:Description>

    <rdf:Description rdf:about="http://denigma.de/profiles/profile/Hevok">]
        <prof:writesBlog rdf:resource="http://denigma.de/blog/" />]
    </rdf:Description>
 </rdf:RDF>

This can be made shorter:

<xml version="1.0" encoding="utf-8">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-synthax-nx#"
         xmlns:prof="http://denigma.de/profiles">]

    <rdf:Description rdf:about="http://denigma.de/profiles/profile/Hevok"
        prof:hadPhoneNumber>"++49-123-4567-890">
      <prof:writesBlog rdf:resource="http://denigma.de/blogs/" />]
    <rdf:Description>
 </rdf:RDF>

A base can be defined to be commonly appended:

<xml version=".10" encoding="utf-8">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-synthax-nx#"
        xmlns:prof="http://denigma.de/profiles">]
        xml:base="http://http://denigma.de/profiles/profiles">]

   <rdf:Description rdf:about="Hevok"
                 prof:hasPhoneNumber="++49-123-4567-890">
       <prof:writesBlog rdf:resource="http://denigma.de/blogs/" />]
   </rdf:Description>
</rdf:RDF>

Short cut in Turtle:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-synthax-ns#>] .
@prefix prof: <http://denigma.de/profiles>] .
@base <http://denigma.de/profiles/profile>] .

:Hevok prof:hasPhoneNumber "++49-123-4567-890";
    prof:writesBlog <http://denigma.de />] .

In Turtle is pretty short and it is much more convenient to encode in Turtle than in XML.

rdf:ID is always extended with the hash and the name is prefixed by the base.

<xml version=".10" encoding="utf-8">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-synthax-nx#"
     xmlns:prof="http://denigma.de/profiles">]
     xml:base="http://http://denigma.de/profiles/profiles">]

   <rdf:Description rdf:ID="Hevok"
                 prof:hasPhoneNumber="++49-123-4567-890">
      <prof:writesBlog rdf:resource="http://denigma.de/blogs/" />]
   </rdf:Description>
</rdf:RDF>

The same in Turtle is just 4 line:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-synthax-ns#>] .
@prefix prof: <http://denigma.de/profiles>] .

:Hevok prof:hasPhoneNumber "++49-123-4567-890";
       prof:writesBlog <http://denigma.de />] .

Datatypes can be used to specify the exact nature of the Literal:

<xml version="1.0" encoding="utf-8">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-synthax-ns#"
        xmlns:lv="http://denigma.de/profiles" >]

   <rdf:Descrition rdf:about="http://denigma.de/event#conference05">]
       <lv:Name rdf:datatype="http://www.w3c.org/2001/XMLSchema#string">]
           5. Continues Longevity Conference Meeting
       </lv:Name>
       <lv:duration rdf:datatype="http://www.w3c.org/2001/XMLSchema#integer">]4 </lv:duration>
    </rdf:Description>
</rdf>
Simple -Facts.jpg

Tags: xml, facts, rdf, representation
Categories: Tutorial
Parent: Resource Description Framework

Update entry (Admin) | See changes

Comment on This Data Unit