<html>
<head>
<title>&lt;xsl:message&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:message&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 dient zum Senden einer Nachricht. Wie die Nachricht versendet wird, kann f&uuml;r verschiedene XSLT-Prozessoren variieren, typischerweise wird sie aber an das Standardausgabeger&auml;t gesendet. Dieses Element eignet sich f&uuml;r die Fehlersuche in Stylesheets.</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">
<dl>
<dt>
terminate= &quot; yes &quot; | &quot; no &quot;
</dt>
<dd>
Besitzt dieses Attribut den Wert <span class="LITERAL">
yes
</span>, so bricht der XSLT-Prozessor nach der Ausgabe dieser Nachricht die Ausf&uuml;hrung ab. Der Standardwert f&uuml;r dieses Attribut ist <span class="LITERAL">
no
</span>. Wenn <span class="LITERAL">
&lt;
xsl:message
&gt;
</span> den Prozessor nicht beendet, wird die Nachricht gesendet und die Verarbeitung fortgesetzt.
<P></p>
</dl>
</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:message&gt;</span> erscheint innerhalb einer Template. </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 13, Nachrichten</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>Das nachfolgende Stylesheet verwendet das Element <span class="LITERAL">&lt;xsl:message&gt;</span>, um die Umwandlung eines XML-Dokuments nachzuverfolgen. Es wird wieder die Liste der in letzter Zeit gekauften Alben verwendet:</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>
<p>Alle gekauften Alben werden in einer HTML-Tabelle aufgelistet, wobei die einzelnen Zeilen alternierende Hintergrundfarben erhalten. Das Stylesheet verwendet ein <span class="LITERAL">&lt;xsl:choose&gt;</span>-Element innerhalb eines <span class="LITERAL">&lt;xsl:attribute&gt;</span>-Elements, um den Wert des Attributs <span class="LITERAL">bgcolor</span> zu bestimmen. Wird ein bestimmtes <span class="LITERAL">&lt;listitem&gt;</span> in ein HTML-<span class="LITERAL">&lt;tr&gt;</span> mit der Hintergrundfarbe <span class="LITERAL">lavender</span> konvertiert, wird eine Gl&uuml;ckwunschnachricht ausgegeben:</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;
          &lt;xsl:value-of select="list/title"/&gt;
        &lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
        &lt;h1&gt;&lt;xsl:value-of select="list/title"/&gt;&lt;/h1&gt;
        &lt;table border="1"&gt;
          &lt;xsl:for-each select="list/listitem"&gt;
            &lt;tr&gt;
              &lt;td&gt;
                &lt;xsl:attribute name="bgcolor"&gt;
                  &lt;xsl:choose&gt;
                    &lt;xsl:when test="position() mod 4 = 0"&gt;
                      &lt;xsl:text&gt;papayawhip&lt;/xsl:text&gt;
                    &lt;/xsl:when&gt;
                    &lt;xsl:when test="position() mod 4 = 1"&gt;
                      &lt;xsl:text&gt;mintcream&lt;/xsl:text&gt;
                    &lt;/xsl:when&gt;
                    &lt;xsl:when test="position() mod 4 = 2"&gt;
                      &lt;xsl:text&gt;lavender&lt;/xsl:text&gt;
                      &lt;xsl:message terminate="no"&gt;
                        &lt;xsl:text&gt;Table row #&lt;/xsl:text&gt;
                        &lt;xsl:value-of select="position()"/&gt;
                        &lt;xsl:text&gt; is lavender!&lt;/xsl:text&gt;
                      &lt;/xsl:message&gt;
                    &lt;/xsl:when&gt;
                    &lt;xsl:otherwise&gt;
                      &lt;xsl:text&gt;whitesmoke&lt;/xsl:text&gt;
                    &lt;/xsl:otherwise&gt;
                  &lt;/xsl:choose&gt;
                &lt;/xsl:attribute&gt;
                &lt;xsl:value-of select="."/&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
          &lt;/xsl:for-each&gt;
        &lt;/table&gt;
      &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>Beachten Sie, dass die XSLT-Spezifikation nicht festlegt, wie die Nachricht ausgegeben wird. Wenn Sie dieses Stylesheet mit Xalan 2.0.1 verwenden, erhalten Sie die folgenden Ergebnisse:</p>
<span class="PROGRAMLISTING"><pre>
file:///D:/O'Reilly/XSLT/bookSamples/AppendixA/message.xsl; Line 32; Column 51;
Table row #2 is lavender!
file:///D:/O'Reilly/XSLT/bookSamples/AppendixA/message.xsl; Line 32; Column 51;
Table row #6 is lavender!</pre></span> <!--<?troff .Nd 10?>-->
<p>Xalan gibt Feedback zu dem Stylesheet, das die jeweilige Nachricht erzeugt hat. Saxon gibt sich kurz und freundlich.</p>
<span class="PROGRAMLISTING"><pre>
Table row #2 is lavender!
Table row #6 is lavender!</pre></span>
<p>Zur Abwechslung soll hier angef&uuml;hrt werden, wie XT das Element <span class="LITERAL">&lt;xsl:message&gt;</span> verarbeitet:</p>
<span class="PROGRAMLISTING"><pre>
file:/D:/O'Reilly/XSLT/bookSamples/AppendixA/test4.xml:5: Table row #2 is lavender!
file:/D:/O'Reilly/XSLT/bookSamples/AppendixA/test4.xml:9: Table row #6 is lavender!</pre></span>
<p>XT gibt Informationen &uuml;ber die Zeile im XML-Ausgangsdokument, die die Meldung erzeugt hat.</p>
</td>
</tr>
</table>
</div>
</body>
</html>
