Diego Berrueta, Sergio Fernández and Iván Frade (Fundación CTIC)
ESWC2008 workshop on Scripting for the Semantic Web (SFSW2008)
June 2nd 2008
Content negotiation is a HTTP mechanism that makes it possible to
serve different versions of a document
Apache HTTP Server provides three different approaches to implement content negotiation:
# Rewrite rule to serve HTML content if requested
RewriteCond %{HTTP_ACCEPT} !application/rdf\+xml.*(text/html|application/xhtml\+xml)
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
RewriteRule ^example3$ example3.html [R=303]
# Rewrite rule to serve RDF/XML content if requested
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^example3$ example3.rdf [R=303]
# Rewrite rule to serve the RDF/XML content by default
RewriteRule ^example3$ example3.rdf [R=303]
An example of a test over SIOC ontology's namespace:
#req12 a earl:TestRequirement ;
dct:hasPart a earl:Assertion ;
earl:mode http://www.w3.org/WAI/ER/EARL/nmg-strawman#automatic ;
earl:assertedBy #vapour ;
earl:test #TestResponseCode200 ;
earl:subject :rFmCDRcX137 .
:rFmCDRcX137 a earl:TestSubject ;
dc:title "1st request while dereferencing vocabulary URI" ;
dc:date "2008-05-27T20:36:21.318143" ;
earl:httpRequest a http:GetRequest ;
http:accept application/rdf+xml ;
uri:uri http://rdfs.org/sioc/ns# .
earl:httpResponse a http:Response ;
http:responseCode "200" ;
http:content-type "application/rdf+xml" .
Another example of a test over foaf:Person class:
:FmCDRcX51 a earl:TestSubject ;
dc:title "1st request while dereferencing class URI" ;
dc:date "2008-05-27T20:38:34.433181" ;
earl:httpRequest a http:GetRequest ;
http:accept application/rdf+xml ;
uri:uri http://xmlns.com/foaf/0.1/Person .
earl:httpResponse a http:Response ;
http:responseCode "303" ;
http:location http://xmlns.com/foaf/spec/ ;
vapour:nextSubject :FmCDRcX52 .
:FmCDRcX52 a earl:TestSubject ;
dc:title "2nd request while dereferencing vocabulary URI" ;
dc:date "2008-05-27T20:36:24.318251" ;
vapour:previousSubject :FmCDRcX51;
earl:httpRequest a http:GetRequest ;
http:accept application/rdf+xml ;
uri:uri http://xmlns.com/foaf/spec/ .
earl:httpResponse a http:Response ;
http:responseCode "200" ;
http:content-type "application/rdf+xml" .
Vapour against a list of ten popular vocabularies (retrieved on 12/Mar/2008):
| Namespace | Acccept RDF/XML | Accept HTML | Default response |
|---|---|---|---|
| http://www.w3.org/1999/02/22-rdf-syntax-ns# | 3/3 | N/A | RDF/XML |
| http://www.w3.org/2000/01/rdf-schema# | 3/3 | N/A | RDF/XML |
| http://xmlns.com/foaf/0.1/ | 3/3 | 3/3 | RDF/XML |
| http://purl.org/dc/elements/1.1/ | 2/2 | 0/2 | RDF/XML |
| http://www.w3.org/2003/01/geo/wgs84_pos# | 3/3 | 0/3 | RDF/XML |
| http://rdfs.org/sioc/ns# | 3/3 | 0/3 | RDF/XML |
| http://www.w3.org/2004/02/skos/core# | 3/3 | 3/3 | RDF/XML |
| http://usefulinc.com/ns/doap# | 3/3 | 0/3 | RDF/XML |
| http://purl.org/rss/1.0/ | 1/3 | 0/3 | HTML |
| http://semantic-mediawiki.org/swivt/1.0# | 0/3 | 0/3 | text/plain |
Thank you!
Diego Berrueta <diego.berrueta@fundacionctic.org>
Sergio Fernández <sergio.fernandez@fundacionctic.org>
Iván Frade <ivan.frade@gmail.com>