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:
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.
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?
When the temporary DocBook document is needed elsewhere to generate several target formats. This saves time because profiling need not be repeated for each format. It can be particularly useful for a very large original document using several profiling attributes. This method is advantageous only if you do not profile by target format.
If one-step profiling (discussed shortly) does not support the desired output format, you must process the original document in two steps: profiling first, then another stylesheet.
To test profiling attributes. A separate profiling step lets you validate the result independently of the original document, revealing incorrectly assigned profiling attributes.
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:
The stylesheet
profiling/profile.xslThe profiling parameter with the desired value. For the attribute
osthis isprofile.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):
Profiling:
xsltproc --output temp.xml \
--stringparam profile.os "linux" \
DB/profiling/profile.xsl \
profiling-book-001.xmlTransformation:
xsltproc --output profiling-book-lin-001.html \
DB/html/docbook.xsl \
temp.xmlThe 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.
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
back to top