<html>
<head>


<title>Fonction lang()</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="Description">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">Fonction lang()</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">
D&eacute;termine si une cha&icirc;ne de langage donn&eacute;e est identique, ou correspond &agrave; un sous-langage, au langage du n&oelig;ud de contexte, comme d&eacute;fini par un attribut <span class="LITERAL">xml:lang</span>.</td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Entr&eacute;es</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Une cha&icirc;ne repr&eacute;sentant un code langage. Si le langage du n&oelig;ud de contexte est de type <span class="LITERAL">xml:lang=&quot;en-us&quot;</span>, invoquer la fonction <span class="LITERAL">lang()</span> pour les diff&eacute;rentes valeurs <span class="LITERAL">en</span>, <span class="LITERAL">EN</span> et <span class="LITERAL">en-us</span> renvoie la valeur bool&eacute;enne <span class="LITERAL">true</span>, alors qu'invoquer la fonction <span class="LITERAL">lang()</span> pour la valeur <span class="LITERAL">en-gb</span> renvoie la valeur bool&eacute;enne <span class="LITERAL">false</span>.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Sortie</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Si la cha&icirc;ne de l'argument est identique, ou correspond &agrave; un sous-langage, au langage du n&oelig;ud de contexte, la fonction <span class="LITERAL">lang()</span> renvoie la valeur bool&eacute;enne <span class="LITERAL">true</span>. Si le n&oelig;ud de contexte ne poss&egrave;de pas d'attribut <span class="LITERAL">xml:lang</span>, la valeur de l'attribut <span class="LITERAL">xml:lang</span> de son anc&ecirc;tre le plus proche est alors utilis&eacute;e &agrave; la place. Si ce type d'attribut n'existe pas, la fonction <span class="LITERAL">lang()</span> renvoie alors la valeur bool&eacute;enne <span class="LITERAL">false</span>. En comparant le code langage du n&oelig;ud de contexte avec la cha&icirc;ne de l'argument, la fonction <span class="LITERAL">lang()</span> ignore la casse.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">D&eacute;finie dans</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XPath section 4.3, Fonctions bool&eacute;ennes.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Exemple</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Le document XML suivant utilise des codes de langage&nbsp;:</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;list xml:lang=&quot;en&quot;&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=&quot;sw&quot;&gt;Aki Special&lt;/listitem&gt;
  &lt;listitem xml:lang=&quot;en-gb&quot;&gt;Combat Rock&lt;/listitem&gt;
  &lt;listitem xml:lang=&quot;zu&quot;&gt;Talking Timbuktu&lt;/listitem&gt;
  &lt;listitem xml:lang=&quot;jz&quot;&gt;The Birth of the Cool&lt;/listitem&gt;
&lt;/list&gt;</pre></span>
<p>La feuille de style suivante utilise la fonction <span class="LITERAL">lang()</span>&nbsp;:</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;

  &lt;xsl:output method=&quot;text&quot;/&gt;

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

  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;xsl:value-of select=&quot;$newline&quot;/&gt;
    &lt;xsl:for-each select=&quot;list/listitem&quot;&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test=&quot;lang('EN')&quot;&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=&quot;.&quot;/&gt;
      &lt;xsl:value-of select=&quot;$newline&quot;/&gt;
    &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>Les r&eacute;sultats sont les suivants&nbsp;:</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>
