Revision as of 01:42, 1 November 2007 by Admin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UsingFoafTopic

Using foaf:topic

Using foaf:topic to relate a page to one of the topics of that page

Example: saying that a page is about the company "mcdonalds":

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:foaf="http://xmlns.com/foaf/0.1/"
        xmlns:fc="http://xmlns.com/foaf/corp#"
        xmlns:dc="http://purl.org/dc/elements/1.1/" >

<foaf:Document rdf:about="http://c2.com/cgi/wiki?McDonalds">
  <dc:title>McDonalds</dc:title>
  <dc:description>McDonalds page on the C2 Wiki</dc:description>
  <foaf:topic>
    <fc:Company>
      <fc:name>McDonalds</fc:name>
      <foaf:homepage rdf:resource="http://www.mcdonalds.com/"/>
    </fc:Company>
  </foaf:topic>
</foaf:Document>
</rdf:RDF>

Q: That seems to be a document-centric approach. How would this look if I wanted to put the web page information inside the elements describing the company?

A: From the point of view of the abstract RDF graph, the way you nest the XML elements doesn't really matter. However in practice there are interactions between the way a relationship is named ('depicts' versus 'depiction', for eg) and the way the markup is written.

For example, we can re-order the above XML to be neither company-centric nor document-centric:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:foaf="http://xmlns.com/foaf/0.1/"
        xmlns:fc="http://xmlns.com/foaf/corp#"
        xmlns:dc="http://purl.org/dc/elements/1.1/" >

    <fc:Company rdf:nodeID="mcd">
      <fc:name>McDonalds</fc:name>
      <foaf:homepage rdf:resource="http://www.mcdonalds.com/"/>
    </fc:Company>

    <foaf:Document rdf:about="http://c2.com/cgi/wiki?McDonalds">
      <dc:title>McDonalds</dc:title>
      <dc:description>McDonalds page on the C2 Wiki</dc:description>
      <foaf:topic rdf:nodeID="mcd"/>
    </foaf:Document>

</rdf:RDF>

Note that the 'topic' relation always points from a document to a company. This makes it hard to put the document description inside the company description.

In some cases, RDF vocabularies include 'inverse properties' that say the same thing backwards. In FOAF for example, we have foaf:depicts and foaf:depiction, as well as foaf:topic and foaf:page. Here we show the use of foaf:page to relate the company to a page that is about it:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:foaf="http://xmlns.com/foaf/0.1/"
        xmlns:fc="http://xmlns.com/foaf/corp#"
        xmlns:dc="http://purl.org/dc/elements/1.1/" >

    <fc:Company>
      <fc:name>McDonalds</fc:name>
      <foaf:homepage rdf:resource="http://www.mcdonalds.com/"/>
      <foaf:page>
        <foaf:Document rdf:about="http://c2.com/cgi/wiki?McDonalds">
          <dc:title>McDonalds</dc:title>
          <dc:description>McDonalds page on the C2 Wiki</dc:description>
      </foaf:Document>
      </foaf:page>
    </fc:Company>

</rdf:RDF>

As you can see, foaf:page is a bit like foaf:homepage, except that anyone can make a foaf:page about something, whereas the notion of a foaf:homepage is associated with notions of authority: I can't create the homepage for someone else's company.

This is a bit redundant, since foaf:topic and foaf:page express the same information, but can nevertheless be useful if you care about the XML form of your RDF data.


CategoryTutorial