I have this piece of code, modified from the DITA-OT original distribution:
<xsl:template match="*[contains(@class, ' topic/topic ')]" mode="in-this-section-chapter-list">
<fo:block margin-left="6em">
<fo:block>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Chapter with number'"/>
<xsl:with-param name="theParameters">
<number>
<fo:inline>
<xsl:apply-templates select="key('map-id', @id)[1]"
mode="topicTitleNumber"/>
</fo:inline>
</number>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:block>
</xsl:template>
I am trying to only execute/print this mini-toc, when this is a Part that has Chapters as child nodes (see below), but not when it is only a Part without any Chapters, in a book like this:
<?xml version="1.0" encoding="utf-8"?>
<bookmap>
<part>
<chapter/>
<chapter/>
<chapter/>
</part>
<part/>
<part/>
<part/>
<part/>
<appendix/>
</bookmap>
So in this case, only the first <part> would execute/print this.
I thought that passing the value from <xsl:apply-templates select="key('map-id', @id)[1]" mode="topicTitleNumber"/> as text, would allow me to add an if that basically will test for a value that is not empty, thus executing this. But it has not worked.
I came up with something like this, which is not valid:
<xsl:template match="*[contains(@class, ' topic/topic ')]" mode="in-this-section-chapter-list">
<xsl:with-param name="value-number">
<xsl:apply-templates select="key('map-id', @id)[1]"
mode="topicTitleNumber"/>
</xsl:with-param>
<xsl:if test="$value-number!=''">
<fo:block margin-left="6em">
<fo:block>
<xsl:call-template name="insertVariable">
<xsl:with-param name="theVariableID" select="'Chapter with number'"/>
<xsl:with-param name="theParameters">
<number>
<fo:inline>
<xsl:apply-templates select="key('map-id', @id)[1]"
mode="topicTitleNumber"/>
</fo:inline>
</number>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:block>
</xsl:if>
</xsl:template>