+<xsl:template match="illref">
+ <!-- It is important that the class is not checked right in the template - that would make this template match with higher priority, which will turn a few things upside down -->
+ <xsl:if test="@class='html'">
+ <xsl:for-each select="id( @idref )">
+ <!-- This creates unneccessary regeneration of float illustration pages, but it is easiest to keep things this way as long as we have to be backwards compatible... -->
+ <!-- When backwards compatibility can be dropped, most of (all?) the <illustration> processing can happen here -->
+ <xsl:apply-templates select="." />
+ </xsl:for-each>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="illustrations">
+ <ul class="unbulleted">
+ <xsl:for-each select="illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] | illgroup">
+ <xsl:choose>
+ <xsl:when test="self::illustration and @class='float'">
+ <!-- List item with illustration name as link -->
+ <li>
+ <a>
+ <xsl:attribute name="href"><xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="1" /><xsl:text>.htm</xsl:text></xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="$language='es'">
+ <xsl:text>Ilustración </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>Illustration </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) )]" from="/" level="any" format="I" />
+ </a>
+ <!-- List the sections that the illustration appears in -->
+ <xsl:text> (</xsl:text>
+ <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
+ <xsl:call-template name="section-title-link" />
+ <xsl:if test="position()!=last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>)</xsl:text><xsl:value-of select="$newline" />
+ </li>
+ <!-- Call the backwards compatible template for generating the illustration page -->
+ <xsl:call-template name="xhtml-wrapper">
+ <xsl:with-param name="document-type">illustration</xsl:with-param>
+ <xsl:with-param name="filename"><xsl:text>ill</xsl:text><xsl:number count="illustration[@class='float' and contains( $use-illustrators, concat( ':', meta/creator, ':' ) ) ]" from="/" level="any" format="1" /></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="self::illustration"> <!-- inline and map -->
+ <!-- List the sections that the illustration appears in -->
+ <li>
+ <!-- TODO: fix this so that sections that do not represent separate XHTML files are not linked to? -->
+ <xsl:for-each select="//illref[@class='html' and @idref=current()/@id]">
+ <xsl:call-template name="section-title-link" />
+ <xsl:if test="position()!=last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </li>
+ </xsl:when>
+
+ <xsl:when test="self::illgroup and @class!='hidden'">
+ <!-- Check if the group contains any illustrations being used, before creating the list item -->
+ <xsl:if test="count( illustration[contains( $use-illustrators, concat( ':', meta/creator, ':' ) )] ) != 0">
+ <li>
+ <a>
+ <xsl:attribute name="href"><xsl:value-of select="@idref" /><xsl:text>.htm</xsl:text></xsl:attribute>
+ <xsl:value-of select="id(@idref)/meta/title[1]" />
+ </a>
+ </li>
+ </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:for-each>
+ </ul><xsl:value-of select="$newline" />
+</xsl:template>
+