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

  <xsl:template match="rezept">
    <html>
      <head>
        <title><xsl:value-of select="titel" /></title>
        <link rel="stylesheet" href="default.css" />
      </head>
      <body>
        <h1><xsl:value-of select="titel" /></h1>
        <xsl:apply-templates select="zutaten" />
        <h2>Zubereitung</h2>
        <ul>
          <xsl:for-each select="zubereitung">
            <li><xsl:value-of select="." /></li>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="zutaten">
    <p>
      <h2>Zutaten</h2>
      <xsl:element name="a">
        <xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute>
        <xsl:attribute name="target">_blank</xsl:attribute>
        <xsl:value-of select="title" />
      </xsl:element>
      <xsl:apply-templates select="zutat" />
    </p>
  </xsl:template>

  <xsl:template match="zutat">
    <xsl:value-of select="@menge" />
    <xsl:text> </xsl:text>
    <xsl:choose>
      <xsl:when test="@link">
        <xsl:element name="a">
          <xsl:attribute name="href">
            <xsl:value-of select="@link" />
          </xsl:attribute>
          <xsl:value-of select="." />
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="." />
      </xsl:otherwise>
    </xsl:choose>
    <br>
  </xsl:template>

</xsl:stylesheet>

