I am traversing an XML file (that contains multiple tables) using XSLT. Part of the job of the page is to get the title of each table, and present that title with along with the number of items that table contains (i.e. "Problems (5)").
I am able to get the number of items, but I now need to separate the sections with 0 (zero) items in them, and put them at the bottom of the list of table titles. I'm having trouble with this because the other items with positive numbers need to be left in their original order/not sorted.
Here is the code for the list of titles:
<ul>
<xsl:for-each select="n1:component/n1:structuredBody/n1:component/n1:section/n1:title">
<li style="list-style-type:none;">
<div style = "padding:3px"><a href="#{generate-id(.)}">
<xsl:variable name ="count" select ="count(../n1:entry)"/>
<xsl:choose>
<xsl:when test = "$count != 0">
<xsl:value-of select="."/> (<xsl:value-of select="$count"/>)
</xsl:when>
<xsl:otherwise>
<div id = "zero"><xsl:value-of select="."/> (<xsl:value-of select="$count"/>)</div>
</xsl:otherwise>
</xsl:choose>
</a>
</div>
</li>
</xsl:for-each>
</ul>
Right now, the "zero" div just marks each link as gray.
Any help regarding how to place the "zero" divs at the bottom of the list would be greatly appreciated. Thank you!
Edited code using zero/nonzero templates:
<xsl:for-each select="n1:component/n1:structuredBody/n1:component/n1:section/n1:title">
<li style="list-style-type:none;">
<div style = "padding:3px"><a href="#{generate-id(.)}">
<xsl:apply-templates select="n1:title[count(../n1:entry) != 0]" mode="nonzero" />
<xsl:apply-templates select="n1:title[count(../n1:entry) == 0]" mode="zero" />
</a>
</div>
</li>
</xsl:for-each>