How to encode a RDF/XML of simple interest

465 views Asked by At

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.

3

There are 3 answers

2
unor On

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.

2
Galaad On

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.

0
Jeen Broekstra On

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.