4

I am trying to validate a foaf code on W3C RDF and the from following block it is causing problem. Here I am trying to show relation between Randy and Adil, please currect me why I can't use "rel" tag here or why is it causing problem?

<foaf:knows>
        <foaf:Person>

        <foaf:name>Randy</foaf:name>

        <foaf:mbox_sha1sum>0525a7bfaf263d404e751bb12b89e4acc1ce68a7</foaf:mbox_sha1sum>
        <rdfs:workplaceHomepage rdf:resource="randy.html" />
    <rel:friendOf rdf:resource="adil.html"/>        
  </foaf:Person>
    </foaf:knows>

Error:

FatalError: The prefix "rel" for element "rel:friendOf" is not bound.[Line = 39, Column = 46]
Scott Reynen
  • 3,530
  • 18
  • 17
Himalay
  • 131
  • 2
  • 13

2 Answers2

3

You need to declare the namespace rel in the same way that you must have specified foaf at the top of your RDF/XML document.

This example should work for you ...

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:rel="http://some.namespace.for.rel.com/ns/"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         >
 <foaf:Person>
   <foaf:name>Peter Parker</foaf:name>
   <foaf:mbox rdf:resource="mailto:peter.parker@dailybugle.com"/>
    <foaf:knows>
        <foaf:Person>
        <foaf:name>Randy</foaf:name>
        <foaf:mbox_sha1sum>0525a7bfaf263d404e751bb12b89e4acc1ce68a7</foaf:mbox_sha1sum>
        <rdfs:workplaceHomepage rdf:resource="randy.html" />
    <rel:friendOf rdf:resource="adil.html"/>        
      </foaf:Person>
    </foaf:knows>
 </foaf:Person>
</rdf:RDF>

Anyway the use you make of rdfs:workplaceHomepage is wrong, you should use foaf:workplaceHomepage and also rel:friendOf doesn't make much sense. You can use foaf:knows here also.

Manuel Salvadores
  • 16,287
  • 5
  • 37
  • 56
3

You should wrap the FOAF content in an RDF element that declares the appropriate namespaces:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:foaf="http://xmlns.com/foaf/0.1/"
     xmlns:rel="http://www.perceive.net/schemas/relationship/">
Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • What if I need to show relation like "loves" "likes" and so on? – Himalay May 06 '11 at 14:11
  • @Himalay: there seem to be no such relationships in `rel`. You could define your own relationships, perhaps as subproperties of those of http://www.perceive.net/schemas/20031015/relationship/relationship.rdf, but then your file might not work with FOAF APIs. – Fred Foo May 06 '11 at 14:13