XML-Technologien / DocBook / Konditionale Elemente (Profiling) / Profiling für eigene Attribute nutzen

(Auszug aus "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" von Thomas Schraitle)

Die vordefinierten Profiling-Attribute sollten für die meisten Fälle ausreichen. Haben Sie DocBook jedoch angepasst und neue Attribute hinzugefügt, lassen sich diese ebenso profilieren. Hierzu ein Beispiel:

 

Beispiel: 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>

Möchten Sie alle Elemente erhalten, die in foo den Wert a haben, benötigen Sie die Parameter profile.attribute und profile.value:

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

Sie erhalten:

<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>

Wie erwartet erscheint der Attributwert b nicht in der Ausgabe.

  

nach oben