3

I am a beginner in writing a RDF schema and was wondering how should I make a good use of URI concept and create a RDFs doc of simple interest. I am trying to create a RDF of following statement-

Jeffy is a Graduate student
Jeffy likes yoga
Jeffy is seeking Tennis.

How should I write a RDF based on these three sentences. Any light on this would be really helpful.

unor
  • 92,415
  • 26
  • 211
  • 360
AKIWEB
  • 19,008
  • 67
  • 180
  • 294

3 Answers3

6

Can I recommend that you don't use RDF/XML? It's quite a complex syntax format to learn to write by hand. You're better off writing your RDF using something like Turtle syntax, in which case your example would be something like:

@prefix my: <http://example.org/mynamespace/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

my:jeffy rdf:type my:GraduateStudent ;
         my:likes my:yoga ;
         my:isSeeking my:Tennis .

If you must have RDF/XML for one reason or another, consider using any RDF parser toolkit (OpenRDF Sesame, Apache Jena, dotNetRDF, etc.) to convert from one syntax to another.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
3

You could use OWL instead of RDFs because:

1) It is a superset of RDFs

2) It is more powerful

For example:

<?xml version="1.0"?>

<!DOCTYPE rdf:RDF [
  <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
  <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
  <!ENTITY base "http://www.example.com/example/" >
  ]>

<rdf:RDF
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
   xmlns:owl="http://www.w3.org/2002/07/owl#"
   xmlns:base="http://www.example.com/example/"
   >

  <owl:Class rdf:about="#GraduateStudent" />

  <owl:DatatypeProperty rdf:about="&base;Likes">
    <rdfs:domain rdf:resource="&base;GraduateStudent" />
    <rdfs:range rdf:resource="string" />
  </owl:DatatypeProperty>

  <owl:DatatypeProperty rdf:about="&base;IsSeeking">
    <rdfs:domain rdf:resource="&base;GraduateStudent" />
    <rdfs:range rdf:resource="string" />
  </owl:DatatypeProperty>

  <base:GraduateStudent rdf:about="&base;GraduateStudent/001">
    <base:Likes>yoga</base:Likes>
    <base:IsSeeking>Tennis</base:IsSeeking>
  </base:GraduateStudent>

</rdf:RDF>

You can notice that, the model AND the data are in the same file.

3 importants features:

1) Class: declare a class

2) DatatypeProperty: declare a literal property

3) ObjectProperty (not here): declare a link to another node of the semantic graph

In your case you can create a "Sport" class, change DatatypeProperty by ObjectProperty, update the range and create the instances of the 2 sports.

Galaad
  • 64
  • 1
  • 7
  • Thank you Galaad, can you please clear me if I can use friend of a function(FOAF)? – AKIWEB Aug 15 '12 at 02:27
  • 3
    While you are of course correct that OWL is more expressive than RDFS, I would just like to point out that nothing in the actual example you give actually needs the expressivity of OWL (the only thing that you cannot really express in RDFS is the difference between a DatatypeProperty and an ObjectProperty, but it's questionable whether that distinction is necesssary). – Jeen Broekstra Aug 15 '12 at 02:28
2

FOAF:

You could use foaf:Person for "Jeffy" (you could give the name with foaf:name resp. foaf:givenName resp. foaf:nick).

You could use foaf:interest for the interest in yoga (you would have to use a foaf:Document that represents "yoga", though; see foaf:isPrimaryTopicOf). Or you could use foaf:topic_interest (the range is owl:Thing).

Being a graduate student could (maybe!) be modelled with foaf:Group.


See the example in Wikipedia, it's in Turtle serialization.

unor
  • 92,415
  • 26
  • 211
  • 360
  • @unor- thank you, can you please elaborate more by giving or showing any example, I am completely new to use the FOAF function. It will really help me to understand more. Thanks in advance! – AKIWEB Aug 15 '12 at 17:29
  • @Nevzz03: I added a link to an example with Turtle syntax. – unor Aug 15 '12 at 19:10