<html>
<head>
  <title>WebJames - Content negotiation</title>
</head>

<body bgcolor="#ffffff">
<p>
<h3>
<table bgcolor="#cccccc" width="99%"><tr><td>
<a name="contentneg">Content negotiation</a>
</td></tr></table>
</h3>

  It is possible to have a resource (HTML page, image, etc.) in several
 different formats. A browser can supply information on what formats or
 languages are preferable, and WebJames will return the file that best
 matches the browsers preference.
<p>
  The filename requested by the browser should <b>not</b> have an extension
 (ie. <code>page</code>, not <code>page.html</code>). WebJames will then look
 for a type-map file, which has a filename of, for example, <code>page.var</code>.
 The extension that is added can be altered by changing the line <br>
 <code>AddHandler type-map .var</code><br>
 in the attributes file.
 <p>
  The type map is in the same format as <i>Apache</i> uses, and consists of a
 section for each variant of a resource. Each section starts with a line
 <code>URI: page.en.html</code> where page.en.html is the URI of the resource
 relative to the type-map file.
 This is followed by one or more of the following lines
 <ul>
 <li>Content-type: the mime type of the file. Can also include a source quality
 factor and the charset that the resource uses. A quality factor is a number
 between 0 and 1 that indicates the relative 'quality' of the variant. A variant
 with a source quality of 0 will never be returned. If a source quality is not
 specified then it defaults to 1. Examples:<br>
 <code>Content-type: image/jpeg</code><br>
 <code>Content-type: image/png; qs=0.6</code><br>
 <code>Content-type: text/html; charset=iso-8859-2; qs=0.4</code>
 <li>Content-Language: the language the file is written in. Examples:<br>
 <code>Content-language: de</code><br>
 <code>Content-language: en-us</code>
 <li>Content-Encoding: the encoding applied to the file. Encodings are not yet fully
 supported by WebJames. Example:<br>
 <code>Content-encoding: gzip</code>
 <li>Description: a human readable description of the variant. If WebJames cannot find
 a variant that satifies the browser's preferences then it will return a list of all
 possible variants, and will include this description in the list. Example:<br>
 <code>Description: The complete works of Shakespere in Swahilli</code>

</ul>

 There is an example of content negotiation supplied in the <code>Site/content</code>
 directory.
 <a name="multiviews"><h5>MultiViews</h5></a>

  It is possible to use content negotiation without having to create a type map file
 for each page. If you give a page or directory the multiviews attribute, then whenever
 a page is requested that does not have a filename extension, WebJames will scan the
 directory for other files with the same name but with an extension. It will
 effectively create a type-map on-the-fly based on the directory contents, and then proceed
 as with standard content negotiation. Files should be named <code>name.ext</code> or
 <code>name.lang.ext</code>. The ext will be converted to a mime type, and the lang,
 if present, will be used as the language.

<p>
<a href="index.html">Back to contents</a>
<p>
</body>
</html>
