Ukázka generování výstupu

Příklad 6. katalog-generovani-vystupu.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"/>
        <!-- Vypsání mezery do výstupu, bez xsl:text by byla zrušena -->
        <xsl:text> </xsl:text>
        <xsl:value-of select="current-date()"/>
      </h1>
  
      <table width="100%">
        <tr>
          <th>#</th>
          <th>Název</th>
          <th>Kategorie</th>
          <th>Cena</th>
        </tr>  
        <xsl:for-each select="/katalog/polozka">
          <tr>
            <td align="center"><xsl:value-of select="position()"/>.</td>
            <td align="center">
              <span title="Cena: {cena}">
                <xsl:value-of select="nazev"/>
              </span>
            </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>