Steven Noels wrote:
On 3/04/2003 8:52 Jeff Turner wrote:

Pity about losing the declarative processing model.


Cannot agree more. Declarative is great SoC.

Get real: what is declarative in


 <xsl:choose>
  <xsl:when test="...">
   <xsl:call-template name="blah">
    <xsl:with-param name="whatever>
     <xsl:for-each select="node()">
      <xsl:value-of select="."/>
     </xsl:for-each>
    </xsl:with-param>
   </xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   ...
  </xsl:otherwise>
 </xsl:choose>

?

Here is the snipped code I had to write a few days ago in order to generate a table of picture thumbnails. Input is something like this

 ...
 <fotografie>
  <foto id="1">whatever</foto>
  <foto id="2">blah</foto>
 </fotografie>
 ...


The stylesheet looks like this:


...

<xsl:template match="fotografie">
<table class="fotografie">
<xsl:call-template name="rowIterator">
<xsl:with-param name="row" select="0"/>
<xsl:with-param name="rows" select="ceiling(count(//foto) div $columns)"/>
</xsl:call-template>
</table>
</xsl:template>


  <!-- iterates over rows -->
  <xsl:template name="rowIterator">
   <xsl:param name="row"/>
   <xsl:param name="rows"/>
   <xsl:if test="$row &lt; $rows">
    <tr valign="top">
     <xsl:call-template name="columnIterator">
      <xsl:with-param name="row" select="$row"/>
      <xsl:with-param name="column" select="0"/>
     </xsl:call-template>
    </tr>
    <xsl:call-template name="rowIterator">
     <xsl:with-param name="rows" select="$rows"/>
     <xsl:with-param name="row" select="$row + 1"/>
    </xsl:call-template>
   </xsl:if>
  </xsl:template>

  <!-- iterates over columns -->
  <xsl:template name="columnIterator">
   <xsl:param name="row"/>
   <xsl:param name="column"/>
   <xsl:variable name="item" select="($row * $columns) + $column + 1"/>
   <xsl:if test="$column &lt; $columns">
    <td align="center" width="{format-number((1 div $columns), '##%')}">
     <xsl:choose>
      <xsl:when test="//foto[$item]">
       <xsl:apply-templates select="//foto[$item]"/>
      </xsl:when>
      <xsl:otherwise>
       <br/>
      </xsl:otherwise>
     </xsl:choose>
    </td>
    <xsl:call-template name="columnIterator">
     <xsl:with-param name="row" select="$row"/>
     <xsl:with-param name="column" select="$column + 1"/>
    </xsl:call-template>
   </xsl:if>
  </xsl:template>

Reply via email to