6CC001 Workshop - week 09

From mi-linux
Revision as of 15:16, 27 January 2011 by In9352 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Main Page >> Advanced Web Technologies >> Workbook >> Week 09

Let's create an RDF file that specifies that:

  • This page is called “Watchmen” and is about comics
  • This page is called “Sin City” and is about comics
  • This page is called “Maus” and is about comics
  • This page is called “1984” and is about books
  • This page is called “Never le me go” and is about books
  • This page is called “Ender’s game” and is about books

Here is the code:

<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/">
  
      <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Watchmen">
          <dc:title>Watchmen</dc:title>
          <dc:subject>Comics</dc:subject>
      </rdf:Description>
      
      <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Sin_city">
          <dc:title>Sin City</dc:title>
          <dc:subject>Comics</dc:subject>
      </rdf:Description>
      
      <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Maus">
          <dc:title>Maus</dc:title>
          <dc:subject>Comics</dc:subject>
      </rdf:Description>
              
      <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Nineteen_Eighty-Four">
          <dc:title>1984</dc:title>
          <dc:subject>Books</dc:subject>
      </rdf:Description>
      
      <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Never_Let_Me_Go">
          <dc:title>Never let me go</dc:title>
          <dc:subject>Books</dc:subject>
      </rdf:Description>
      
      <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Ender%27s_game">
          <dc:title>Ender's game</dc:title>
          <dc:subject>Books</dc:subject>
      </rdf:Description>              
                  
</rdf:RDF>

Using SPARQL, I can easily ask for all the pages that are on the subject of “comics”:

SELECT ?x
FROM <http://mi-linux.wlv.ac.uk/~in9352/rdf/comics.rdf>
WHERE { ?x  <http://purl.org/dc/elements/1.1/subject>  "Comics" }

Let’s test our query with this free SPARQL processor:

These 3 pages are definitely on the topic of “comics” => better than Google’s keyword matching algorithm!

Sparql.gif