Sample Use-cases: Using XSLT and CSS for PDF Transformations
This section includes examples that can be used as a starting point for various customizations using XSLT and CSS.
How to Use a Bullet Instead of Numbers for Tasks Containing a Single Step
If a DITA Task only contains one step (<step> element), you probably
want it to be rendered like an unordered list (displayed with a bullet instead of a
number).
...
<steps>
<step>
<cmd>The step</cmd>
</step>
</steps>
...
Should be rendered as:
o The stepInstead of:
1. The stepTo achieve this, you need to create an XSLT template that adds a special
@outputclass attribute (with its value set to single) for
the single step, then you need to match this attribute from the CSS and change its
aspect.
-
In the customization XSL, add:
<xsl:template match="*[contains(@class, ' task/step ')][count(../*[contains (@class, ' task/step ')]) = 1]"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="outputclass" select="concat(@outputclass, ' single ')"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
-
In your customization CSS,
add:
*[outputclass ~= "single"] { list-style-type:circle !important; margin-left:2em; }