<html>
<head>
<title>lang()-Funktion</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">lang()-Funktion</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 Funktion bestimmt, ob ein bestimmter Sprach-String in der gleichen Sprache oder Sprachvariante wie der Kontextknoten gehalten ist. Sie richtet sich dabei nach dem Wert des Attributs <span class="LITERAL">xml:lang</span>.</td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Eingaben</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Ein String, der einen Sprachencode repr&auml;sentiert. Hat der Kontextknoten die Sprache <span class="LITERAL">xml:lang="en-us"</span>, so wird durch Aufruf der Funktion <span class="LITERAL">lang()</span> mit einem der Argumentwerte <span class="LITERAL">en</span>, <span class="LITERAL">EN</span> oder <span class="LITERAL">en-us</span> der Boolesche Wert <span class="LITERAL">true</span> zur&uuml;ckgegeben. Wird <span class="LITERAL">lang()</span> hingegen mit dem Wert <span class="LITERAL">en-gb</span> aufgerufen, wird der Boolesche Wert <span class="LITERAL">false</span> zur&uuml;ckgegeben.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Ausgabe</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Hat der Argument-String dieselbe Sprache oder Sprachvariante wie der Kontextknoten, liefert <span class="LITERAL">lang()</span> den Booleschen Wert <span class="LITERAL">true</span>. Besitzt der Kontextknoten kein <span class="LITERAL">xml:lang</span>-Attribut, wird der <span class="LITERAL">xml:lang</span>-Wert des n&auml;chsten Vorfahren verwendet. Wenn es jedoch kein solches Attribut gibt, liefert die Funktion <span class="LITERAL">lang()</span> den Booleschen Wert <span class="LITERAL">false</span>. Beim Vergleichen des Sprachencodes des Kontextknotens mit dem Argument-String wird die Gro&szlig;-/Kleinschreibung von der Funktion <span class="LITERAL">lang()</span> ignoriert.</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>XPath-Abschnitt 4.3, Boolesche Funktionen</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>Hier ein XML-Dokument, das Sprachencodes 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>Hier das Stylesheet, das die Funktion <span class="LITERAL">lang()</span> verwendet:</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="text"/&gt;

<!--<?troff .Nd 10?>-->
  &lt;xsl:variable name="newline"&gt;
&lt;xsl:text&gt;
&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:for-each select="list/listitem"&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="lang('EN')"&gt;
          &lt;xsl:text&gt;Here's an English-language album: &lt;/xsl:text&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:text&gt;-------&gt; Here's some World music: &lt;/xsl:text&gt;
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
      &lt;xsl:value-of select="."/&gt;
      &lt;xsl:value-of select="$newline"/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>Hier schlie&szlig;lich die Ergebnisse:</p>
<span class="PROGRAMLISTING"><pre>

Here's an English-language album: The Sacred Art of Dub
Here's an English-language album: Only the Poor Man Feel It
Here's an English-language album: Excitable Boy
-------&gt; Here's some World music: Aki Special
Here's an English-language album: Combat Rock
-------&gt; Here's some World music: Talking Timbuktu
-------&gt; Here's some World music: The Birth of the Cool
</pre></span>
</td>
</tr>
</table>
</div>
</body>
</html>
