XSLT mapping rules and GRDDL profile for Facebook Open Graph Protocol

Hello everyone,

Courtesy of Air France I had some time to hack a first XSLT 
transformation that extracts RDF from an XHTML page using the Open Graph 
protocol.

I released this alpha version as an open source freeware GRDDL profile:
http://ns.inria.fr/grddl/ogp/

If you want to declare that a document contains Open Graph Protocol data 
and always uses the latest profile, add this profile to the head of your 
XHTML:
<head profile="http://ns.inria.fr/grddl/ogp/">

Tests are being done as I write this and feedback is welcome.


The current version takes an XHTML file containing OGP markup as input e.g.

<html xmlns:og="http://opengraphprotocol.org/schema/">
<head>
<base href="http://www.inria.fr/sophia/index.html" />
<title>INRIA Sophia Antipolis</title>
<meta property="og:title" content="INRIA Sophia Antipolis" />
<meta property="og:type" content="non profit" />
<meta property="og:url" content="http://www.inria.fr/sophia/" />
<meta property="og:image" 
content="http://www-sop.inria.fr/oasis/FMCO/2008/ur_sophia.jpg" />
<meta property="og:description" content="INRIA’s Sophia Antipolis - 
Méditerranée research centre was set up in 1983 at the heart of one of 
the most important scientific parks in Europe. Today it has premises in 
Sophia Antipolis, Marseille and Montpellier, and now in Italy, bringing 
together almost 500 staff - including nearly 400 scientists – divided in 
about 40 research teams."/>
<meta property="og:site_name" content="INRIA - French National Institute 
for Research in Computer Science and Control " />
<meta property="og:latitude" content="43.6161" />
<meta property="og:longitude" content="7.0678" />
<meta property="og:street-address" content="2004 rt des Lucioles" />
<meta property="og:locality" content="Sophia Antipolis" />
<meta property="og:region" content="French Riviera" />
<meta property="og:postal-code" content="06902" />
<meta property="og:country-name" content="France" />
<meta property="og:email" content="Fabien.Gandon@inria.fr" />
<meta property="og:phone_number" content="+33492387788" />
<meta property="og:fax_number" content="+33492387783" />
<meta property="og:upc" content="HRV1230OPHJ" />
<meta property="og:isbn" content="1234567890123" />
</head>
</html>


 From this it provides an RDF version with both the extracted OGB 
triples and some mappings to several ontologies e.g. (result for the 
XHTML above):

<rdf:RDF xmlns:owl="http://www.w3.org/2002/07/owl#" 
xmlns:good="http://purl.org/goodrelations/v1#" 
xmlns:foaf="http://xmlns.com/foaf/0.1/" 
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" 
xmlns:h="http://www.w3.org/1999/xhtml" 
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
xmlns:biblio="http://purl.org/ontology/bibo/" 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns:sioc="http://rdfs.org/sioc/ns#" 
xmlns:og="http://opengraphprotocol.org/schema/" 
xmlns:dc="http://purl.org/dc/elements/1.1/" 
xmlns:vcard="http://www.w3.org/2006/vcard/ns#" 
xml:base="http://opengraphprotocol.org/schema/">

<!--Processing metadata property="title" content="INRIA Sophia Antipolis"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<rdfs:label>INRIA Sophia Antipolis</rdfs:label>
<dc:title>INRIA Sophia Antipolis</dc:title>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:title>INRIA Sophia Antipolis</og:title>
</rdf:Description>

<!--Processing metadata property="type" content="non profit"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<rdf:type rdf:resource="http://opengraphprotocol.org/schema/Non_profit"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:type>non profit</og:type>
</rdf:Description>

<!--Processing metadata property="url" 
content="http://www.inria.fr/sophia/"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<foaf:homepage rdf:resource="http://www.inria.fr/sophia/"/>
<rdf:seeAlso rdf:resource="http://www.inria.fr/sophia/"/>
</rdf:Description>
<sioc:Document rdf:about="http://www.inria.fr/sophia/">
<sioc:about 
rdf:resource="http://www.inria.fr/sophia/index.html#objectN65541"/>
</sioc:Document>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:url>http://www.inria.fr/sophia/</og:url>
</rdf:Description>

<!--Processing metadata property="image" 
content="http://www-sop.inria.fr/oasis/FMCO/2008/ur_sophia.jpg"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<foaf:depiction 
rdf:resource="http://www-sop.inria.fr/oasis/FMCO/2008/ur_sophia.jpg"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:image>http://www-sop.inria.fr/oasis/FMCO/2008/ur_sophia.jpg</og:image>
</rdf:Description>

<!--Processing metadata property="description" content="INRIA’s Sophia 
Antipolis - Méditerranée research centre was set up in 1983 at the heart 
of one of the most important scientific parks in Europe. Today it has 
premises in Sophia Antipolis, Marseille and Montpellier, and now in 
Italy, bringing together almost 500 staff - including nearly 400 
scientists – divided in about 40 research teams."-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<rdfs:comment>INRIA’s Sophia Antipolis - Méditerranée research centre 
was set up in 1983 at the heart of one of the most important scientific 
parks in Europe. Today it has premises in Sophia Antipolis, Marseille 
and Montpellier, and now in Italy, bringing together almost 500 staff - 
including nearly 400 scientists – divided in about 40 research 
teams.</rdfs:comment>
<dc:description>INRIA’s Sophia Antipolis - Méditerranée research centre 
was set up in 1983 at the heart of one of the most important scientific 
parks in Europe. Today it has premises in Sophia Antipolis, Marseille 
and Montpellier, and now in Italy, bringing together almost 500 staff - 
including nearly 400 scientists – divided in about 40 research 
teams.</dc:description>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:description>INRIA’s Sophia Antipolis - Méditerranée research centre 
was set up in 1983 at the heart of one of the most important scientific 
parks in Europe. Today it has premises in Sophia Antipolis, Marseille 
and Montpellier, and now in Italy, bringing together almost 500 staff - 
including nearly 400 scientists – divided in about 40 research 
teams.</og:description>
</rdf:Description>

