HttpUriConfig

From W3C Wiki

HTTP Server Setup Configurations for RDFS/OWL Ontologies Using HTTP URIs

This is a writeup of possible configurations for HTTP servers (using Apache 2.0 as the example), to support the use of HTTP URIs for identifying classes, properties and individuals in RDFS/OWL ontologies.

@@TODO get these checked by HTTP and Apache geeks ...

Minimum Requirements

For each HTTP URI denoting an RDFS/OWL class, property or individual ...

  1. ... it is possible for an HTTP client to obtain an RDF/XML serialisation of a set of RDF statements constituting the definitive RDF description of that class, property or individual, via one or more HTTP GET requests which include the header field 'Accept: application/rdf+xml'.
  2. ... it is not possible to receive a response to an HTTP request that is not consistent with TAG resolution on httpRange-14 [@@TODO ref].
  3. ... it is not possible to obtain responses to HTTP requests that lead to ambiguity, uncertainty, or inconsistency in the interpretation of the nature of the denoted resource.

Good-Practice Requirements

For each HTTP URI denoting an RDFS/OWL class, property or individual ...

  1. ... it is possible for an HTTP client to obtain the most relevant item of human-readable HTML content documentation for that class, property or individual, via one or more HTTP GET requests that include an 'Accept:' header field with the appropriate HTML content type(s).
  2. ... it is possible for an RDF application to differentiate between versions of the definitive RDF description of that class, property or individual, by using as provenance information the ultimate endpoint of an attempt to dereference the URI via an HTTP GET request with the header field 'Accept: application/rdf+xml'.

A note on 'Hash vs. Slash'

The use of both 'hash' and 'slash' HTTP URIs to denote RDFS/OWL classes, properties or individuals is potentially consistentent with the TAG resolution on httpRange-14 [@@TODO ref]. However, the practicalities of configuring an HTTP server to meet the minimum and good-practice requirements differ for hash and slash namespaces, therefore these are treated under different headings below.

Hash ('#') Namespaces

'Hash URIs' are e.g.:


http://www.example.com/foo#bar
http://www.example.com/foo/bar#baz


N.B. the fragment identifier (i.e. the bit after the '#') is not passed to the server in an HTTP request, this is mandated by the HTTP 1.1 specification (@@TODO ref).

Hash Static Configuration A ('Minimal')

Example implementation:

For class, property or individual denoted by the URI http://www.example.com/foo/bar#baz ...

  • Create a file called 'bar.rdf' that contains an RDF/XML serialisation of the definitive RDF decription of all resources denoted by URIs from the http://www.example.com/foo/bar# namespace.
  • Copy 'bar.rdf' to the directory '/apachedocumentroot/foo/' on the server.
  • Add a .htaccess file to the directory '/apachedocumentroot/foo/' that includes the following directives:


# Directive to ensure *.rdf files served as appropriate content type, if not present in main apache config
<FilesMatch "[^.]+\.rdf">
   ForceType "application/rdf+xml"
</FilesMatch>

# Rewrite rule to make sure we get to the right place from the namespace URI 
# (needed if MultiViews is enabled and other files or directories with a similar name exist)
RewriteEngine On
RewriteRule ^bar$ bar.rdf


Notes:

This setup ensures all HTTP GET requests return an RDF/XML serialisation.

Hash Static Configuration B ('Good-Practice')

Example implementation:

For class, property or individual denoted by the URI http://www.example.com/foo/bar#baz ...

  • Create a file '20051028.rdf' that contains an RDF/XML serialisation of the definitive RDF decription of all resources denoted by URIs from the http://www.example.com/foo/bar# namespace, as at 2005-10-28 (or whatever the relevant date is).
  • Create a file '20051028.html' that contains HTML content documentation about all resources denoted by URIs from the http://www.example.com/foo/bar# namespace, as at 2005-10-28 (or whatever the relevant date is). This document should include sections for each of the classes/properties/individuals documented, each section being headed by an HTML anchor that is identical to the fragment identifier of the documented class/property/individual.
  • Copy the file '20051028.rdf' to the directory '/apachedocumentroot/foo/bar/rdf/' on the server.
  • Copy the file '20051028.html' to the directory '/apachedocumentroot/foo/bar/html/' on the server.
  • Create a type-map file called 'bar.var' that contains the following:


URI: bar

URI: bar-latest-rdf
Content-type: application/rdf+xml

URI: bar-latest-html
Content-type: text/html, text/xml, application/xml, application/xhtml+xml


  • Copy 'bar.var' to the directory '/apachedocumentroot/foo/' on the server.
  • Add a .htaccess file to the directory '/apachedocumentroot/foo/' that includes the following directives:


RewriteEngine On

# Setup rewrite to type-map from namespace URI
RewriteRule ^bar$ bar.var

# Setup redirect for RDF
RewriteRule ^bar-latest-rdf$ /foo/bar/rdf/20051028 [R=303]

# Setup redirect for HTML
RewriteRule ^bar-latest-html$ /foo/bar/html/20051028 [R=303]


  • Make sure that for both directories '/foo/bar/rdf/' and '/foo/bar/html/' that MultiViews is enabled, and that the directive to serve '.rdf' files as content-type 'application/rdf+xml' is present either in the main apache configuration or in the relevant '.htacess' file.

