Ukázka transformace

Příklad 1. clanek.xsl

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

  <!-- Výstup bude do HTML v kódování utf-8 -->
  <xsl:output indent="yes" method="html" encoding="utf-8"/> 

  <!-- Zpracování celého dokumentu, kořenový element vygeneruje
       kostru HTML dokumentu -->
  <xsl:template match="/">
    <html>
      <head>
        <title><xsl:value-of select="/clanek/zahlavi/autor"/>: 
               <xsl:value-of select="/clanek/zahlavi/nazev"/></title>
        <style type="text/css">
          .zahlavi { text-align: center;
                     border: solid 2px red;
                     background-color: #F0E0E0; 
                     padding: 1em; }
          .rubrika { font-size: xx-small;
                     float: right; }
        </style>
      </head>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="zahlavi">
    <div class="zahlavi">
      <xsl:apply-templates/>
    </div>
  </xsl:template>
  
  <xsl:template match="rubrika">
    <p class="rubrika">
      Rubrika: <b><xsl:apply-templates/></b>
    </p>
  </xsl:template>

  <xsl:template match="nazev">
    <h1 align="center"><xsl:apply-templates/></h1>
  </xsl:template>

  <xsl:template match="autor">
    <p align="center"><i><xsl:apply-templates/></i></p>
  </xsl:template>

  <xsl:template match="perex">
    <p><i><xsl:apply-templates/></i></p>
  </xsl:template>

  <xsl:template match="para">
    <p><xsl:apply-templates/></p>
  </xsl:template>

  <xsl:template match="em">
    <i><xsl:apply-templates/></i>
  </xsl:template>

</xsl:stylesheet>