<!--Processing metadata property="site_name" content="INRIA - French 
National Institute for Research in Computer Science and Control "-->
<sioc:Site rdf:about="http://www.inria.fr/">
<rdfs:label>INRIA - French National Institute for Research in Computer 
Science and Control </rdfs:label>
<dc:title>INRIA - French National Institute for Research in Computer 
Science and Control </dc:title>
<sioc:space_of>
<sioc:Container>
<sioc:container_of>
<sioc:Document rdf:about="http://www.inria.fr/sophia/index.html">
<sioc:about 
rdf:resource="http://www.inria.fr/sophia/index.html#objectN65541"/>
</sioc:Document>
</sioc:container_of>
</sioc:Container>
</sioc:space_of>
</sioc:Site>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:site_name>INRIA - French National Institute for Research in Computer 
Science and Control </og:site_name>
</rdf:Description>

<!--Processing metadata property="latitude" content="43.6161"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<geo:lat>43.6161</geo:lat>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:latitude>43.6161</og:latitude>
</rdf:Description>

<!--Processing metadata property="longitude" content="7.0678"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<geo:long>7.0678</geo:long>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:longitude>7.0678</og:longitude>
</rdf:Description>

<!--Processing metadata property="street-address" content="2004 rt des 
Lucioles"-->
<vcard:VCard rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:adr>
<vcard:Address 
rdf:about="http://www.inria.fr/sophia/index.html#addressN65541">
<vcard:street-address>2004 rt des Lucioles</vcard:street-address>
</vcard:Address>
</vcard:adr>
</vcard:VCard>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:street-address>2004 rt des Lucioles</og:street-address>
</rdf:Description>

<!--Processing metadata property="locality" content="Sophia Antipolis"-->
<vcard:VCard rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:adr>
<vcard:Address 
rdf:about="http://www.inria.fr/sophia/index.html#addressN65541">
<vcard:locality>Sophia Antipolis</vcard:locality>
</vcard:Address>
</vcard:adr>
</vcard:VCard>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:locality>Sophia Antipolis</og:locality>
</rdf:Description>

<!--Processing metadata property="region" content="French Riviera"-->
<vcard:VCard rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:adr>
<vcard:Address 
rdf:about="http://www.inria.fr/sophia/index.html#addressN65541">
<vcard:region>French Riviera</vcard:region>
</vcard:Address>
</vcard:adr>
</vcard:VCard>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:region>French Riviera</og:region>
</rdf:Description>

<!--Processing metadata property="postal-code" content="06902"-->
<vcard:VCard rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:adr>
<vcard:Address 
rdf:about="http://www.inria.fr/sophia/index.html#addressN65541">
<vcard:postal-code>06902</vcard:postal-code>
</vcard:Address>
</vcard:adr>
</vcard:VCard>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:postal-code>06902</og:postal-code>
</rdf:Description>

<!--Processing metadata property="country-name" content="France"-->
<vcard:VCard rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:adr>
<vcard:Address 
rdf:about="http://www.inria.fr/sophia/index.html#addressN65541">
<vcard:country-name>France</vcard:country-name>
</vcard:Address>
</vcard:adr>
</vcard:VCard>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:country-name>France</og:country-name>
</rdf:Description>

<!--Processing metadata property="email" content="Fabien.Gandon@inria.fr"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<foaf:mbox rdf:resource="mailto:Fabien.Gandon@inria.fr"/>
<vcard:email>Fabien.Gandon@inria.fr</vcard:email>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:email>Fabien.Gandon@inria.fr</og:email>
</rdf:Description>

<!--Processing metadata property="phone_number" content="+33492387788"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:tel>+33492387788</vcard:tel>
<foaf:phone>+33492387788</foaf:phone>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:phone_number>+33492387788</og:phone_number>
</rdf:Description>

<!--Processing metadata property="fax_number" content="+33492387783"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<vcard:tel>+33492387783</vcard:tel>
<foaf:phone>+33492387783</foaf:phone>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:fax_number>+33492387783</og:fax_number>
</rdf:Description>

<!--Processing metadata property="upc" content="HRV1230OPHJ"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<good:hasEAN_UCC-13>0HRV1230OPHJ</good:hasEAN_UCC-13>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:upc>HRV1230OPHJ</og:upc>
</rdf:Description>

<!--Processing metadata property="isbn" content="1234567890123"-->
<rdf:Description 
rdf:about="http://www.inria.fr/sophia/index.html#objectN65541">
<biblio:isbn>1234567890123</biblio:isbn>
</rdf:Description>
<rdf:Description rdf:about="http://www.inria.fr/sophia/index.html">
<og:isbn>1234567890123</og:isbn>
</rdf:Description>

</rdf:RDF>

(Pffeeww !)

Cheers,

-- 
fabien, inria, http://fabien.info

Received on Monday, 3 May 2010 10:09:01 UTC