Microformats

  1. Principe
    1. Syntaxe
    2. XSLT
    3. Méta-informations nécessaires à l'extraction automatique

  2. Exemple 1 : le microformat hCalendar.
    1. Le fichier-source
    2. Données extraites
    3. Effectuer l'extraction

  3. Exemple 2 : Le microformat Embedded RDF .
    1. Le fichier-source
    2. Données extraites
    3. Effectuer l'extraction

  4. Le cas de RDFa
    1. Principe
    2. Un exemple ultra-simple
      1. Texte-source :
      2. Données extraites (XML) :
      3. Données extraites (N3) :
      4. Remarques :
    3. Autre exemple, un peu moins simple
      1. Fichier-source
      2. Données extraites (N3)
      3. Remarques :
    4. Application
      1. Texte-source
      2. Données extraites (N3)
      3. Remarques
      4. Exploitation

  1. Principe

    GRDDL = Gleaning Resource Descriptions from Dialects of Languages
    [ref : le GRDDL-Primer :
    http://www.w3.org/TR/grddl-primer/]

    L'idée est d'associer une certaine sémantique à divers éléments syntaxiques présents dans des documents XML,
    notamment dans des pages XHTML. Des logiciels ad hoc peuvent alors traiter les fichiers et en extraire l'information correspondante
    (représentée typiquement en RDF). Ces logiciels se réalisent assez naturellement en XSLT...

    1. Syntaxe

      La première question est alors "quelles extensions syntaxiques va-t-on apporter au dialecte XML visé ?".
      Dans ce cours, on se limitera au dialecte XHTML, en considérant ue la plupart des documents XML couramment écrits (à la main)
      sont des pages Web, et qu'il est donc intéressant de voir comment on peut étendre leur fonctionnalité en y "tissant de la sémantique".

      Nous verrons deux approches :
      1. Celle des microformats hCalendar et Embedded RDF, qui utilisent des classes, au sens des CSS.
        Pour chacune, le jeu de classes utilisé constitue un vocabulaire spécifique du domaine traité.

      2. Celle de RDFa, qui fait appel à un jeu d'attributs supplémentaires.

      Pour un catalogue plus fourni, voir
      CustomRdfDialects.

    2. XSLT

      Seconde question : comment réaliser l'extraction des informations "sémantiques" ?
      Dans tous les cas, via une transformation (feuille de style) XSLT.
      Où est-elle et comment est-elle mise en œuvre ?

    3. Méta-informations nécessaires à l'extraction automatique


      • Principalement, l'adresse de la feuille de style,
        qui est donnée via <link rel="transformation". href="l'adresse"/>.
        Par exemple, pour le microformat hCalendar :
        <link rel="transformation" href="
        http://www.w3.org/2002/12/cal/glean-hcal"/>

      • Mais encore faut-il préciser le sens de la méta-donnée "transformation".
        C'est le rôle du fichier désigné par le profil donné dans la balise englobante <head> :
        <head profile="http://www.w3.org/2003/g/data-view">.

        Ce dernier fichier est valable pour tous les microformats. Il énonce (en anglais !) :
        Transformation : an InformationResource that specifies a transformation from a set of XML documents to RDF graphs.

        Le GRDDL-Primer propose une vision graphique du processus d'extraction :

        hCalendar


      • Pour certains microformats, il existe un fichier-profil qui contient aussi l'indication du fichier-transformation
        (via la méta-donnée profileTransformation).
        Il suffit alors de le donner comme profil, en faisant l'éconoie du <link rel="transformation" href="l'adresse"/>.
        C'est le cas pour

        • Embedded RDF
          dont le profil est "http://purl.org/NET/erdf/profile".
          Voici le contenu de ce fichier :

          <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

            <head profile="http://www.w3.org/2003/g/data-view">
              <title>Embedded RDF HTML Profile</title>
              <link rel="transformation" href="http://www.w3.org/2003/g/glean-profile" />
            </head>
            <body>

              <p>
                <a rel="profileTransformation"
                    href="http://purl.org/NET/erdf/extract-rdf.xsl">GRDDL transform</a>
              </p>
            </body>
          </html>



        • RDFa
          dont le profil est "http://ns.inria.fr/grddl/rdfa/".
          Ce fichier est trop long pour être cité in extenso. On y trouve dûment mentionné :
          <a rel="profileTransformation" href="2008/09/03/RDFa2RDFXML.xsl">2008/09/03/RDFa2RDFXML.xsl</a>

        • Dans ce cas, le processus d'extraction automatique est plus complexe. Il est décrit de manière graphique par le GRDDL-Primer
          ainsi :

          Extraction

          L'idée est que :
          A GRDDL-capable client tool, when visiting a page which contains the profile reference http://purl.org/NET/erdf/profile
          will first visit this profile document and apply the transformation declared here.
          The results of that transformation will contain a statement identifying the transformation that should be applied
          to convert the originating document into RDF/XML.
          The GRDDL client has everything it needs to get RDF/XML from the original XHTML document,
          while the author of the originating document need not concern themselves with the details of the profile,
          merely including the reference to its URI is enough.
          [GRDDL-Primer]

          Cela ne change rien au fond, c'est une sorte de commodité administrative...

          L'essentiel est que la transformation se définit par une feuille de style XSLT, applicable au fichier XHTML augmenté.
          Et que cette feuille de style peut résider n'importe où sur le réseau.

  2. Exemple 1 : le microformat hCalendar.

    Choix d'extension : utiliser systématiquement des noms de classes (comme pour des CSS) pour leur attribuer une sémantique.

    Exemple illustratif, repris au GRDDL-Primer : la page "Le calendrier de Robin".
    1. Le fichier-source

      Dans le fichier-source de cette page , on trouve le passage suivant
      (en gras les indications "sémantiques")

      <ol class="schedule">
        <li>2007
          <ol>
            <li class="vevent"><strong class="summary">Web Design Conference</strong> in
              <span class="location">Edinburgh, UK</span>:
              <abbr class="dtstart" title="2007-01-08">Jan 8</abbr> to
              <abbr class="dtend" title="2007-01-11">10</abbr>
            </li>
            <li class="vevent"><strong class="summary">Board Review</strong> in
              <span class="location">New York, USA</span>:
              <abbr class="dtstart" title="2007-02-23">Feb 23</abbr> to
              <abbr class="dtend" title="2007-02-25">24</abbr>
            </li>
          </ol>
        </li>
      </ol>



      qui se visualise comme

      Visu
    2. Données extraites

      On en extrait les triplets RDF que voici,  en format N3
      N.B. Une forme comme "2007-02-25"^^<http://www.w3.org/2001/XMLSchema#date>
      se lit : la chaîne (littéral) "2007-02-25", qui est réputée conforme au datatype "date" défini par XML-Schémas.

      @prefix ns0:     <http://www.w3.org/2002/12/cal/icaltzd#> .
      @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

      <http://example.org/>
            a       ns0:Vcalendar ;
            ns0:component
                    [ a       ns0:Vevent ;
                      ns0:dtend "2007-02-25"^^<http://www.w3.org/2001/XMLSchema#date> ;
                      ns0:dtstart "2007-02-23"^^<http://www.w3.org/2001/XMLSchema#date> ;
                      ns0:location "New York, USA"@en ;
                      ns0:summary "Board Review"@en ;
                      ns0:url <http://example.org/>
                    ] ;
            ns0:component
                    [ a       ns0:Vevent ;
                      ns0:dtend "2007-01-11"^^<http://www.w3.org/2001/XMLSchema#date> ;
                      ns0:dtstart "2007-01-08"^^<http://www.w3.org/2001/XMLSchema#date> ;
                      ns0:location "Edinburgh, UK"@en ;
                      ns0:summary "Web Design Conference"@en ;
                      ns0:url <http://example.org/>
                    ] ;
            ns0:prodid "-//connolly.w3.org//RDF Calendar $Date: 2007/06/30 19:05:32 $ (BETA)//EN" ;
            ns0:version "2.0" .


      Ce texte RDF peut ensuite être interrogé via SPARQL, etc.

    3. Effectuer l'extraction

      Comme expliqué plus haut, on rend possible l'extraction automatique du contenu en RDF-XML par le GRDDL service :
      http://www.w3.org/2007/08/grddl/.
      en ajoutant un attribut profil dans <head> et en donnant l'adresse du transformateur XSLT dans un <link>.

      Voici le nouvel en-tête :
      <head profile="http://www.w3.org/2003/g/data-view">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>Robin's Schedule</title>
        <link rel="transformation" href="http://www.w3.org/2002/12/cal/glean-hcal"
        />
      </head>


      L'extraction donne un texte XML assez verbeux, mais dont la traduction en N3 aboutit au résultat ci-dessus :

      <?xml version="1.0" encoding="utf-8"?>
      <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description rdf:about="http://example.org/">
          <rdf:type rdf:resource="http://www.w3.org/2002/12/cal/icaltzd#Vcalendar"/>
        </rdf:Description>
        <rdf:Description rdf:about="http://example.org/">
          <ns0:prodid xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">-//connolly.w3.org//RDF Calendar $Date: 2007/06/30 19:05:32 $ (BETA)//EN</ns0:prodid>
        </rdf:Description>
        <rdf:Description rdf:about="http://example.org/">
          <ns0:version xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2.0</ns0:version>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r2">
          <rdf:type rdf:resource="http://www.w3.org/2002/12/cal/icaltzd#Vevent"/>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r2">
          <ns0:summary xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" xml:lang="en">Web Design Conference</ns0:summary>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r2">
          <ns0:dtstart xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2007-01-08</ns0:dtstart>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r2">
          <ns0:dtend xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2007-01-11</ns0:dtend>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r2">
          <ns0:url xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:resource="http://example.org/"/>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r2">
          <ns0:location xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" xml:lang="en">Edinburgh, UK</ns0:location>
        </rdf:Description>
        <rdf:Description rdf:about="http://example.org/">
          <ns0:component xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:nodeID="r1259674159r19622r2"/>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r3">
          <rdf:type rdf:resource="http://www.w3.org/2002/12/cal/icaltzd#Vevent"/>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r3">
          <ns0:summary xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" xml:lang="en">Board Review</ns0:summary>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r3">
          <ns0:dtstart xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2007-02-23</ns0:dtstart>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r3">
          <ns0:dtend xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2007-02-25</ns0:dtend>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r3">
          <ns0:url xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:resource="http://example.org/"/>
        </rdf:Description>
        <rdf:Description rdf:nodeID="r1259674159r19622r3">
          <ns0:location xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" xml:lang="en">New York, USA</ns0:location>
        </rdf:Description>
        <rdf:Description rdf:about="http://example.org/">
          <ns0:component xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#" rdf:nodeID="r1259674159r19622r3"/>
        </rdf:Description>
      </rdf:RDF>

      <!-- Extracted from pasted markup by http://www.w3.org/2007/08/grddl/ -->



  3. Exemple 2 : Le microformat Embedded RDF .

    Même principe que pour hCalendar, à base de classes CSS.
    Notre exemple, lui aussi repris au GRDDL-Primer, est la page "Le calendrier de David".
    1. Le fichier-source


         <p class="-cal-Vevent" id="tiddlywinks">
            From <span class="cal-dtstart" title="2006-10-07">7 October, 2006</span>
            to <span class="cal-dtend"  title="2006-10-13">12 October, 2006</span>
            I will be attending the
             <span class="cal-summary">National Tiddlywinks Championship</span> in
             <span class="cal-location">Bognor Regis, UK</span>.
          </p>
          <p class="-cal-Vevent" id="holiday">
            Then I'm <span class="cal-summary">on holiday</span> in the
            <span class="cal-location">Cayman Islands</span> between
            <span class="cal-dtstart" title="2006-11-14">14 November, 2006</span>
            and <span class="cal-dtend"  title="2007-01-02">1 January, 2007</span>.
          </p>

          <p class="-cal-Vevent" id="award">
            I then visit Scotland on
            <span class="cal-dtstart" title="2007-01-08">the 8th January</span> to
            <span class="cal-summary">pick up a lifetime achievement award from the Web Design Conference</span>.
            This time the ceremony is in <span class="cal-location">Edinburgh, UK</span>.
            I'll be taking the train home on the <span class="cal-dtend"  title="2007-01-11">10th</span>.
          </p>


      se visualise ainsi :

      David

      En dehors du style de rédaction très différent du précédent, on voit que les annotations sémantiques sont exactement les mêmes,
      à l'exception du préfixe "cal-".

    2. Données extraites

      Obtenues comme un fichier XML(vois plus loin), ci-dessous traduit en N3 :
      @prefix ns0:     <http://www.w3.org/2002/12/cal/icaltzd#> .
      @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

      <http://www.w3.org/TR/grddl-primer/david-erdf.html#award>
            a       ns0:Vevent ;
            ns0:dtend "2007-01-11" ;
            ns0:dtstart "2007-01-08" ;
            ns0:location "Edinburgh, UK" ;
            ns0:summary """pick up a lifetime
            achievement award from the Web Design Conference""" .

      <http://www.w3.org/TR/grddl-primer/david-erdf.html#tiddlywinks>
            a       ns0:Vevent ;
            ns0:dtend "2006-10-13" ;
            ns0:dtstart "2006-10-07" ;
            ns0:location "Bognor Regis, UK" ;
            ns0:summary """National Tiddlywinks
            Championship""" .

      <http://www.w3.org/TR/grddl-primer/david-erdf.html#holiday>
            a       ns0:Vevent ;
            ns0:dtend "2007-01-02" ;
            ns0:dtstart "2006-11-14" ;
            ns0:location "Cayman Islands" ;
            ns0:summary "on holiday" .

      <http://www.w3.org/TR/grddl-primer/david-erdf.html>
            <http://webns.net/mvcb/generatorAgent>
                    <http://purl.org/NET/erdf/extract> .


      Comme on pouvait s'y attendre, les données extraites sont à peu près de la même forme que dans l'exemple précédent.
      On note l'exploitation de l'attribut "id" qui donne des URIs pour désigner les 3 "Vevents" qui étaient ci-dessus des ressources anonymes.
    3. Effectuer l'extraction

      Comme expliqué ci-dessus, le profil et propre au microformat Embedded RDF, et la balise <link> ne dirige plus vers la transformation,
      elle permet seulement d'interpréter le préfixe "cal-".

        <head profile="http://purl.org/NET/erdf/profile">
          <title>Where Am I</title>
          <link rel="schema.cal" href="http://www.w3.org/2002/12/cal/icaltzd#" />
        </head>

      Voici le
      fichier XML obtenu :

      <?xml version="1.0" encoding="utf-8"?>
      <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html">
          <ns0:generatorAgent xmlns:ns0="http://webns.net/mvcb/" rdf:resource="http://purl.org/NET/erdf/extract"/>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#tiddlywinks">
          <rdf:type rdf:resource="http://www.w3.org/2002/12/cal/icaltzd#Vevent"/>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#tiddlywinks">
          <ns0:dtstart xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2006-10-07</ns0:dtstart>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#tiddlywinks">
          <ns0:dtend xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2006-10-13</ns0:dtend>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#tiddlywinks">
          <ns0:summary xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">National Tiddlywinks
            Championship</ns0:summary>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#tiddlywinks">
          <ns0:location xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">Bognor Regis, UK</ns0:location>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#holiday">
          <rdf:type rdf:resource="http://www.w3.org/2002/12/cal/icaltzd#Vevent"/>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#holiday">
          <ns0:summary xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">on holiday</ns0:summary>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#holiday">
          <ns0:location xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">Cayman Islands</ns0:location>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#holiday">
          <ns0:dtstart xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2006-11-14</ns0:dtstart>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#holiday">
          <ns0:dtend xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2007-01-02</ns0:dtend>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#award">
          <rdf:type rdf:resource="http://www.w3.org/2002/12/cal/icaltzd#Vevent"/>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#award">
          <ns0:dtstart xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2007-01-08</ns0:dtstart>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#award">
          <ns0:summary xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">pick up a lifetime
            achievement award from the Web Design Conference</ns0:summary>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#award">
          <ns0:location xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">Edinburgh, UK</ns0:location>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.w3.org/TR/grddl-primer/david-erdf.html#award">
          <ns0:dtend xmlns:ns0="http://www.w3.org/2002/12/cal/icaltzd#">2007-01-11</ns0:dtend>
        </rdf:Description>
      </rdf:RDF>

      <!-- Extracted from http://www.w3.org/TR/grddl-primer/david-erdf.html by http://www.w3.org/2007/08/grddl/ at http://www.w3.org/2007/08/grddl/?docAddr=http://www.w3.org/TR/grddl-primer/david-erdf.html -->




  4. Le cas de RDFa

    1. Principe

      Il s'agit d'un microformat généraliste, où les ajouts sémantiques sont portés par des attributs supplémentaires :
      RDFa utilise pour partie la syntaxe HTML existante :
      • l'attribut class - permettant de spécifier le type de l'objet
      • l'attribut id - indirectement, servant à définir l'URI d'un objet dans la page
      • les attributs rel, rev et href - spécifiant une relation avec une autre ressource

      RDFa ajoute ses propres éléments, les attributs :
      • about - une URI spécifiant la ressource décrite par les métadonnées ; en son absence, il s'agit du document en cours
      • property - spécifiant une propriété pour le contenu d'un élément
      • content - attribut optionnel qui remplace le contenu d'un élément quand on utilise l'attribut de propriété
      • datatype - attribut optionnel qui spécifie le type de donnée du contenu.

      [
      Wikipédia]

      N.B. Aujourd'hui class est sorti de l'usage, il est tremplacé par typeof.

      L'extraction en RDF/XML est réalisée par la feuille de style de Fabien Gandon (INRIA),
      qui se trouve en : http://ns.inria.fr/grddl/rdfa/2008/09/03/RDFa2RDFXML.xsl
      et qui est référencée par le profil  : http://ns.inria.fr/grddl/rdfa/ .

    2. Un exemple ultra-simple

      Celui qui illustre les namespaces dans le cours n° 1, réécrit en RDFa pour montrer l'aboutissement de la démarche.
      Texte-source :

      <?xml version="1.0" encoding='UTF-8'?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
      <!-- L'exemple de namespace réécrit en RDFa -->
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:xdc="http://www.xml.com/books#"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
       <head profile="http://ns.inria.fr/grddl/rdfa/">
         <title>Book Review</title>
          <base href="http://www.xml.com/books/reviews" />
       </head>
      <body>
       <div about="#2009-11-30" typeof="xdc:bookreview">
         <h1 property="xdc:title" style="font-family: sans-serif;">XML: A Primer</h1>
         <table border="3">
          <tr align="center">
           <td>Author</td><td>Price</td>
           <td>Pages</td><td>Date</td>
          </tr>
          <tr align="left">
           <td property="xdc:author">Simon St. Laurent</td>
           <td property="xdc:price"
      datatype="xsd:float">31.98</td>
           <td property="xdc:pages">352</td>
           <td property="xdc:date" datatype="xsd:date">1998-01-15</td>
          </tr>
         </table>
        </div>
       </body>
      </html>


      Données extraites (XML) :

      <?xml version="1.0" encoding="utf-8"?>
      <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description rdf:about="http://www.xml.com/books/reviews#2009-11-30">
          <rdf:type rdf:resource="http://www.xml.com/books#bookreview"/>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.xml.com/books/reviews#2009-11-30">
          <ns0:title xmlns:ns0="http://www.xml.com/books#">XML: A Primer</ns0:title>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.xml.com/books/reviews#2009-11-30">
          <ns0:author xmlns:ns0="http://www.xml.com/books#">Simon St. Laurent</ns0:author>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.xml.com/books/reviews#2009-11-30">
          <ns0:price xmlns:ns0="http://www.xml.com/books#" rdf:datatype="http://www.w3.org/2001/XMLSchema#float">31.98</ns0:price>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.xml.com/books/reviews#2009-11-30">
          <ns0:pages xmlns:ns0="http://www.xml.com/books#">352</ns0:pages>
        </rdf:Description>
        <rdf:Description rdf:about="http://www.xml.com/books/reviews#2009-11-30">
          <ns0:date xmlns:ns0="http://www.xml.com/books#" rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1998-01-15</ns0:date>
        </rdf:Description>
      </rdf:RDF>

      <!-- Extracted from pasted markup by http://www.w3.org/2007/08/grddl/ -->


      Données extraites (N3) :

      @prefix ns0:     <http://www.xml.com/books#> .
      @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

      <http://www.xml.com/books/reviews#2009-11-30>
            a       ns0:bookreview ;
            ns0:author "Simon St. Laurent" ;
            ns0:date "1998-01-15"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:pages "352" ;
            ns0:price "31.98"^^<http://www.w3.org/2001/XMLSchema#float> ;
            ns0:title "XML: A Primer" .


      Remarques :
      1. Comme son nom l'indique, la balise <base> introduit une URL qui va préfixer les URLs apparaissant de la le fichier,
        en l'occurrence le sujet "#2009-11-30" de la relation introduit par about (qui doit être une URL !).
      2. L'attribut typeof se traduit en RDF-XML par "rdf:type", nous en reparlerons longuement plus tard.
        À noter qu'en syntaxe N3 "rdf:type" devient simplement l'article indéfini "a", abréviation de "is-a".
      3. L'attribut "datatype" en RDFa se traduit en RDF-XML par "rdf:datatype",
        qui en notation N3 devient une sorte d'opérateur infixé "^^".

    3. Autre exemple, un peu moins simple

      repris au RDFa Primer dont on trouvera une excellente traduction en français,
      et modifié pour le faire entrer dans une progression pédagogique.
      Fichier RDFa original alice-example.html.

      Fichier-source
      modifié Alice.html (en gras les éléments RDFa, italique pour les nouveautés)
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:foaf="http://xmlns.com/foaf/0.1/">
        <head profile="http://ns.inria.fr/grddl/rdfa/">
          <title>Alice rêve de sémantique</title>
          <base href="http://example.com/alice"></base>
          <link rel="stylesheet"
                type="text/css"
                href="http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/style.css" />
        </head>
        <body>
        <h1>Alice's blog</h1>
         
          <div about="/posts/2008-09-15">
              <h2 property="dc:title">L'ennui avec Bob</h2>
              <h3 property="dc:creator">Alice</h3>
              <p>L'ennui avec Bob, c'est qu'il fait de meilleures photos que moi :</p>
              <div class="imgbox" about="http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/sunset.jpg">
                  <img src="http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/sunset.jpg" alt="sunset" />
                  <div>
                     <span property="dc:title">Beautiful Sunset</span>
                     by
                     <span property="dc:creator">Bob</span>.
                  </div>
              </div>       
          </div>
       
          <div about="/posts/2008-10-07">
              <h2 property="dc:title">La soirée chez Jo</h2>
              <h3 property="dc:creator">Eve</h3>
              <p>C'était génial !</p>
          </div>     
       
          <div class="socialnet" about="#me" typeof="foaf:Person">       
              <p property="foaf:name">Alice Birpemswick</p>
              <p>Email: <a rel="foaf:mbox" href="mailto:alice@example.com">alice@example.com</a></p>
              <p>Phone: <a rel="foaf:phone" href="tel:+1-617-555-7332">+1 617.555.7332</a></p>
              <p>Mes potes:</p>       
              <ul rel="foaf:knows">
                  <li typeof="foaf:Person">
                     <a property="foaf:name" rel="foaf:homepage" href="http://example.com/bob">Bob</a>
                  </li>
                  <li typeof="foaf:Person">
                     <a property="foaf:name" rel="foaf:homepage" href="http://example.com/eve">Eve</a>
                  </li>
                  <li typeof="foaf:Person">
                     <a property="foaf:name" rel="foaf:homepage" href="http://example.com/manu">Manu</a>
                  </li>
              </ul>
          </div>
       
          <div id="footer">
             <p>The content on this site is licensed under
               <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">
                 a Creative Commons License
               </a>.
             </p>
             <div class="validrdfa">
                <a href="http://validator.w3.org/check?uri=referer">
                  <img src="http://www.w3.org/Icons/valid-xhtml-rdfa" alt="Valid XHTML+RDFa"/>
                </a>
             </div>
          </div>
             
        </body>
      </html>


      Données extraites (N3)

      @prefix ns0:     <http://www.w3.org/1999/xhtml/vocab#> .
      @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

      <http://example.com/posts/2008-09-15>
            <http://purl.org/dc/elements/1.1/creator>
                    "Alice" ;
            <http://purl.org/dc/elements/1.1/title>
                    "L'ennui avec Bob" .

      <http://example.com/alice#me>
            a       <http://xmlns.com/foaf/0.1/Person> ;
            <http://xmlns.com/foaf/0.1/knows>
                    [ a       <http://xmlns.com/foaf/0.1/Person> ;
                      <http://xmlns.com/foaf/0.1/homepage>
                              <http://example.com/manu> ;
                      <http://xmlns.com/foaf/0.1/name>
                              "Manu"
                    ] ;
            <http://xmlns.com/foaf/0.1/knows>
                    [ a       <http://xmlns.com/foaf/0.1/Person> ;
                      <http://xmlns.com/foaf/0.1/homepage>
                              <http://example.com/eve> ;
                      <http://xmlns.com/foaf/0.1/name>
                              "Eve"
                    ] ;
            <http://xmlns.com/foaf/0.1/knows>
                    [ a       <http://xmlns.com/foaf/0.1/Person> ;
                      <http://xmlns.com/foaf/0.1/homepage>
                              <http://example.com/bob> ;
                      <http://xmlns.com/foaf/0.1/name>
                              "Bob"
                    ] ;
            <http://xmlns.com/foaf/0.1/mbox>
                    <mailto:alice@example.com> ;
            <http://xmlns.com/foaf/0.1/name>
                    "Alice Birpemswick" ;
            <http://xmlns.com/foaf/0.1/phone>
                    <tel:+1-617-555-7332> .

      <http://example.com/posts/2008-10-07>
            <http://purl.org/dc/elements/1.1/creator>
                    "Eve" ;
            <http://purl.org/dc/elements/1.1/title>
                    "La soirée chez Jo" .

      <http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/sunset.jpg>
            <http://purl.org/dc/elements/1.1/creator>
                    "Bob" ;
            <http://purl.org/dc/elements/1.1/title>
                    "Beautiful Sunset" .

      <http://example.com/alice>
            ns0:license <http://creativecommons.org/licenses/by/3.0/> ;
            ns0:stylesheet <http://www.w3.org/TR/2008/NOTE-xhtml-rdfa-primer-20081014/style.css> .



      Remarques :
      1. Notons d'abord qu'en l'absence de about, typeof suffit pour faire naître un sujet de relation comme ressource anonyme.
        C'est le cas pour les trois foaf:Person amies d'Alice.

      2. La nouveauté la plus importante est le traitement de l'attribut "rel", avec comme valeur une relation.

      3. Enfin, on note qu'en l'absence de sujet donné par about ou suggéré par typeof, le sujet par défaut
        est l'URL <base> du document elle-même, comme illustré par les 3 dernières lignes du fichier N3 ci-dessus.

    4. Application

      Reprise au GRDDL-Primer : on rejoint les histoires de calendrier illustrées par les deux premiers exemples
      en hCalendar et en Embedded RDF. Fichier original :
      http://www.w3.org/TR/grddl-primer/janeschedule.html
      Texte-source
      mis à jour : les occurrences de class, qui ne fonctionnent plus,  sont remplacées par typeof.
      On observe que l'extraction automatique est ici programmée par profil et lien vers la transformation [voir ci-dessus].
      Les trois paragraphes étant semblables, je n'ai annoté que le premier.

      <?xml version="1.0" encoding='UTF-8'?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
                                "http://www.w3.org/MarkUp/DTD/xhtml+rdfa-1.dtd">
      <html xmlns:cal="http://www.w3.org/2002/12/cal/icaltzd#"
            xmlns:xs="http://www.w3.org/2001/XMLSchema#"
            xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns="http://www.w3.org/1999/xhtml"
         >
       <head profile="http://www.w3.org/2003/g/data-view">
        <title>Jane's Blog</title>
          <link rel="transformation"
                href="http://ns.inria.fr/grddl/rdfa/2008/09/03/RDFa2RDFXML.xsl"/>

       </head>
       <body>
        <p about="#event1" typeof="cal:Vevent">
            <b property="cal:summary">Weekend off in Iona</b>:
            <span property="cal:dtstart" content="2006-10-21" datatype="xs:date">Oct 21st</span>
            to <span property="cal:dtend" content="2006-10-21"  datatype="xs:date">Oct 23rd</span>.
            See <a rel="cal:url" href="http://freetime.example.org/">FreeTime.Example.org</a> for
            info on <span property="cal:location">Iona, UK</span>.
        </p>
        <p about="#event2" typeof="cal:Vevent">
            <b property="cal:summary">Holiday in Ireland</b>:
            <span property="cal:dtstart" content="2006-12-23" datatype="xs:date">Dec 23rd</span>
            to <span property="cal:dtend" content="2006-12-27"  datatype="xs:date">Dec 27th</span>.
            See <a rel="cal:url" href="http://vacation.example.org/">Vacation.Example.org</a> for
            info on <span property="cal:location">Belfast, Ireland</span>.
        </p>
        <p><b>New Years!</b> Now it's 2007...</p>
        <p about="#event3" typeof="cal:Vevent">
            <b property="cal:summary">Web Conference</b>:
            <span property="cal:dtstart" content="2007-01-08" datatype="xs:date">Jan 8th</span>
            to <span property="cal:dtend" content="2007-01-11"  datatype="xs:date">Jan 11th</span>.
            See <a rel="cal:url" href="http://webconf.example.org/">webconf.example.org</a> for
            info on <span property="cal:location">Edinburgh, UK</span>.
        </p>
       </body>
      </html>


      Données extraites (N3)

      @prefix ns0:     <http://www.w3.org/2002/12/cal/icaltzd#> .
      @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

      <http://example.org/#event1>
            a       ns0:Vevent ;
            ns0:dtend "2006-10-21"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:dtstart "2006-10-21"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:location "Iona, UK" ;
            ns0:summary "Weekend off in Iona" ;
            ns0:url <http://freetime.example.org/> .

      <http://example.org/#event3>
            a       ns0:Vevent ;
            ns0:dtend "2007-01-11"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:dtstart "2007-01-08"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:location "Edinburgh, UK" ;
            ns0:summary "Web Conference" ;
            ns0:url <http://webconf.example.org/> .

      <http://example.org/#event2>
            a       ns0:Vevent ;
            ns0:dtend "2006-12-27"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:dtstart "2006-12-23"^^<http://www.w3.org/2001/XMLSchema#date> ;
            ns0:location "Belfast, Ireland" ;
            ns0:summary "Holiday in Ireland" ;
            ns0:url <http://vacation.example.org/> .


      Remarques
      Nous avons vu la quasi-totalité de la mécanique à l'œuvre dans cet exemple.
      Seule nouveauté, l'emploi de l'attribut content conjointement avec property, qui permet de
      donner comme valeur à property la valeur de content au lieu du contenu textuel de l'élément en cours.

      Exploitation
      À partir des trois ressources RDF obtenues en extrayant les données contenues dans les calendriers de Robin (en hCalendar),
      de David (en Embedded RDF) et de Jane (en RDFa), on peut formuler une requête SPARQL pour déterminer des rencontres possibles.

      Voici une telle requête, accompagnée du commentaire original [repris au GRDDL-Primer] :

      PREFIX ical: <http://www.w3.org/2002/12/cal/icaltzd#>
      PREFIX xs: <http://www.w3.org/2001/XMLSchema#>

      SELECT ?start1 ?stop1 ?loc1 ?summ1 ?summ2 ?summ3

      FROM <http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/MicroFormats/ExRDFa/Jane/Jane.xml>
      FROM <http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/MicroFormats/EmbedRDF/David.xml>
      FROM <http://pagesperso-systeme.lip6.fr/Jean-Francois.Perrot/inalco/XML/RDF/MicroFormats/hCalendar/Robin.xml>

      WHERE
        {
          ?event1 a ical:Vevent;
                    ical:summary ?summ1 ;
                    ical:dtstart ?start1 ;
                    ical:dtend ?stop1 ;
                    ical:location ?loc1.
            ?event2 a ical:Vevent;
                    ical:summary ?summ2 ;
                    ical:dtstart ?start2;
                    ical:dtend ?stop2;
                    ical:location ?loc2.
            ?event3 a ical:Vevent;
                    ical:summary ?summ3 ;
                    ical:dtstart ?start3;
                    ical:dtend ?stop3;
                    ical:location ?loc3.
            FILTER (  ?event1 != ?event2 &&  ?event2 != ?event3  &&  ?event1 != ?event3  ) .
            FILTER ( xs:string(?start1) = xs:string(?start2) ).
            FILTER ( xs:string(?stop1) = xs:string(?stop2) ).
            FILTER ( xs:string(?loc1) = xs:string(?loc2) ).
            FILTER ( xs:string(?start1) = xs:string(?start3) ).
            FILTER ( xs:string(?stop1) = xs:string(?stop3) ).
            FILTER ( xs:string(?loc1) = xs:string(?loc3) ).
            FILTER ( xs:string(?start3) = xs:string(?start2) ).
            FILTER ( xs:string(?stop3) = xs:string(?stop2) ).
            FILTER ( xs:string(?loc3) = xs:string(?loc2) ).
            FILTER ( xs:string(?summ1) <= xs:string(?summ2) ).
            FILTER ( xs:string(?summ2) <= xs:string(?summ3) ).
      }

      The SELECT line determines which variable will appear in the results, here one of the start dates, one of the stop dates, a location and a summary.
      The FROM lines identify the data sources to use in the query, in this case the RDF/XML derived from Jane, David and Robin's original documents.
      The WHERE section provides a pattern which can match three events.
      The first block of FILTERs match up identical start and stop dates as well as locations between the three events.
      These values, which may be differently typed, are simplified to simple literals with the str() operator.
      The final two FILTER lines are idiomatic expressions which prevent multiple results returning due to the interchangeability of the variables.


      Et comme on s'en doute l'évaluation de cette requête conduit à un rendez-vous à Édimbourg !

      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      | start1                | stop1                 | loc1            | summ1            | summ2                      | summ3                                                                        |
      ==================================================================================================================================================================================================
      | "2007-01-08"^^xs:date | "2007-01-11"^^xs:date | "Edinburgh, UK" | "Web Conference" | "Web Design Conference"@en | "pick up a lifetime\n      achievement award from the Web Design Conference" |
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


      Exercice :  En simplifiant la requête ci-dessus, écrivez-en une qui demande à chacun de nos trois amis à quelles dates et pour quelle raison
      il se trouve à Édimbourg, et transformez le fichier RDF-XML obtenu en une page XHTML qui s'affiche grosso modo ainsi :
      Jane est à Édimbourg du .... au .... pour ...., David y est du .... au .... pour ...., et Robin du .... au .... pour .....