Notes:

This setup means that all hash URIs are 'clickable'. I.e. if you put http://www.example.com/foo/bar#baz in your browser, you get redirected to http://www.example.com/foo/bar/html/20051028, which should have a 'baz' anchor, which makes the browser go straight to the relevant bit of documentation.

This setup also means clients asking for RDF/XML always end up at a snapshot, and can use provenance to differentiate between snapshots.

Slash ('/') Namespaces

'Slash URIs' are e.g.:


http://www.example.com/foo/bar
http://www.example.com/foo/bar/baz


Slash Static Configuration A ('Minimal')

(N.B. I haven't tested this!!)

Example implementation:

For class, property or individual denoted by the URI http://www.example.com/foo/bar/baz ...

  • Create a file called 'index.rdf' that contains an RDF/XML serialisation of the definitive RDF decription of all resources denoted by URIs from the http://www.example.com/foo/bar/ namespace.
  • Copy 'index.rdf' to the directory '/apachedocumentroot/foo/bar/' on the server.
  • Add a .htaccess file to the directory '/apachedocumentroot/foo/bar/' that includes the following directives:


# Directive to ensure *.rdf files served as appropriate content type, if not present in main apache config
<FilesMatch "[^.]+\.rdf">
   ForceType "application/rdf+xml"
</FilesMatch>

RewriteEngine On

# Rewrite rule to make sure we serve the file for the namespace URI
RewriteRule ^$ index.rdf

# Rewrite rule to make sure we do a redirect for any class/prop/individual URIs
RewriteRule ^.+$ /foo/bar/ [R=303]


Notes:

@@TODO Does this work???

Slash Static Configuration B ('Good-Practice')

Example implementation:

For class, property or individual denoted by the URI http://www.example.com/foo/bar/baz ...

  • Create a file called '20051028.rdf' that contains an RDF/XML serialisation of the definitive RDF decription of all resources denoted by URIs from the http://www.example.com/foo/bar/ namespace, as at 2005-10-28 (or whatever is relevant date).
  • Create a file called '20051028.html' that contains HTML content documentation about all resources denoted by URIs from the http://www.example.com/foo/bar/ namespace, as at 2005-10-28 (or whatever the relevant date is).
  • Copy '20051028.rdf' to the directory '/apachedocumentroot/foo/bar/rdf/' on the server.
  • Copy '20051028.html' to the directory '/apachedocumentroot/foo/bar/html/' on the server.
  • Create a file called 'index.var' containing the following:


URI: 

URI: latest-rdf
Content-type: application/rdf+xml

URI: latest-html
Content-type: text/html, text/xml, application/xml, application/xhtml+xml


  • Copy 'index.var' to the directory '/apachedocumentroot/foo/bar/' on the server.
  • Add a .htaccess file to the directory '/apachedocumentroot/foo/bar/' that includes the following directives:


RewriteEngine On

# Setup rewrite to type-map from namespace URI and all class/prop/individual URIs
RewriteRule ^.*$ index.var

# Setup redirect for RDF
RewriteRule ^latest-rdf$ /foo/bar/rdf/20051028 [R=303]

# Setup redirect for HTML
RewriteRule ^latest-html$ /foo/bar/html/20051028 [R=303]


  • Make sure that for both directories '/foo/bar/rdf/' and '/foo/bar/html/' that ?MultiViews is enabled, and that the directive to serve '.rdf' files as content-type 'application/rdf+xml' is present either in the main apache configuration or in the relevant '.htacess' file.

Notes:

Because you cannot include a '#' in the redirect URI, you cannot redirect from a class/prop/individual slash URI to a fragment of an HTML document. What you can do, however, is ...

Slash Static Configuration C ('Good-Practice Plus')

Example implementation:

For class, property or individual denoted by the URI http://www.example.com/foo/bar/baz ...

  • Create a file called '20051028.rdf' that contains an RDF/XML serialisation of the definitive RDF decription of all resources denoted by URIs from the http://www.example.com/foo/bar/ namespace, as at 2005-10-28 (or whatever is relevant date).
  • Create a file called 'baz.html' that contains HTML content documentation, only about the resource denoted by http://www.example.com/foo/bar/baz, as at 2005-10-28 (or whatever the relevant date is). (Do the same for each of the class, props and individuals for the http://www.example.com/foo/bar/ namespace).
  • Copy '20051028.rdf' to the directory '/apachedocumentroot/foo/bar/rdf/' on the server.
  • Copy 'baz.html' to the directory '/apachedocumentroot/foo/bar/html/20051028/' on the server.
  • Create a file 'index.var' containing the following:


URI: 

URI: latest-rdf
Content-type: application/rdf+xml

URI: latest-html
Content-type: text/html, text/xml, application/xml, application/xhtml+xml


  • Copy 'index.var' to the directory '/apachedocumentroot/foo/bar/' on the server.
  • Add a .htaccess file to the directory '/apachedocumentroot/foo/bar/' that includes the following directives:

RewriteEngine On

RewriteRule ^$ index.var

RewriteRule ^latest-rdf$ /foo/bar/rdf/20051028 [R=303]

RewriteRule ^latest-html$ /foo/bar/html/20051028 [R=303]

RewriteRule