XML technologies / DocBook / Generating (X)HTML / Generating linked chunks / Specifying filenames
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
There are three ways to name chunk files:
automatically, the default behavior of the DocBook stylesheets
using an
idattribute on the corresponding chunk elementusing a processing instruction
Generating filenames automatically
An automatically generated name consists of an abbreviation with a sequential number; these may recur. For example, the third section of the fifth chapter would produce the filename ch05s03.html. The following table summarizes the abbreviations.
Table: Chunk element abbreviations
Abbreviation | Element name | Abbreviation | Element name |
ap | | ar | |
bi | | bk | |
ch | | co | |
go | | ix | |
ln | | pt | |
pr | | re | |
rh | | rn | |
s | | si | |
a Only in a book.
b Only in a set.
c Only if the parameter generate.legalnotice.link has the value 1.
d Only if the parameter generate.revhistory.link has the value 1.
Transforming a DocBook document produces output similar to the following:
Writing ch01s02.html for section(sec.xmlintro.xml10)
Writing ch01s03.html for section(sec.xmlintro.whatisxml)
Writing ch01s04.html for section(sec.xmlintro.parser)
Writing ch01s05.html for section
The output shows the name of the corresponding element and, if present, the id value in parentheses. To suppress this output, set the parameter chunk.quietly to 1.
Although this naming scheme is plausible, it becomes unstable when the document is edited: adding or deleting structural elements inevitably disrupts the numbering. This method therefore poses a potential risk when frequently modified documents are published on the web and linked to. Prefer one of the following two methods.
Generating filenames from the id attribute
If a structural element has the attribute id or xml:id, the filename can be generated from it:
DocBook 4: <chapter id="XML-Intro"
DocBook 5: <chapter xml:id="XML-Intro">
Set the parameter use.id.as.filename to 1 to enable this naming scheme:
xsltproc --param use.id.as.filename 1 ...The transformation outputs:
Writing XML-Intro.html for chapter(XML-Intro)
The contents of the chapter element are written to the file XML-Intro.html. This works for all chunk elements in the table Chunk elements that generate a new file, except the root element. By default, the root element, regardless of its name, always uses index.html, unless the parameter root.filename is set to a different value.
Even the filename extension can be changed. Use the parameter html.ext; the default is .html.
Filenames using a processing instruction
If ID values are inconsistent or contain unusual characters, it is advisable not to use them as filenames. In this case, insert a processing instruction:
<chapter>
<?dbhtml filename="XML-Intro.html"?>
<title>Einführung in XML</title> ...The processing instruction <?dbhtml?> has the keyword filename, which contains the (X)HTML filename. Note that the stylesheet leaves the name unchanged: it appends no additional suffixes or similar additions to the filename. Also ensure that the processing instruction occurs inside the chunk element being named. For a chapter, insert it after chapter; for an appendix, after appendix and so on.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de