Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document describes best practice recipes for publishing vocabularies or ontologies on the Web (in RDF Schema or OWL). The features of each recipe are described in detail, so that vocabulary designers may choose the recipe best suited to their needs. Each recipe introduces general principles and an example configuration for use with an Apache HTTP server (which may be adapted to other environments). The recipes are all designed to be consistent with the architecture of the Web as currently specified, although the associated example configurations have been kept intentionally simple.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document was prepared by the Semantic Web Deployment Working Group (SWD), based on previous work by the Semantic Web Best Practices and Deployment Working Group (SWBPD). This work is part of the W3C Semantic Web Activity.
This document is a Note documenting some best practices. At the time of publication the Semantic Web Deployment Working Group has no plans for further work on this document. This version addresses several comments made on the previous version. It does not, however, attempt to address the known issue related to 'q' values in content negotiation nor does it provide recipes for publishing vocabularies using RDFa [RDFA] and GRDDL [GRDDL], both of which are recognized as useful techniques for some vocabularies.
Comments are welcome and may be sent to [email protected]; please include the text "comment" in the subject line. All messages received at this address are viewable in a public archive. The Working Group may respond to comments as time is available. We encourage the community to discuss aspects of this Note in the Semantic Web Interest Group mailing list (public archive).
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document is intended for the creators and maintainers of vocabularies in RDFS and OWL (vocabulary and ontology are used interchangeably in the context of this specification). It provides step-by-step instructions for publishing vocabularies on the Web, giving example configurations designed to cover the most common cases. For more information about RDFS and OWL see [RDFS, RDFPrimer, OWLGuide, OWLFeatures].
This “cookbook” gives “recipes” describing the steps needed to publish a vocabulary on a Web server, and to configure the Web server to support Semantic Web applications. The section “Choosing a recipe” provides guidance for choosing the most appropriate recipe depending on the situation and requirements. Once the recipe has been chosen, the reader can follow the steps, adapting the examples for a particular vocabulary.
All of the recipes give example configurations for the Apache HTTP server [APACHE20]. For those not already familiar with Apache configuration, the appendix on Apache configuration provides a short introduction to the Apache configuration mechanisms used in the examples and basic information on troubleshooting.
While the provided configuration examples are specific to an Apache HTTP server, the general principles apply to non-Apache environments as well. The Working Group invites contributions of additional bindings for non-Apache servers. The W3C has provided a wiki page to collect these non-Apache bindings and recommendations.
This document is primarily intended for creators and maintainers of existing vocabularies who are looking for guidance on how their vocabularies should best be published on the Web. It is not intended to provide detailed and exhaustive guidance on choosing an appropriate URI namespace for naming a new vocabulary and its constituent terms. However, some basic technical information about URI namespaces, including some considerations relevant to choosing a URI namespace for a vocabulary, is given in the section on URI namespaces.
The recipes have all been designed to be consistent with the architectural principles of the World Wide Web as currently specified in the document "Architecture of the World Wide Web" [AWWW04]. In order to verify that they are in fact so, a set of minimum requirements is described at the end of this document. These minimum requirements are intended to articulate the fundamental requirements of Semantic Web applications. All of the recipes when correctly implemented should satisfy the minimum requirements. A set of extended requirements is also given. The extended requirements are intended to articulate further practical needs of Semantic Web application developers, such as providing documentation about a vocabulary on Web pages in HTML. Recipes 3, 4, 5 and 6, when correctly implemented, should satisfy the extended requirements.
In order to satisfy the extended requirements, the recipes 3, 4, 5, and 6 configure a server to perform content negotiation. A brief explanation of this process is given in the section on content negotiation, along with a description of some options for coping with variability in deployed client behavior.
Appendix A describes how to adapt the six recipes given in the main body of the document for the special case of vocabularies identified using "persistent URLs", or PURLs, which are resolved using PURL services such as http://purl.org/ [PURL].
For brevity, the rationale behind each of the recipes is not described in this document. Readers wishing to go deeper should consult URI/Resource Relationships in "Architecture of the World Wide Web" [AWWW04], fragment identifiers in HTTP URIs [RFC3986] [RFC2616], the W3C Interest Group Note: "Cool URIs for the Semantic Web" [COOLURI], and the W3C Technical Architecture Group's resolution on the range of HTTP dereferencing (aka "httpRange-14"). [HTTPRANGE14]
Finally, it should be noted that the Recipes described in this Cookbook are not the only way to publish a vocabulary or ontology for use by Semantic Web applications. RDFa and its cousin GRDDL may in the near future provide an effective method for publishing documents for use by both people and machines. But a useful discussion of RDFa and GRDDL is well beyond the scope of this document.
The choice of recipe depends primarily on what types of content you wish to provide from your vocabulary URI and the URIs of the classes and properties defined by your vocabulary. URI namespaces are described in more detail in Appendix B; throughout this document, the expression "vocabulary URI" can be interpreted as "vocabulary namespace URI".
Configuration | hash namespace | slash namespace |
Machine processable RDF | Recipe 1 | Recipe 2 |
Machine processable RDF (using PURLs) | Recipe 1a | Recipe 2a |
RDF and Single HTML document | Recipe 3 | Recipe 4 |
RDF and Single HTML document (using PURLs) | Recipe 3a | Recipe 4a |
RDF and Multiple HTML documents | Recipe 5 or Recipe 6 | |
RDF and Multiple HTML documents(using PURLs) | Recipe 5a |
The simplest recipes configure your server to provide only machine-processable (RDF) content from the vocabulary URI.
If you are using a hash namespace see Recipe 1 or, if using PURLs, Recipe 1a.
If you are using a slash namespace see Recipe 2 or, if using PURLs, Recipe 2a.
The extended recipes configure your server to provide both machine-processable (RDF) and human-readable (HTML) content (see also the section content negotiation below). These recipes are easily extended to serve additional content types.
If you are using a hash namespace and want to provide both RDF and HTML content, see Recipe 3 or, if using PURLs, Recipe 3a.
If you are using a slash namespace and want to provide both RDF and HTML content, where the HTML content is contained in a single document, see Recipe 4 or, if using PURLs, Recipe 4a.
If you are using a slash namespace and want to provide both RDF and HTML content, where the HTML content is served as individual hyperlinked documents for each class or property, with an overview (e.g. a table of contents or an index) at the vocabulary URI, see Recipe 5 or, if using PURLs, Recipe 5a.
If you are using a slash namespace and want to provide both RDF and HTML content, where the HTML content is served as individual hyperlinked documents for each class or property, and where the RDF is served as bounded descriptions of each class or property, see Recipe 6.
When an HTTP client attempts to dereference a URI, it can specify which type (or types) of content it would prefer to receive in response. It does this by including an 'Accept:' field in the header of the request message, the value of which gives MIME types corresponding to preferred content types. For example, an HTTP client that prefers RDF/XML content might include the following field in the header of each request:
Accept: application/rdf+xml
Similarly, an HTTP client that prefers HTML content, such as a Web browser, might include something like the following field in the header of each request:
Accept: application/xhtml+xml,text/html
It is accepted as a principle of good practice that HTTP clients SHOULD include an 'Accept:' field in a request header, explicitly specifying those content types that may be handled.
When the server receives a request, it can use the value(s) of the 'Accept:' field to select the most appropriate response from those available, attempting to meet the preference of the client as closely as possible. This process is an example of content negotiation [AWWW04].
Recipes 1 and 2 below do not configure the server to perform any content negotiation. RDF/XML is the only representation type available, and is provided irrespective of the value of the 'Accept:' header sent by the client.
Recipes 3, 4, 5 and 6 below do configure the server to perform content negotiation based on the value of the 'Accept:' header field sent by the client. However, the proposed configuration examples do not handle the full HTTP specification with respect to content negotiation. Actually, although the examples accommodate some client ordering preferences in content negotiation, they do not handle the 'q' metrics. Therefore, HTTP clients which use q-values in the 'Accept' header may obtain unexpected results.
Editor's note: The Working Group is considering alternatives to be fully compliant with the HTTP specification, while keeping the recipes as simple as possible. This is recorded as ISSUE-58 in the Working Group's issue process. Comments on this issue are invited, and should be sent in an email to the SWD Working Group, starting the subject line with "Comment: ISSUE-58".
When the server is configured to perform content negotiation, a 'default behavior' must be specified -- the server must be able to determine which response should be sent in the cases where:
In recipes 3, 4, 5, and 6 below, RDF/XML is configured as the default response. This is chosen to minimize the impact on deployed Semantic Web applications that do not currently send appropriate 'Accept:' header field values for RDF content. Bear in mind that if HTML is configured as the default response, some existing Semantic Web applications expecting to receive RDF content will receive HTML content instead, and will break.
Developers and maintainers of Semantic Web applications that expect to process RDF content, and that do not currently provide an 'Accept:' header field in HTTP requests, should plan to provide such a header in the future.
A suitable value of the 'Accept:' field is as follows:
Accept: application/rdf+xml,application/xml;q=0.5
The 'q=0.5' value in the above example indicates a relative quality value as specified by Section 14 the HTTP 1.1 protocol [RFC2616]. The default 'q' value if none is specified is 1.0. This example can be read as "I prefer 'application/rdf+xml, giving it the default relative quality value of 1.0, but will still accept application/xml, although I consider it to be only 50% of the value of application/rdf+xml".
Unlike most other browsers, Internet Explorer sends 'Accept:' headers containing a catch-all */* without a mediating 'q' value. In contrast, both Firefox and Safari accept */*;q=0.5, and Opera accepts */*;q=0.1. Establishing a default behavior that takes this into account requires the insertion of a rewrite condition based on the value of the 'User-agent:' header field:
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
Additionally, if you also want to retain 'clickable' URIs in IE, you must set HTML as the default response (see comments in examples for instructions on how to do this).
Effectively testing the results of content negotiation can become fairly complex for some of the Recipes. In order to facilitate the testing of the results of content negotiation on a single URI a content negotiation testing service has been established.
This service will request a provided URI from a server, run a test suite specifically designed to test the response of the server against the Recipe specifications, and display a pass/fail report on each set of tests as well as a detailed explanation of its findings.
The source code for the testing service is also available.
Jump straight to: Example configuration | Testing the configuration
This recipe gives an example of the simplest possible configuration for a vocabulary that uses a hash namespace. The recipe configures the server to provide machine-processable (RDF) content from the vocabulary URI, thereby satisfying the minimum requirements. This is illustrated by the following diagram:
(Serve the RDF description of the vocabulary, encoded as RDF/XML.)
For a vocabulary …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example1
defining classes …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example1#ClassA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example1#ClassB
and properties …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example1#propA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example1#propB
Create a file called example1.rdf that contains a complete RDF/XML serialization of the vocabulary. I.e. all resources defined by the vocabulary are described in this file.
Copy the example1.rdf file to the /apachedocumentroot/examples/ directory on the server.
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory on the server:
# Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to serve RDF/XML content from the vocabulary URI RewriteRule ^example1$ example1.rdf
(N.B. If a .htaccess file does not exist, create one.)
If this configuration is working, it should support the following interactions:
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example1 HTTP/1.1 Host: example.com
Response header should contain the following fields:
HTTP/1.x 200 OK Content-Type: application/rdf+xml
Jump straight to: Example configuration | Testing the configuration
This recipe gives an example of the simplest possible configuration for a vocabulary that uses a slash namespace. The recipe configures the server to provide machine-processable (RDF) content from the vocabulary URI, and to redirect the client to the vocabulary URI from class and property URIs, thereby satisfying the minimum requirements. This is illustrated by the following diagrams:
(Serve the RDF description of the vocabulary, encoded as RDF/XML.)
(Redirect the client to the vocabulary URI.)
For vocabulary …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example2/
defining classes …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example2/ClassA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example2/ClassB
and properties …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example2/propA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example2/propB
Create a file called example2.rdf that contains a complete RDF/XML serialization of the vocabulary. I.e. all resources defined by the vocabulary are described in this file.
Copy the example2.rdf file to the /apachedocumentroot/examples/ directory on the server.
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory on the server:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to redirect 303 from any class or prop URI RewriteRule ^example2/.+ example2/ [R=303] # Rewrite rule to serve RDF/XML content from the vocabulary URI RewriteRule ^example2/$ example2.rdf
(N.B. If a .htaccess file does not exist, create one.)
The directory option 'MultiViews' must be disabled for this configuration to work, and a directory called /apachedocumentroot/examples/example2/ must not actually exist on the server's file system.
If this configuration is working, it should support the following interactions:
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example2/ HTTP/1.1 Host: example.com
Response header should contain the following fields:
HTTP/1.x 200 OK Content-Type: application/rdf+xml
Test message (substitute correct path and host for your class or property URI):
GET /examples/example2/ClassA HTTP/1.1 Host: example.com
Response header should contain the following fields, with your vocabulary URI as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example2/
Jump straight to: Example configuration | Testing the configuration | Notes
This recipe gives an example of an extended configuration for a vocabulary with a hash namespace. The recipe configures the server to provide either human-readable (HTML) or machine-processable (RDF) content from the vocabulary URI, depending on what is requested, thereby satisfying the extended requirements. This is illustrated by the following diagrams:
(Redirect the client to current HTML documentation for the vocabulary.)
(Redirect the client to the current RDF description of the vocabulary.)
For vocabulary …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example3
defining classes …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example3#ClassA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example3#ClassB
and properties …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example3#propA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example3#propB
Create a file called 2005-10-31.rdf that contains a complete RDF/XML serialization of the vocabulary, as at 2005-10-31 (or whatever the current date is). I.e. all resources defined by the vocabulary are described in this file, and this file represents a 'snapshot' or 'version' of the vocabulary.
Create a file called 2005-10-31.html that contains HTML content documentation about all classes and properties defined by the vocabulary as at 2005-10-31 (or whatever the current date is). This document may include sections for each of the classes/properties documented, each section being headed by an HTML anchor whose name is identical to the fragment identifier of the documented class or property.
Copy 2005-10-31.rdf and 2005-10-31.html to the directory /apachedocumentroot/examples/example3-content/ on the server.
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to serve HTML content from the vocabulary URI 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-content/2005-10-31.html [R=303] # Rewrite rule to serve RDF/XML content from the vocabulary URI if requested RewriteCond %{HTTP_ACCEPT} application/rdf\+xml RewriteRule ^example3$ example3-content/2005-10-31.rdf [R=303] # Choose the default response # --------------------------- # Rewrite rule to serve the RDF/XML content from the vocabulary URI by default RewriteRule ^example3$ example3-content/2005-10-31.rdf [R=303] # Rewrite rule to serve HTML content from the vocabulary URI by default (disabled) # (To enable this option, uncomment the rewrite rule below, and comment # out the rewrite rule directly above) # RewriteRule ^example3$ example3-content/2005-10-31.html [R=303]
(N.B. If a .htaccess file does not exist, create one.)
If this configuration is working, it should support the following interactions:
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example3 HTTP/1.1 Host: example.com Accept: text/html
Response header should contain the following fields, with your HTML content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example3-content/2005-10-31.html
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example3 HTTP/1.1 Host: example.com Accept: application/rdf+xml
Response header should contain the following fields, with your current RDF content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example3-content/2005-10-31.rdf
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example3 HTTP/1.1 Host: example.com
Response header should contain the following fields, with your current RDF content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example3-content/2005-10-31.rdf
This example uses the modification date of the vocabulary version to create file names. It would also be possible to use version numbers (e.g. '1.01') instead of dates for this purpose, or indeed any convention that makes it possible to differentiate between vocabulary versions, and helps to keep track of version history.
See also the section on content negotiation.
Jump straight to: Example configuration | Testing the configuration | Notes
This recipe gives an example of an extended configuration for a vocabulary with a slash namespace. The recipe configures the server to provide either human-readable (HTML) or machine-processable (RDF) content from the vocabulary URI, depending on what is requested, and to redirect the client from class and property URIs to the appropriate content locations, again depending on what is requested, thereby satisfying the extended requirements. The HTML documentation is served as a single file. This behavior is illustrated by the following diagrams:
(As per Recipe 3, redirect the client to current HTML documentation for the vocabulary.)
(As per Recipe 3, redirect the client to the current RDF description of the vocabulary.)
(Redirect the client to the fragment of current HTML documentation for the vocabulary relevant to the class or property.)
(Redirect the client to the current RDF description of the vocabulary.)
For vocabulary …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example4/
defining classes …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example4/ClassA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example4/ClassB
and properties …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example4/propA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example4/propB
Create a file called 2005-10-31.rdf that contains a complete RDF/XML serialization of the vocabulary, as at 2005-10-31 (or whatever the current date is). I.e. all resources defined by the vocabulary are described in this file, and this file represents a 'snapshot' or 'version' of the vocabulary.
Create a file called 2005-10-31.html that contains HTML content documentation about all classes and properties defined by the vocabulary as at 2005-10-31 (or whatever the current date is). This document may include sections for each of the classes/properties documented, each section being headed by an HTML anchor whose name is identical to the fragment identifier of the documented class or property.
Copy 2005-10-31.rdf and 2005-10-31.html to the directory /apachedocumentroot/examples/example4-content/ on the server.
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to serve HTML content from the vocabulary URI 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 ^example4/$ example4-content/2005-10-31.html [R=303] # Rewrite rule to serve directed HTML content from class/prop URIs 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 ^example4/(.+) example4-content/2005-10-31.html#$1 [R=303,NE] # Rewrite rule to serve RDF/XML content if requested RewriteCond %{HTTP_ACCEPT} application/rdf\+xml RewriteRule ^example4/ example4-content/2005-10-31.rdf [R=303] # Choose the default response # --------------------------- # Rewrite rule to serve RDF/XML content by default RewriteRule ^example4/ example4-content/2005-10-31.rdf [R=303] # Rewrite rules to serve HTML content by default (disabled) # (To enable this option, uncomment the two rewrite rules below, # and comment out the rewrite rule directly above) # RewriteRule ^example4/$ example4-content/2005-10-31.html [R=303] # RewriteRule ^example4/(.+) example4-content/2005-10-31.html#$1 [R=303,NE]
(N.B. If a .htaccess file does not exist, create one.)
For this configuration to work, the directory option 'MultiViews' must be disabled, and a directory called /apachedocumentroot/examples/example4/ must not actually exist on the server's file system.
If this configuration is working, it should support the following interactions:
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example4/ HTTP/1.1 Host: example.com Accept: text/html
Response header should contain the following fields, with your HTML content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example4-content/2005-10-31.html
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example4/ HTTP/1.1 Host: example.com Accept: application/rdf+xml
Response header should contain the following fields, with your RDF content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example4-content/2005-10-31.rdf
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example4/ HTTP/1.1 Host: example.com
Response header should contain the following fields, with your RDF content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example4-content/2005-10-31.rdf
Test message (substitute correct path and host for your class or property URI):
GET /examples/example4/ClassA HTTP/1.1 Host: example.com Accept: text/html
Response header should contain the following fields, with your HTML content location (plus appropriate fragment identifier) as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example4-content/2005-10-31.html#ClassA
Test message (substitute correct path and host for your class or property URI):
GET /examples/example4/ClassA HTTP/1.1 Host: example.com Accept: application/rdf+xml
Response header should contain the following fields, with your RDF content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example4-content/2005-10-31.rdf
Test message (substitute correct path and host for your class or property URI):
GET /examples/example4/ClassA HTTP/1.1 Host: example.com
Response header should contain the following fields, with your RDF content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example4-content/2005-10-31.rdf
As with Recipe 3, this example uses the modification date of the vocabulary version to create file names. It would also be possible to use version numbers (e.g. '1.01') instead of dates for this purpose, or indeed any convention that makes it possible to differentiate between vocabulary versions, and helps to keep track of version history.
See also the section on content negotiation.
Jump straight to: Example configuration | Testing the configuration | Notes
This recipe gives an example of an extended configuration for a vocabulary with a slash namespace. The recipe configures the server to provide both machine-processable (RDF) and human-readable (HTML) content, depending on what is requested, with the HTML documentation being given as multiple hyperlinked HTML documents plus an overview document. This behavior is illustrated by the following diagrams:
(Redirect the client to current HTML overview documentation for the vocabulary.)
(As per Recipe 3 and Recipe 4, redirect the client to the current RDF description of the vocabulary.)
(Redirect the client to current HTML documentation for the class or property.)
(As per Recipe 4, redirect the client to the current RDF description of the vocabulary.)
For vocabulary …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example5/
defining classes …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example5/ClassA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example5/ClassB
and properties …
http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example5/propA http://www.w3.org/2006/07/SWD/recipes/examples-20080421/example5/propB
Create a file called 2005-10-31.rdf that contains a complete RDF/XML serialization of the vocabulary, as at 2005-10-31 (or whatever the current date is). I.e. all resources defined by the vocabulary are described in this file, and this file represents a 'snapshot' or 'version' of the vocabulary.
Copy 2005-10-31.rdf to the directory /apachedocumentroot/examples/example5-content/ on the server.
Create files ClassA.html ClassB.html propA.html propB.html each of which contains HTML content documentation relevant to the class or property with the corresponding local name, as at 2005-10-31 (or whatever the current date is). Create a file index.html that contains HTML content documentation about the vocabulary itself, with hyperlinks to all class or property documentation.
Copy ClassA.html ClassB.html propA.html propB.html and index.html to the directory /apachedocumentroot/examples/example5-content/2005-10-31-docs/ on the server.
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule 1: to serve HTML content from the namespace URI 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 ^example5/$ example5-content/2005-10-31-docs/index.html [R=303] # Rewrite rule 2: to serve HTML content from class or prop URIs 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 ^example5/(.+) example5-content/2005-10-31-docs/$1.html [R=303] # Rewrite rule 3: to serve RDF content is requested RewriteCond %{HTTP_ACCEPT} application/rdf\+xml RewriteRule ^example5/ example5-content/2005-10-31.rdf [R=303] # Choose the default response # --------------------------- # Rewrite rule 4: to serve RDF/XML content by default RewriteRule ^example5/ example5-content/2005-10-31.rdf [R=303] # Rewrite rules to serve HTML content by default (disabled) # (To enable this option, uncomment the two rewrite rules below, # and comment out the rewrite rule directly above) # RewriteRule ^example5/$ example5-content/2005-10-31-docs/index.html [R=303] # RewriteRule ^example5/(.+) example5-content/2005-10-31-docs/$1.html [R=303]
(N.B. If a .htaccess file does not exist, create one.)
If this configuration is working, it should support the following interactions:
Test message (substitute correct path and host for your vocabulary URI):
GET /examples/example5/ HTTP/1.1 Host: example.com Accept: text/html
Response header should contain the following fields, with your HTML overview content location as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example5-content/2005-10-31-docs/index.html
Same as Recipe 4.
Same as Recipe 4.
Test message (substitute correct path and host for your class or property URI):
GET /examples/example5/ClassA HTTP/1.1 Host: example.com Accept: text/html
Response header should contain the following fields, with the HTML content location for the given class or property as the value of the 'Location' field:
HTTP/1.x 303 See Other Location: http://example.com/examples/example5-content/2005-10-31-docs/ClassA.html
Same as Recipe 4.
Same as Recipe 4.
See also the section on content negotiation.
As with Recipe 3, this example uses the modification date of the vocabulary version to create file names. It would also be possible to use version numbers (e.g. '1.01') instead of dates for this purpose, or indeed any convention that makes it possible to differentiate between vocabulary versions, and helps to keep track of version history.
If you have the directory options Indexes and MultiViews enabled for the directory /apachedocumentroot/examples/example5-content/2005-10-31-docs/ then you can replace the rewrite rules 1 and 2 with one single rewrite rule:
RewriteCond %{HTTP_ACCEPT} text/html [OR] RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.* RewriteRule ^example5/(.*) example5-content/2005-10-31-docs/$1 [R=303]
This configuration is particularly suited to the use of documentation generated by the OWLDoc plugin for Protege.
This recipe gives an example of an extended configuration for a vocabulary with a slash namespace. The recipe configures the server to provide both machine-processable (RDF) and human-readable (HTML) content, depending on what is requested, with the HTML documentation being given as multiple hyperlinked HTML documents plus an overview document, and the RDF content being made available via a query service such that clients can obtain a partial RDF description of the vocabulary as appropriate.
Despite the fact that this recipe shares nearly all of the features of Recipe 5, the use of a query service or script to retrieve RDF content makes it arguably the most complex of the extended configurations and presents the greatest challenge to providing a directly usable recipe. So we have decided to present this recipe as a set of suggested implementation patterns rather than a 'just follow the numbers' recipe. Moreover, we do not describe a particular implementation pattern in the same level of detail employed in the other recipes. Consequently, some web programming knowledge is required to implement this recipe.
This pattern relies on some application logic deployed in the web server. This logic can be a thin layer that simply redirects the requests (or acts as a proxy) to a third-party web server (see the DBPedia example below), or a thick layer that loads an RDF datasource and translates the HTTP requests into API calls to execute the queries.
There are two alternatives to introducing server-side logic:
Sample implementation (valid for both alternatives 1 and 2).
The DBPedia server is used in the following example as the content provider:
RewriteCond %{HTTP_ACCEPT} text/html [OR] RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml RewriteRule ^example6/(.+) http://dbpedia.org/page/$1 [R=303] RewriteCond %{HTTP_ACCEPT} application/rdf\+xml RewriteRule ^example6/(.+) http://dbpedia.org/data/$1 [R=303] RewriteRule ^example6/(.+) http://dbpedia.org/data/$1 [R=303]
This is an example of a 'thin' implementation layer and the rewrite rules are straightforward:
The trickiest part of implementing Recipe 6 using application logic is to correctly implement HTTP content-negotiation from scratch. While most web scripting languages (PHP, Python, etc.) and frameworks provide access to the value of the HTTP headers and thus, to the 'Accept:' header, choosing the appropriate return type is far from trivial. The 'Accept:' header may contain wildcards and q-values, so regular expressions or simple string comparison functions are not enough. There is a wiki page with pointers to content negotiation libraries for different programming languages. The Working Group invites contributions of additional libraries and frameworks that support content negotiation.
This pattern does not involve writing any application logic. Instead, requests are HTTP-redirected using Apache mod_rewrite. This technique is particularly well-suited to wrap an existing SPARQL endpoint. We exploit the fact that many SPARQL endpoints export HTTP bindings.
Sample implementation:
RewriteCond %{HTTP_ACCEPT} text/html [OR] RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml RewriteRule ^example6/(.+) http://dbpedia.org/$1 [R=303] RewriteCond %{HTTP_ACCEPT} application/rdf\+xml RewriteRule ^example6/(.+) http://dbpedia.org/sparql?query=DESCRIBE+<http://dbpedia.org/$1> [R=303] RewriteRule ^example6/(.+) http://dbpedia.org/sparql?query=DESCRIBE+<http://dbpedia.org/$1> [R=303]
In this example, when the client asks for HTML content, the request is forwarded to an external web server. However, RDF requests are handled differently. A request for a URI such as http://example.org/example6/property/birthplace is redirected to the result of executing a DESCRIBE <http://dbpedia.org/property/birthplace> sentence against the DBPedia SPARQL endpoint. The result is an RDF graph which describes the resource (in this particular case, the property that links people to the place where they were born).
This section attempts to articulate the requirements and expectations of Semantic Web applications and application developers with respect to the HTTP behavior of vocabularies, classes, and properties denoted by HTTP URIs (i.e., URIs from the http: URI space). It is intended as a benchmark against which the example configurations given in the recipes above may be verified.
An HTTP client can obtain the 'authoritative' RDF description of a vocabulary, class, or property by performing an HTTP GET request against the URI of that vocabulary, class or property. The RDF description is returned as an HTTP response whose content type is a registered MIME type for RDF content (currently only 'application/rdf+xml').
This is the default behavior in the case that some form of content negotiation has been implemented for these URIs. I.e. an HTTP GET request without an 'Accept:' header field will result in a response with content type 'application/rdf+xml', which is a serialization of a set of RDF statements, including those statements that constitute the 'authoritative' RDF description of the denoted resource.
N.B. it is reasonable for an attempt to dereference the URI of an RDF property or class to result in an RDF description of more than just that property or class.
Currently the architecture of the Web allows applications to draw inferences about the nature of a resource denoted by an HTTP URI, based on the following:
(i) The HTTP response code obtained when dereferencing the URI (see the resolution of TAG issue 'httpRange-14' [HTTPRANGE14] ),
and …
(ii) Where the URI contains a fragment identifier, the content type(s) of the available representations [AWWW04].
Given these constraints, for each HTTP URI denoting an RDFS/OWL vocabulary, class or property, the range of possible responses to HTTP requests against that URI will not lead applications to draw any inconsistent conclusions.
These requirements are an extension of the minimum requirements.
An HTTP client such as a Web browser can obtain 'human-readable' documentation relating to an RDFS/OWL vocabulary, class or property, by performing an HTTP GET request against the URI of that vocabulary, class or property, specifying 'Accept:' headers appropriate to the desired content type in the request.
Vocabularies change over time as properties or classes are added or their descriptions are editorially changed. Applications need a way to differentiate between successive 'snapshots' of the vocabularies over time. To be precise, what is "versioned" is the description of a property -- i.e., a set of RDF statements about the property -- rather than the property itself, the URI of which does not change.
Conventions in common use for distinguishing successive descriptions include the use of version-number strings or date strings in filenames (e.g., 1.01.rdf or 2005-10-31.rdf) or in pathnames (e.g., http://dublincore.org/2008/01/14/dcelements.rdf#title). It should be noted that, at present, there are no generally accepted conventions for using date or version-number strings in this way.
The examples attempt to distill elements of good practice from currently deployed Semantic Web vocabularies, especially the Dublin Core Metadata Terms, the Friend of a Friend Ontology, and the SKOS Core Vocabulary. All those who contributed to the development of these practices are gratefully acknowledged.
This bibliography as: BibTex | BibTeXML | RDF
PURLs ('Persistent URLs') are URIs from the http://purl.org/ URI space. PURLs are supported by a PURL resolution service, which allows the registered owners of a PURL domain to redirect HTTP requests against a PURL to an arbitrary resource URL. Registered owners of PURLs may not configure the central PURL server other than to specify the redirect URL for each PURL.
When the central PURL server was originally developed in the 1990s, the standard response of an HTTP server to a request against a PURL was to return a response code of 302 ("temporarily moved"). Web architecture has evolved since then, and the Technical Architecture Group (TAG) of W3C has resolved that, for the purpose of such redirects for RDF Class and Property names, the response code 303 ("see other") should be returned (see the TAG resolution on httpRange-14 [HTTPRANGE14]).
As PURL servers use a 302 response code and there is currently no way to configure them to use 303 response codes, existing vocabularies with http://purl.org slash namespaces servers do not strictly conform to the current TAG recommendations. These cases are treated in the following recipes.
Note: At the time this Working Draft is being written (January 2008), an update to the PURL service is in progress. We anticipate this update will address the TAG finding on httpRange-14 and 303 redirects. (see http://www.oclc.org/news/releases/200669.htm ).
Recipe 1a. | Recipe 2a. | Recipe 3a. | Recipe 4a. | Recipe 5a.
This recipe gives an example configuration that satisfies the minimum requirements for a vocabulary with a hash namespace within the http://purl.org/ URI space. Only machine-processable (RDF) content is served at the namespace URI.
For vocabulary …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example1a
defining classes …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example1a#ClassA http://purl.oclc.org/NET/SWD/recipes/examples-A/example1a#ClassB
and properties …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example1a#propA http://purl.oclc.org/NET/SWD/recipes/examples-A/example1a#propB
Create a file called example1a.rdf that contains a complete RDF/XML serialization of the vocabulary. I.e. all resources defined by the vocabulary are described in this file.
Copy example1a.rdf to the directory /apachedocumentroot/examples/ on the server from which you wish to serve the content (in this example the server is www.w3.org).
Set up the following PURL:
PURL: http://purl.org/NET/SWD/recipes/examples-A/example1a URL: http://www.w3.org/2006/07/SWD/recipes/examples/example1a.rdf
If the server is already configured to serve files with the .rdf extension as content type application/rdf+xml then you don't have to do anything further. If this is not the case, you will need to add the following directive:
AddType application/rdf+xml .rdf
either to the main apache configuration files, or if you don't have access to these, to the per-directory configuration file (.htaccess) for the directory /apachedocumentroot/examples/ on the server.
This recipe gives an example configuration that satisfies the minimum requirements for a vocabulary with a slash namespace within the http://purl.org/ URI space. Only machine-processable (RDF) content is served at the namespace URI.
N.B. As of the date of this Working Draft, this example does not strictly conform with the TAG resolution on httpRange-14 [HTTPRANGE14] because the purl.org servers use a 302 redirect code, and not a 303.
For vocabulary …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example2a/
defining classes …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example2a/ClassA http://purl.oclc.org/NET/SWD/recipes/examples-A/example2a/ClassB
and properties …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example2a/propA http://purl.oclc.org/NET/SWD/recipes/examples-A/example2a/propB
Create a file called example2a.rdf that contains a complete RDF/XML serialization of the vocabulary. I.e. all resources defined by the vocabulary are described in this file.
Copy example2a.rdf to the directory /apachedocumentroot/examples/ on the server from which you wish to serve the content (in this example the server is www.w3.org).
Set up the following Partial Redirect PURL:
PR PURL: http://purl.oclc.org/NET/SWD/recipes/examples-A/example2a/ Root URL: http://www.w3.org/2006/07/SWD/recipes/examples/example2a/
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory on the server:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to serve RDF/XML content from all partially redirected URIs RewriteRule ^example2a/ example2a.rdf
(N.B. If a .htaccess file does not exist, create one.)
In the above recipe the single rewrite rule is an internal redirect. This minimizes the number of external (i.e. HTTP) redirects involved in the dereference action. However, you could also implement this rewrite rule as an external redirect, by replacing the above rule with the following:
# Rewrite rule to serve RDF/XML content from all partially redirected URIs RewriteRule ^example2a/ example2a.rdf [R=303]
This creates an additional HTTP redirect in the dereference action, but possibly makes it clearer to the client that attempts to dereference Vocabulary, Class or Property URIs all end up at the same place and it does make the current PURL implementation conformant with the TAG httpRange-14 resolution [HTTPRANGE14].
It is also possible to avoid any server configuration by creating individual PURLs for each class and property of the vocabulary, all referencing the same URL (rather than a Partial Redirect PURL). However, if the content were subsequently to be moved, each PURL would need to be updated -- a cumbersome and impractical task for medium- to large-size ontologies.
This recipe gives an example configuration that satisfies the extended requirements for a vocabulary with a hash namespace within the http://purl.org/ URI space. Both machine-processable (RDF) and human-readable (HTML) content is served at the namespace URI.
For vocabulary …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example3a
defining classes …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example3a#ClassA http://purl.oclc.org/NET/SWD/recipes/examples-A/example3a#ClassB
and properties …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example3a#propA http://purl.oclc.org/NET/SWD/recipes/examples-A/example3a#propB
Create a file called 2005-10-31.rdf that contains a complete RDF/XML serialization of the vocabulary, as at 2005-10-31 (or whatever the current date is). I.e. all resources defined by the vocabulary are described in this file, and this file represents a 'snapshot' or 'version' of the vocabulary.
Create a file called 2005-10-31.html that contains HTML content documentation about all classes and properties defined by the vocabulary as at 2005-10-31 (or whatever the current date is). This document may include sections for each of the classes/properties documented, each section being headed by an HTML anchor whose name is identical to the fragment identifier of the documented class or property.
Copy 2005-10-31.rdf and 2005-10-31.html to the directory /apachedocumentroot/examples/example3a-content/ on the server from which you wish to serve the content (in this example the server is www.w3.org).
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to make sure we serve HTML content from the namespace URI 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 ^example3a$ example3a-content/2005-10-31.html [R=303] # Rewrite rule to make sure we serve the RDF/XML content from the namespace URI by default RewriteRule ^example3a$ example3a-content/2005-10-31.rdf [R=303]
Setup the following PURL:
PURL: http://purl.oclc.org/NET/SWD/recipes/examples-A/example3a URL: http://www.w3.org/2006/07/SWD/recipes/examples/example3a
Because we can't configure the PURL server for content negotiation, this example configures the content server to perform negotiation after the 302 redirect from the PURL server.
This recipe gives an example configuration that satisfies the extended requirements for a vocabulary with a slash namespace within the http://purl.org/ URI space. Both machine-processable (RDF) and human-readable (HTML) content is served at the namespace URI. The HTML documentation is served as a single file.
N.B. this example does not strictly conform with the TAG resolution on httpRange-14 [HTTPRANGE14] because the purl.org servers use a 302 redirect code, and not a 303.
For vocabulary …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example4a/
defining classes …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example4a/ClassA http://purl.oclc.org/NET/SWD/recipes/examples-A/example4a/ClassB
and properties …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example4a/propA http://purl.oclc.org/NET/SWD/recipes/examples-A/example4a/propB
Create a file called 2005-10-31.rdf that contains a complete RDF/XML serialization of the vocabulary, as at 2005-10-31 (or whatever the current date is). I.e. all resources defined by the vocabulary are described in this file, and this file represents a 'snapshot' or 'version' of the vocabulary.
Create a file called 2005-10-31.html that contains HTML content documentation about all classes and properties defined by the vocabulary as at 2005-10-31 (or whatever the current date is). This document may include sections for each of the classes/properties documented, each section being headed by an HTML anchor whose name is identical to the fragment identifier of the documented class or property.
Copy 2005-10-31.rdf and 2005-10-31.html to the directory /apachedocumentroot/examples/example4a-content/ on the server from which you wish to serve the content (in this example the server is www.w3.org)..
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to serve HTML content from the namespace URI 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 ^example4a/$ example4a-content/2005-10-31.html [R=303] # Rewrite rule to serve directed HTML content from class/prop URIs 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 ^example4a/(.+) example4a-content/2005-10-31.html#$1 [R=303,NE] # Rewrite rule to serve RDF/XML content from the namespace URI by default RewriteRule ^example4a/ example4a-content/2005-10-31.rdf [R=303]
(N.B. If a .htaccess file does not exist, create one.)
Set up the following Partial Redirect PURL:
PR PURL: http://purl.oclc.org/NET/SWD/recipes/examples-A/example4a/ URL Root: http://www.w3.org/2006/07/SWD/recipes/examples/example4a/
This configuration would be the most appropriate for Dublin Core Metadata Terms.
This recipe gives an example configuration that satisfies the extended requirements for a vocabulary with a slash namespace within the http://purl.org/ URI space. Both machine-processable (RDF) and human-readable (HTML) content is served at the namespace URI with the HTML documentation being given as multiple hyperlinked HTML documents plus an overview document.
N.B. this example does not strictly conform with the TAG resolution on httpRange-14 [HTTPRANGE14] because the purl.org servers use a 302 redirect code, and not a 303.
For vocabulary …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example5a/
defining classes …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example5a/ClassA http://purl.oclc.org/NET/SWD/recipes/examples-A/example5a/ClassB
and properties …
http://purl.oclc.org/NET/SWD/recipes/examples-A/example5a/propA http://purl.oclc.org/NET/SWD/recipes/examples-A/example5a/propB
Create a file called 2005-10-31.rdf that contains a complete RDF/XML serialization of the vocabulary, as at 2005-10-31 (or whatever the current date is). I.e. all resources defined by the vocabulary are described in this file, and this file represents a 'snapshot' or 'version' of the vocabulary.
Copy 2005-10-31.rdf to the directory /apachedocumentroot/examples/example5a-content/ on the server from which you wish to serve the content (in this example the server is www.w3.org).
Create files ClassA.html ClassB.html propA.html propB.html each of which contains HTML content documentation relevant to the class or property with the corresponding local name, as at 2005-10-31 (or whatever the current date is). Create a file index.html that contains HTML content documentation about the vocabulary itself, with hyperlinks to all class or property documentation.
Copy ClassA.html ClassB.html propA.html propB.html and index.html to the directory /apachedocumentroot/examples/example5a-content/2005-10-31-docs/ on the server from which you wish to serve the content (in this example the server is www.w3.org).
Add the following directives to the .htaccess file in the /apachedocumentroot/examples/ directory:
# Turn off MultiViews Options -MultiViews # Directive to ensure *.rdf files served as appropriate content type, # if not present in main apache config AddType application/rdf+xml .rdf # Rewrite engine setup RewriteEngine On RewriteBase /examples # Rewrite rule to serve HTML content from the namespace URI 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 ^example5a/$ example5a-content/2005-10-31-docs/index.html [R=303] # Rewrite rule to serve HTML content from class or prop URIs 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 ^example5a/(.+) example5a-content/2005-10-31-docs/$1.html [R=303] # Rewrite rule to serve RDF/XML content from the namespace URI by default RewriteRule ^example5a/ example5a-content/2005-10-31.rdf [R=303]
(N.B. If a .htaccess file does not exist, create one.)
Set up the following Partial Redirect PURLs:
PR PURL: http://purl.oclc.org/NET/SWD/recipes/examples-A/example5a/ Root URL: http://www.w3.org/2006/07/SWD/recipes/examples/example5a/
The URI that identifies your vocabulary is referred to here as the vocabulary namespace URI or just vocabulary URI (or ontology URI as vocabulary and ontology are used here interchangeably). For example, the following URI identifies the SKOS Core Vocabulary:
http://www.w3.org/2004/02/skos/core
… and the following URI identifies the FOAF ontology:
http://xmlns.com/foaf/0.1/
SKOS Core [SKOS] is an example of a vocabulary that uses a hash namespace. This is an informal expression which refers to how the URIs for the classes and properties in the vocabulary are constructed. In this case, the URIs for the classes and properties are constructed by appending first a hash character ('#') and then a 'local name' to the vocabulary URI. The 'local name' is a string of characters that uniquely identifies that class or property within the scope of the vocabulary, also known as a 'fragment identifier' [AWWW04] (the local name must be a legal [XML-NS] token NCName).
For example, the following URIs identify a class and a property from the SKOS Core vocabulary:
http://www.w3.org/2004/02/skos/core#Concept http://www.w3.org/2004/02/skos/core#prefLabel
FOAF [FOAF] is an example of a vocabulary that uses a slash namespace. Again, this is an informal expression which refers to the way in which the URIs for the classes and properties defined by the vocabulary are constructed. In this case, the vocabulary URI ends with a forward slash character ('/'), and the URIs of classes and properties are constructed by appending the 'local name' of the class or property directly to the vocabulary URI. Again, the 'local name' is a string of characters that uniquely identifies that class or property within the scope of the vocabulary, and must be a legal [XML-NS] token NCName.
For example, the following URIs identify a class and a property from the FOAF vocabulary:
http://xmlns.com/foaf/0.1/Person http://xmlns.com/foaf/0.1/maker
Note that a vocabulary whose URI ends with a forward slash character doesn't necessarily use a slash namespace. It could use a hash namespace, for example the vocabulary http://example.org/myvocabulary/ could define classes http://example.org/myvocabulary/#Foo and http://example.org/myvocabulary/#Bar.
Both hash namespaces and slash namespaces are supported within the architecture of the Web. However, certain behaviors are required of the Web server that differ between these two choices. Because both the requests received by the server and the responses returned by the server are different in each case, the mechanics of setting up an HTTP server to satisfy some or all of the requirements given below also differ, and hence these two cases are treated separately.
Readers should be aware of a third type of vocabulary URI under discussion at the time of writing: URIs based on a 303-redirect service such as http://thing-described-by.org. Though simpler to implement than approaches described in this document, the 303-redirect approach has not yet been implemented for stable, published RDF vocabularies and is not used in any of the following recipes. Appendix C describes this approach in more detail.
This document is intended for creators and maintainers of existing vocabularies. Proper guidance on choosing the best URI namespace for any given situation is beyond the scope of this document. However, the recipes given here make assumptions and involve trade-offs with respect to functionality, so some considerations relevant to choosing a URI namespace are described in this section. If you have already chosen a URI namespace, skip to the section choosing a recipe.
The URI namespace you choose for your vocabulary should be a Web address (a URI) to which you have write access. Others who use your vocabulary will expect to be able to dereference both the vocabulary URI itself as well as the URIs of properties and classes defined by your vocabulary. The choice of URI namespace is a fundamental decision you make early in the design of your vocabulary.
While RDF permits a namespace name to start with any valid URI scheme, best practice for the Semantic Web is to use a URI scheme that can be resolved by any client without requiring the use of additional plug-ins or client setup configuration. The http URI scheme is the best known of these and is recognized by all Web clients. This document focuses exclusively on vocabularies whose namespace name begins with http:.
Best practice dictates that all RDF vocabularies use either a hash namespace or a slash namespace (see above). Which you choose depends in part on how big you expect your vocabulary to become, how often you expect to add new terms (i.e., properties or classes), and how you expect users to access information about individual terms in your vocabulary.
For small vocabularies, it may be most convenient to serve the entire vocabulary in a single Web access. Such a vocabulary would typically use a hash namespace, and a Web access (i.e., an HTTP GET request) for any term in the vocabulary would return a single information resource describing all of the terms in the vocabulary.
A vocabulary that is large, to which additions are anticipated frequently, or that defines more data than a typical user application will want to access at one time, should be arranged so that progressively greater detail about the terms in the vocabulary may be retrieved through multiple Web accesses. The full description of all of the terms may be divided among many information resources, or may be managed via a query service (e.g. [SPARQL] -- see Recipe 6). Such a vocabulary would typically use a slash namespace, which allows for the possibility that a Web access for any term in the vocabulary may return information principally about just that one term. (Such a configuration is not possible for a vocabulary that uses a hash namespace, because of the mechanics of the HTTP protocol.)
A more detailed discussion of issues related to URI design for the Semantic Web can be found in these documents:
URIs of this type are formed by appending the URI of a descriptive resource as a query string to the base URI of a 303-redirect service such as http://thing-described-by.org. The domain thing-described-by.org delegates authority for defining the meaning of such a query URI to the domain cited in the query string (i.e., the part following a question mark).
In principle, then, one might coin the URI http://thing-described-by.org?http://example.org/foo as an identifier for the Foo vocabulary. An HTTP GET request against the URI for the Foo vocabulary, or against a property or class in the Foo vocabulary, would result in a response code of 303, thus conforming to the second of the two minimum requirements articulated in this document for the publication of RDF vocabularies. If, in addition, the URI http://example.org/foo were to identify an authoritative RDF description for the vocabulary, and the server providing that description were to return a MIME type properly identifying it as such, then the use of http://thing-described-by.org?http://example.org/foo could be said to conform to first of the minimum requirements as well.
An Apache HTTP server [APACHE20] is configured by directives written either inside the main Apache configuration files (usually 'httpd.conf' etc.) or inside per-directory configuration files (usually '.htaccess'). The recipes given here assume that you do not have access to the main Apache configuration files and that you therefore have to use a per-directory configuration using .htaccess files to supply the configuration directives. You may find more specific information about the use of .htaccess files in the Apache Tutorial: .htaccess files.
If you do have write access to the main Apache configuration files, you might consider writing the configuration directives directly there, as using per-directory configuration can negatively affect server performance and requires more careful configuration of directory-level security, see the Apache Tutorial: When (not) to use .htaccess files. It should be noted that AllowOverride is a directory-level directive and its performance and security side-effects don't usually extend beyond the directory trees in which it's enabled.
Note: The configurations given here have been tested on an Apache HTTP server version 2.0.46 only.
In order to support this use of per-directory configuration files, the server must be configured to allow certain overrides for the directories you are using. The required overrides are:
AllowOverride FileInfo Options
In addition, make sure that your version of Apache has been compiled with the mod_rewrite module, or that the mod_rewrite Dynamic Shared Object (DSO) has been installed and the following lines are in the Apache configuration file:
AddModule mod_rewrite.c
LoadModule rewrite_module modules/mod_rewrite.so
If you are having problems getting the recipes to work, it may be because the required override directives are not specified in the main Apache configuration files or mod_rewrite is not available.
To test whether your server will correctly parse a .htaccess file in a given directory, load a URL that accesses a file in the directory you wish to test into a web browser and verify that the file is served correctly. Next create (or edit) a .htaccess file in that directory that contains the line:
InvalidDirective Here
Reload the URL in your web browser. If the server is parsing the .htaccess files in that directory, the server should return an "Internal Server Error" page generated by the unparsable InvalidDirective. If the page redisplays normally, then you need to ask your sysadmin to enable .htaccess files in the directories that you'll be using with the Recipes. When you have confirmed that the server is parsing your .htaccess files, don't forget to remove the InvalidDirective line from the .htaccess file in that directory.
To test whether mod_rewrite is installed, replace the InvalidDirective line from the first test with this:
RewriteEngine On
Reload the URL in your web browser. If mod_rewrite is not installed, or you don't have sufficient override permissions to enable it in .htaccess in that directory, then the server should return an "Internal Server Error" page. The AllowOverride directive must be set to FileInfo (or All) to allow you to enable mod_rewrite in a .htaccess file.
The appropriate content type for serving RDF/XML content is 'application/rdf+xml', as defined in RFC3870. An Apache server can be configured to recognize files with the '.rdf' extension and serve them with the appropriate content type, by adding the following directive to the .htaccess file:
AddType application/rdf+xml .rdf
This directive may also be applied globally at the server level in the server configuration file. In which case it can be safely removed from the recipes.
The example configurations described in this document implement content negotiation by means of rewrite rules (mod_rewrite) to redirect the requests to the most suitable representation. This mechanism is simple and allows great flexibility with respect to the location of the HTML and RDF/XML documents, which may even reside in different servers.
There are some cases in which the provided example configuration does not properly handle content negotiation. In particular, requests with an 'Accept:' header that contains q-values cannot be parsed with rewrite rules, and the server may respond with a representation different from the preferred one. While it is certainly possible to configure an Apache server to handle such requests, this configuration can't be performed within the limitations of .htaccess files. It is beyond the scope of this document to provide a complete server configuration example to handle these requests. Interested readers may wish to refer to content negotiation with type-maps in Apache.