开发者

Adding extra fields to a FOAF file

开发者 https://www.devze.com 2022-12-21 02:29 出处:网络
I would like to store my personal data in a FOAF file on my own server. There is a group of us doing the same thing. We need a couple of custom fields that the standard FOAF implementation doesn\'t ha

I would like to store my personal data in a FOAF file on my own server. There is a group of us doing the same thing. We need a couple of custom fields that the standard FOAF implementation doesn't have, ie: availability.

How can I add the availability field, and still keep the FOAF file validated? I guess I use the RDF format outside of the FOAF block, but I am not quite sure how to do that 'legally'. Here is a sample of FOAF code.

<?xml version="1.0"?>

    <rdf:RDF xmlns:rdf="http://www.w3开发者_如何学编程.org/1999/02/22-rdf-syntax-ns#"
             xmlns:foaf="http://xmlns.com/foaf/0.1/">
      <foaf:Person>
       <foaf:name>Joe Blogs</foaf:name>
       <foaf:gender>Male</foaf:gender>
       <foaf:title>Mr</foaf:title>
       <foaf:givenname>Joe</foaf:givenname>
       <foaf:family_name>Blogs</foaf:family_name>
     </foaf:Person>
    </rdf:RDF>


It's really simple, you just need an 'availability' property. You could just make up a namespace and use it:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:myvocab="http://my.example.org/vocab#">
   <foaf:Person>
     <myvocab:availability>....</myvocab:availability>
     <foaf:name>Joe Blogs</foaf:name>
     ....
   </foaf:Person>
</rdf:RDF>

Perfectly legal. Ideally you would host an rdf file describing the property at http://my.example.org/vocab, so people could look up the property.

However even easier is open.vocab.org. There you can define you little property and it will be retrievable. The namespace will be http://open.vocab.org/terms/, and the property name will be, well, whatever you pick.

(It may be that there's a relevant property out there already, of course. Try asking on the foaf list)


Yes, FOAF was designed (by using RDF) to allow just this kind of casual extensibility. You can add anything you like so long as it parses as RDF (see http://www.w3.org/RDF/Validator )

0

精彩评论

暂无评论...
验证码 换一张
取 消