Difficulty: ★☆☆ (easy)
Keywords: chunk, chunking, pi, processing instructions

Problem

You need a method to use the chunking process, but you want to define your own file and directory names for the HTML output.

Solution

The DocBook XSL stylesheets recognize the specific processing instruction (PI) <?dbhtml> for HTML output to influence the chunking process. The PI knows the following pseudo-attributes:

<?dbhtml dir="PATH">

Specifies a directory name in which to write files. It is possible to add a trailing slash or leave it out, the stylesheets know how to deal with both cases.

<?dbhtml filename="FILENAME">

Specifies a file name for a chunk. The value must contain only the file name with an optional extension, but not any directories.

You can combine filename and dir. Insert this processing instruction into your component of your XML file.

Discussion

The <?dbhtml> processing instruction should be inserted after the start tag of the component. Consider the following structure with such PIs:

<book version="5.0" xml:id="book"
    xmlns="http://docbook.org/ns/docbook" xml:lang="en">
    <?dbhtml dir="book"?>
  <title>Chunking Test</title>
  <preface xml:id="preface">
    <?dbhtml dir="pre/"?>
    <!-- ... -->
  </preface>
  <chapter xml:id="intro">
    <?dbhtml dir="intro" filename="index.html"?>
    <!-- ... -->
  </chapter>
  <appendix xml:id="app.overview">
    <?dbhtml dir="app" filename="index.html"?>
    <!-- ... -->
  </appendix>
</book>

When you transform it to HTML with the chunk.xsl stylesheet, you will get the following directory structure:

book/
├── app/
│   ├── ...
│   └── index.html
├── index.html
├── intro/
│   ├── ...
│   └── index.html
└── pre/
    ├── ...
    └── pr01.html

You can combine other chunking parameters as described in Section 5.8, “Controlling the Chunking Process”.

See Also


Project@GitHubIssue#10