Introducing XWeb

Creating different versions from the same input

Sometimes it is useful to create multiple versions of the same input files using different layouts. The XWeb website used this to create two complete different looks of the same content for a design poll. A more common usage is to create two or more version of a site which are optimized for a particular browser or audience, e.g. a very fancy version using lots of graphics for people with modern browsers and enough bandwidth who enjoy this kind of websites while offering a low-bandwidth, maybe text-only version for people who prefer simple and fast sites or are not capable to access the other version for whatever reason.

Creating two different websites using the same content can easily be done with XWeb: the basic idea is just to give more than one <layout>. The only additional information you have to give is where to put the different sites, which can be done by adding the attribute outputDir to the <layout> elements. One layout can skip this attribute but we recommend putting all versions into different subdirectories.

This leaves of course the question how to get a start page which is loaded when the site is accessed without using a subdirectory. Typically this is either a page asking the user to choose or redirecting him automatically depending on information collected with JavaScript. You can add such page above all layout directories and existing independent of the layouts by adding the additional <index> element directly into the <website> element. This element is treated in the same manner as a normal <file> element and has the same attributes.

A website offering three different layouts for modern browsers, older browsers and text-based access could look like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <website baseURL="" sourceDir="content" targetDir="output">
    <index sourceFile="index.html" targetFile="index.html" type="copy"/>
      <-- the usual structure -->
    <layout outputDir="css">
      <-- a layout for browser supporting CSS well -->
    <layout outputDir="tables">
      <-- a layout for browser with broken CSS support, using tables instead -->
    <layout outputDir="text">
      <-- a text-only version of the site -->

If we have e.g. a type "xhtml" used in the <structure> part it has to be defined in each of the <layout>s. By giving different XSLT stylesheets and creating different images (or none) the generated sites can look completely different.

One drawback of this approach has to be noted: any url pointing into the site itself will be specific for the layout version chosen, if someone links into the site the link will always point into a specific layout. This can be avoided only by dynamic page generation, if you want to get this you have to use different tools (take a look at the list of related programs on the XWeb site). One approach to reduce this problem is to offer links from one version of the site into the others, keeping the position in the structure. This way links will still point into a specific layout but a visitor can change this easily.