XML technologies / DocBook / Conditional elements (profiling) / Applying multiple profiling criteria / Multiple profiling attributes, multiple values

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

DocBook allows multiple attributes on an element. A document for several operating systems could therefore include an additional attribute userlevel to distinguish users from administrators. Starting from the example profiling-book-001.xml this information can be included as follows:

 

Example: profiling-book-002.xml

<book>
    <chapter>
        <title>Installation</title>
        <section os="linux" userlevel="user;admin">
            <title>Installationsmedium</title>
            <para>Die Installation unter Linux...</para>
            <para userlevel="admin">Für den Admin ...</para>
        </section>
        <section os="win" userlevel="user;admin">
            <title>Installationsmedium</title>
            <para>Die Installation unter Windows.</para>
            <para userlevel="admin">Weiteres für den Admin.</para>
        </section>
        <section userlevel="user;admin">
            <title>Hilfe</title>
            <section userlevel="admin">
                <title>Einrichten der Hilfe</title>
                <para>Wie man die Hilfe einrichtet.</para>
            </section>
            <section userlevel="user">
                <title>Wo finde ich was?</title>
                <para>...</para>
            </section>
        </section>
    </chapter>
</book>

This document has four variants: user documentation for Linux and Windows, and administrator documentation for Linux and Windows. The matrix below shows the parameters needed to produce each variant:

OS

User

Administrator

Linux

profile.os=linux
profile.userlevel=user

profile.os=linux
profile.userlevel=admin

Windows

profile.os=win
profile.userlevel=user

profile.os=win
profile.userlevel=admin

To produce the Linux user documentation, find the corresponding intersection in the table to obtain the required parameters. The command is therefore:

xsltproc --stringparam profile.os "linux" \
         --stringparam profile.userlevel "user" \
         html/profile-docbook.xsl \
         prof-book-002.xml

This command produces the following file; redundant blank lines have been collapsed:

<?xml version="1.0" ?>
<book>
    <chapter>
        <title>Installation</title>
        <section os="linux" userlevel="user;admin">
            <title>Installationsmedium</title>
            <para>Die Installation unter Linux.</para>
        </section>
        <section userlevel="user;admin">
            <title>Hilfe</title>
            <para>Wie man die Hilfe einrichtet.</para>
            <section userlevel="user">
                <title>Wo finde ich was?</title>
                <para>...</para>
            </section>
        </section>
    </chapter>
</book>

  

back to top