DRY...don't repeat yourself

Mark Birbeck's picture

Software development is built on 're-use', but writing web-pages is one place that we've generally not had the benefit of re-use mechanisms. However, RDFa allows all of the metadata that we just saw in the FoaF example to be obtained from features that would normally be found in a web-page anyway.

For example, if my blog already has a link to my work web-site:

  <body>
    I am currently working on an  XForms processor called
    <a href="http://www.formsPlayer.com/">formsPlayer</a>.
  </body>

I could re-use this information and so replace the mark-up for foaf:workplaceHomepage in the head of the document with this:

  <body about="#author">
    I am currently working on an  XForms processor called
    <a rel="foaf:workplaceHomepage"
      href="http://www.formsPlayer.com/">formsPlayer</a>.
  </body>

A full example that uses all of these techniques might look like this:

  <html
   xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
   xmlns:foaf="http://xmlns.com/foaf/0.1/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
  >
    <head>
      <link rel="dc:creator" href="#about" />
      <meta about="#author">
        <link rel="rdf:type" href="[foaf:Person]" />
        <meta property="foaf:givenname" content="Mark" />
        <meta property="foaf:family_name" content="Birbeck" />
        <meta property="foaf:mbox_sha1sum"
          content="b8b2922a0d39cd7c7db0b4f65124b4dd2a79fa24" />
        <link rel="foaf:homepage" href="" />
        <meta property="geo:long" content="4.833333" />
        <meta property="geo:lat" content="43.95" />
      </meta>
    </head>
    <body about="#author">
      Hi, my name is Mark Birbeck,
      and I am currently working on an XForms processor called
      <a rel="foaf:workplaceHomepage"
        href="http://www.formsPlayer.com/">formsPlayer</a>.
      Don't bother emailing me though, because I'm on holiday
      in Avignon. (I wish...)
    </body>
  </html>