6. Changing the website

Sooner or later the day will come when someone tells you the website you've created is out of date/behind the times or something similar. Basically you need to start again. By now you've forgotten all the details about building website, how the bits fit together, what tools you need for what part of the process (you do remember your name don't you? Oh good). With that experience in mind this section outlines what is needed to start again. To remove the existing content, re-design the site layout and import an appropriate selection of the old content into a new layout. Firstly then a recap of the basics.

The key files:

In reverse order. Your oddments, those files that you've been given to add to the site for any one of a thousand reasons, the key fact being that they are not generated from XML. Hence the 'static' name. They are not transformed each time the site is built. They do need managing. If you leave them laying around your disk it is likely they will be forgotten over time. Collect them in one place (/static directory?) in a hierarchy such that when they are transferred to the /upload directory, they are all ready to be uploaded to the correct place on the website.

Your xml source files. These are the files from which each HTML page is created by the website build process, using the docbook XSLT stylesheets. Depending on how many you have, it may not be necessary to be too strict with storage. On the other hand, if you have tens or hundreds of files organisation is called for. The layout of your source XML files is intimately tied in with both build.xml and layout.xml . This is perhaps worth spending a few minutes with. My habit is to locate a new website in a common root. Example 7 shows the basic layout of build.xml. One of the optional attributes of the root element is basedir. The 'base directory', this is the location on your disk, from which all other (relative) pathnames are taken. Lets say we have a build file starting with

Example 14. A build.xml example

  <project 
     name="generate"   
     basedir="/sites/xmlsite/"              
     default="help">  

Later in that file, if we want to reference our 'static' directory, we can simply say ${basedir}/static. This makes the static directory relative to the 'root' (base directory) of the site. Being lazy, that means when you want to create your eighteenth site, you simply change the base directory (basedir) and keep the same layout of the various directories! That does make life a lot easier. Back to the issue of lots of source xml files. If the number of XML source files is increasing it is worth sorting them into groups with some common theme. Take each group and move it from the 'root' directory (I'll use the ant property ${basedir} from now on as this 'root' directory for this website), into ${basedir}/group1. group1 should be some name that you will recognise as holding files on a common topic. So on and so forth for all or most of your files. Each time you move a file, you will need to tell the build process where to find these files. layout file Shows an example layout file. Lets say that the files in the preparation area (ing.xml, teapot.xml ....) became numerous. Each line in the layout.xml file will need changing so that the stylesheets will know where to find it. Lets say we create a directory named prep for these. So

  <tocentry dir="prepare" page="prep.xml" filename="prepare.html">   
      <tocentry page="ing.xml" filename="ingredients.html"/>

will become

  <tocentry dir="prepare" page="prep.xml" filename="prepare.html">   
      <tocentry page="prep/ing.xml" filename="ingredients.html"/>

Similarly with each file in this group, move it into the prep directory and update the layout.xml file to reflect this change

Next the layout.xml file. The easy way is to start again, as per Section 3.1, although you will want to keep some files. If you create a nice tidy 'archive' directory somewhere safe, and move all your files into that directory, you can start designing the site again. To step through that process once more.

  1. Start with what you want to appear on the website, a page hierarchy (The layout

  2. Reflect this in the layout.xml file (layout file

  3. Build the xml files needed (or retrieve them from the archive if you decide they are to be kept). Use a template for a new file so that you always use the same ideas for naming etc.

  4. For any files which have others as direct descendents (see proc.xml in layout file), make good use of the <webtoc/> element

The last point is important. The webtoc element is there to help you by generating a local table of contents for those elements 'beneath' the current file. Example 15 shows a use

Example 15. Using the webtoc element

  <webpage navto="yes" id="topic">
<head>
<title></title>
<summary></summary>
  <keywords></keywords>
</head>                        

  <webtoc/>                     1
 
  <section>
    <title></title>
    <para></para>
  </section>
</webpage>

1

The webtoc element in use


The webtoc element serves the purpose of generating automatic links to those files 'beneath' it, in the layout.xml file structure. If you modify layout.xml, then the table of contents will be updated. It is very useful, very flexible and always up to date. This makes a very good partner to the site 'structure' found in layout.xml.

This section is simply a reflection and summary of a new site build. It should be enough to remind users of the key steps in organizing a website.