Příklad 2. katalog-sablony.xsl
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <!-- Nastavení výstupní metody a kódování --> <xsl:output method="html" encoding="utf-8"/> <!-- Šablona pro kořenový uzel generuje kostru HTML --> <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>Název</th> <th>Kategorie</th> <th>Cena</th> </tr> <xsl:apply-templates/> </table> </body> </html> </xsl:template> <!-- Šablony pro jednotlivé elementy --> <xsl:template match="polozka"> <tr> <xsl:apply-templates/> </tr> </xsl:template> <xsl:template match="nazev"> <td align="center"><xsl:apply-templates/></td> </xsl:template> <xsl:template match="kategorie"> <td align="center"><xsl:apply-templates/></td> </xsl:template> <xsl:template match="cena"> <td align="right"><xsl:apply-templates/> Kč</td> </xsl:template> <!-- Prázdné šablony pro elementy, které se mají ignorovat --> <xsl:template match="vyrobce"/> <xsl:template match="katalog/nazev"/> </xsl:stylesheet>