Zpracování pomocí iterace

Příklad 3. katalog-jinak.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0">

<xsl:output method="html" encoding="utf-8"/>
  
<xsl:template match="/">
  <html>
    <head>
      <title><xsl:value-of select="/katalog/nazev"/></title>
      <style type="text/css">
        body   { color: black; background-color: white; }
        table  { border: solid 2px black; border-collapse: collapse; }
        th a   { text-decoration: none; color: black; }
        th     { background-color: #FF8000; }
        th, td { border: solid 1px black; }
      </style> 
    </head>
    <body>
      <h1>
        <xsl:value-of select="/katalog/nazev"/>
      </h1>
  
      <table width="100%">
        <tr>
          <th>#</th>
          <th>Název</th>
          <th>Kategorie</th>
          <th>Cena</th>
        </tr>  
        <!-- Postupně zpracujeme všechny položky -->
        <xsl:for-each select="/katalog/polozka">
          <tr>
            <td align="center"><xsl:value-of select="position()"/>.</td>
            <td align="center"><xsl:value-of select="nazev"/></td>
            <td align="center"><xsl:value-of select="kategorie"/></td>
            <td align="right"><xsl:value-of select="cena"/></td>
          </tr>
        </xsl:for-each>
      </table>
    </body>
  </html>    
</xsl:template>

</xsl:stylesheet>