Customization of Element Folding

By default the Serna XSLT processor generates the se:fold extension FO for collapsed elements. This FO is shown as a rectangular widget with a small cross and (optionally) the element name. However, it is often useful to redefine default folding behaviour, so the representation of collapsed element can contain more information (e.g. for folded chapters, we still need chapter name and title). To define custom folding behaviour, stylesheet must define the named template serna.fold.template. Typically this template looks like
 <xsl:template name="serna.fold.template">

   <xsl:apply-templates select="." mode="serna.fold"

              xse:apply-serna-fold-template="false"/>

 </xsl:template>



 <!-- Default rule -->

 <xsl:template match="*" mode="serna.fold">

   <se:fold se:fold=""/>

 </xsl:template>
Note the xse:apply-serna-fold-template="false" attribute for xsl:apply-templates. It prohibits generation of fold templates for the children instances of apply-templates. Without it, Serna will call serna.fold.template recursively and will crash. It is also usually desirable to disable generation of fold templates also in places like tables of contents.

Custom folding templates MUST enclose all generated content into the single fo:block or fo:inline with the se:fold="" extension attribute. Serna determines boundaries of folded blocks by searching for this attribute. If it is not specified, Expand Command won't work.

In custom folding templates extension FO se:fold can be used explicitly, if single-click expand functionality is needed. Note that it also must be wrapped (with other content) as described above.

The se:fold FO can take the optional attribute show-element-name, whose value may be true or false. If show-element-name is false, then element name won't be shown in the se:fold widget.