XML technologies / DocBook / Conditional elements (profiling) / Profiling methods / Two-step profiling

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

This method requires two steps to obtain the target format:

  1. profiling: A reduced document is generated from your original document with its profiling attributes. It contains only the required information; the rest is removed during this process. Never edit or correct this file; always modify the original document.

  2. Transformation: The second step is the actual transformation into the target format. The temporary DocBook document generated in the previous step is converted into HTML, XHTML, FO, or another format.

When is this method used?

The following example demonstrates profiling for DocBook 4; the same principles apply to DocBook 5.

 

Example: profiling-book-001.xml

<?xml version="1.0"?>
<book>
    <chapter>
        <title>Installation></title>
        <section os="linux">
            <title>Installationsmedium</title>
            <para>Die Installation unter Linux.</para>
        </section>
        <section os="win">
            <title>Installationsmedium</title>
            <para>Die Installation unter Windows.</para>
        </section>
        <section>
            <title>Hilfe</title>
            <para>Hier steht eine Hilfe.</para>
        </section>
    </chapter>
</book>

The document consists of one chapter and three sections. Two things are required to apply profiling:

  1. The stylesheet profiling/profile.xsl

  2. The profiling parameter with the desired value. For the attribute os this is profile.os.

If you need only the Linux documentation from the original document to create an HTML file, use these two invocations (replace the placeholder DB with the path to your DocBook stylesheets):

  1. Profiling:

xsltproc --output temp.xml \ 
   --stringparam profile.os "linux" \ 
   DB/profiling/profile.xsl \ 
   profiling-book-001.xml

  1. Transformation:

xsltproc --output profiling-book-lin-001.html \ 
   DB/html/docbook.xsl \ 
   temp.xml

The first invocation generates a temporary DocBook document (temp.xml). It contains all elements that have no attribute, or whose os attribute has the value linux. The same applies if you set profile.os to win: the Linux section would then be excluded, leaving only the Windows section.

The second step transforms the temporary DocBook document into an HTML file.

  

back to top