XML technologies / DocBook / Generating (X)HTML / Generating linked chunks / Setting the output directory

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

By default, the stylesheets write output to the current directory. To write files elsewhere, use:

  1. the parameter base.dir,

  2. the processing instructions <?dbhtml filename="..."?> and <?dbhtml dir="..."?> directly in the DocBook document,

  3. a combination of both.

Set the parameter base.dir to the output directory:

xsltproc --stringparam base.dir /irgendwo/hin/ ... 

On Linux and MacOS, ensure the directory always ends with a slash, or with a backslash on Windows. Otherwise, the filenames contain the supplied value as a prefix.

The second method uses the processing instruction <?dbhtml?>, allowing a more structured directory layout:

<book>
  <?dbhtml dir="docbook"?>
  <title>DocBook</title>
...
  <chapter id="xml-intro">
     <?dbhtml dir="xml"?>
     <?dbhtml filename="index.html"?>
  ...
  <chapter id="xslt-intro">
     <?dbhtml dir="xsl"?>
  ...     
</book>

This code generates the following file structure:

docbook
|
+ index.html
|
+- xml
| |
| +- index.html
|
+- xsl
   |
   +- ch02.html

All children of the first chapter element go into the directory docbook/xml. If you also use the parameter use.id.as.filename, filenames are based on their ID attributes.

The third method combines the first two, so no further example is needed.

  

back to top