<html>
<head>
<title>&lt;xsl:comment&gt;</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="Beschreibung">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">&lt;xsl:comment&gt;</td>
<td valign="top" class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr>
<td valign="top" colspan="2" class="description">
Diese Anweisung erm&ouml;glicht die Erstellung eines Kommentars im Ausgabedokument. Kommentare werden manchmal verwendet, um juristische Hinweise, Ausschlussklauseln oder Erstellungsinformationen &uuml;ber das Ausgabedokument aufzunehmen. Eine weitere praktische Anwendung des Elements <span class="LITERAL">&lt;xsl:comment&gt;</span> ist die Erzeugung von CSS-Definitionen oder JavaScript-Code in einem HTML-Dokument.</td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Kategorie</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Anweisung</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Obligatorische Attribute</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Keine</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Optionale Attribute</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Keine</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Inhalt</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Eine XSLT-Vorlage</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">&Uuml;bergeordnetes Element</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>
<span class="LITERAL">&lt;xsl:comment&gt;</span> erscheint innerhalb einer Vorlage.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Definition</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XSLT-Abschnitt 7.4, Erzeugung von Kommentaren </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Beispiel</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Es folgt ein Stylesheet, das einen Kommentar f&uuml;r die Definition von CSS-Formaten in einem HTML-Dokument definiert:</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

  &lt;xsl:output method="html"/&gt;

  &lt;xsl:template match="/"&gt;
    &lt;html&gt;
      &lt;head&gt;
        &lt;title&gt;XSLT and CSS Demo&lt;/title&gt;
        &lt;style&gt;
          &lt;xsl:comment&gt; 
            p.big      {font-size: 125%; font-weight: bold} 
            p.green    {color: green; font-weight: bold}
            p.red      {color: red; font-style: italic}
          &lt;/xsl:comment&gt;
        &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
        &lt;xsl:apply-templates select="list/title"/&gt;
        &lt;xsl:apply-templates select="list/listitem"/&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="title"&gt;
    &lt;p class="big"&gt;&lt;xsl:value-of select="."/&gt;&lt;/p&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template match="listitem"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="position() mod 2"&gt;
        &lt;p class="green"&gt;&lt;xsl:value-of select="."/&gt;&lt;/p&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;p class="red"&gt;&lt;xsl:value-of select="."/&gt;&lt;/p&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  
&lt;/xsl:stylesheet&gt;</pre></span>
<p>Dieses Stylesheet erzeugt drei CSS-Formate innerhalb eines HTML-Kommentars.  Das Stylesheet wird auf das folgende Dokument angewendet:</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;list xml:lang="en"&gt;
  &lt;title&gt;Albums I've bought recently:&lt;/title&gt;
  &lt;listitem&gt;The Sacred Art of Dub&lt;/listitem&gt;
  &lt;listitem&gt;Only the Poor Man Feel It&lt;/listitem&gt;
  &lt;listitem&gt;Excitable Boy&lt;/listitem&gt;
  &lt;listitem xml:lang="sw"&gt;Aki Special&lt;/listitem&gt;
  &lt;listitem xml:lang="en-gb"&gt;Combat Rock&lt;/listitem&gt;
  &lt;listitem xml:lang="zu"&gt;Talking Timbuktu&lt;/listitem&gt;
  &lt;listitem xml:lang="jz"&gt;The Birth of the Cool&lt;/listitem&gt;
&lt;/list&gt;</pre></span> <!--<?troff .Nd 10?>-->
<p>Das Stylesheet wendet ein CSS-Format auf das Element <span class="LITERAL">&lt;title&gt;</span> an und wechselt zwischen zwei CSS-Formaten f&uuml;r die Listenelemente (<span class="LITERAL">&lt;listitem&gt;</span>). Hier der erzeugte HTML-Code:</p>
<span class="PROGRAMLISTING"><pre>
&lt;html&gt;
&lt;head&gt;
&lt;META http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
&lt;title&gt;XSLT and CSS Demo&lt;/title&gt;
&lt;style&gt;
&lt;!-- 
            p.big      {font-size: 125%; font-weight: bold} 
            p.green    {color: green; font-weight: bold}
            p.red      {color: red; font-style: italic}
          --&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p class="big"&gt;Albums I've bought recently:&lt;/p&gt;
&lt;p class="green"&gt;The Sacred Art of Dub&lt;/p&gt;
&lt;p class="red"&gt;Only the Poor Man Feel It&lt;/p&gt;
&lt;p class="green"&gt;Excitable Boy&lt;/p&gt;
&lt;p class="red"&gt;Aki Special&lt;/p&gt;
&lt;p class="green"&gt;Combat Rock&lt;/p&gt;
&lt;p class="red"&gt;Talking Timbuktu&lt;/p&gt;
&lt;p class="green"&gt;The Birth of the Cool&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span>
<p>Wie das HTML-Dokument in einem Browser angezeigt wird, sehen Sie in <link linkend="xslt-appa-a6">Abbildung A-6</link>.</p>
<figure label="A-6" id="xslt-appa-a6">
        <p class="TITLE">Dokument mit erzeugten Kommentarknoten</p>
        <graphic depth="323" width="405" fileref="figs/xslt.aa06.gif"/></figure>
</td>
</tr>
</table>
</div>
</body>
</html>
