XML technologies / DocBook / Conditional elements (profiling) / Profiling for custom attributes

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

The predefined profiling attributes should suffice in most cases. If you have customized DocBook and added new attributes, you can profile those too. Here is an example:

 

Example: profiling-book-003.xml

<book>
    <chapter>
        <title>Installation></title>
        <section os="linux">
            <title>Installationsmedium</title>
            <para>Die Installation unter Linux.</para>
        </section>
        <section>
            <title>Hilfe</title>
            <para foo="a">Hier steht etwas nur für a.</para>
            <para foo="b">Hier steht etwas nur für b.</para>
        </section>
    </chapter>
</book>

To retain all elements whose foo attribute has the value a, you need the parameters profile.attribute and profile.value:

xsltproc --stringparam profile.attribute "foo" \
         --stringparam profile.value "a" \
         profiling/profile.xsl profiling-book-003.xml

The result is:

<book>
    <chapter>
        <title>Installation></title>
        <section os="linux">
            <title>Installationsmedium</title>
            <para>Die Installation unter Linux.</para>
        </section>
        <section>
            <title>Hilfe</title>
            <para foo="a">Hier steht etwas nur für a.</para>
        </section>
    </chapter>
</book>

As expected, the attribute value b does not appear in the output.

  

back to top