<html>
<head>
<title>&lt;xsl:for-each&gt;</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">&lt;xsl:for-each&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">
XSLT ̔ZqƂċ@\܂B̗vf <span class="LITERAL">select</span> gpāÃ݂ReLXgm[hIł܂B </td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">JeS</td>
</tr>
<tr>
<td colspan="2" class="description">
<p></p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">K{̑</td>
</tr>
<tr>
<td colspan="2" class="description">
<dl>
<dt>
select
</dt>
<dd>
݂̃ReLXgm[hI XPath w肵܂B
<P></p>
</dl>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">ȗ\ȑ</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>ȂB</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Rec</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>
<span class="LITERAL">&lt;xsl:for-each&gt;</span> ɂ́AIem[h]ev[g܂܂܂B<span class="LITERAL">&lt;xsl:for-each&gt;</span> vf 1 ܂͕ <span class="LITERAL">&lt;xsl:sort&gt;</span> vf܂߂āAsOɑIm[hבւ邱Ƃł܂B<span class="LITERAL">&lt;xsl:sort&gt;</span> vf́AKev[g̊JnOɍŏɎw肷Kv܂B </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">w</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>
<span class="LITERAL">&lt;xsl:for-each&gt;</span> ev[gɎw肵܂B</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">`</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XSLT 8 ߁uRepetitionv</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>̃X^CV[g <span class="LITERAL">&lt;xsl:for-each&gt;</span> vf܂B</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;

  &lt;xsl:variable name="newline"&gt;
&lt;xsl:text&gt;
&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:variable name="complicatedVariable"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="count(//listitem) &gt; 10"&gt;
        &lt;xsl:text&gt;really long list&lt;/xsl:text&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:when test="count(//listitem) &gt; 5"&gt;
        &lt;xsl:text&gt;moderately long list&lt;/xsl:text&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:text&gt;fairly short list&lt;/xsl:text&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;Here is a &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$complicatedVariable"/&gt;
    &lt;xsl:text&gt;:&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:variable name="listitems" select="list/listitem"/&gt;
    &lt;xsl:call-template name="processListitems"&gt;
      &lt;xsl:with-param name="items" select="$listitems"/&gt;
    &lt;/xsl:call-template&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template name="processListitems"&gt;
    &lt;xsl:param name="items"/&gt;
    &lt;xsl:for-each select="$items"&gt;
      &lt;xsl:value-of select="position()"/&gt;
      &lt;xsl:text&gt;.  &lt;/xsl:text&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>̃X^CV[gł́A<span class="LITERAL">items</span> ƂO <span class="LITERAL">&lt;xsl:param&gt;</span> ̒lgp <span class="LITERAL">&lt;xsl:for-each&gt;</span> vf܂B<span class="LITERAL">items</span> p[^ɂ́AXML \[XhLg <span class="LITERAL">&lt;listitem&gt;</span> vf܂܂܂B<span class="LITERAL">&lt;xsl:for-each&gt;</span> vfɂÂׂĂ̗vfJԂ܂B XML hLgɑ΂ăX^CV[ggp܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;list&gt;
  &lt;title&gt;A few of my favorite albums&lt;/title&gt;
  &lt;listitem&gt;A Love Supreme&lt;/listitem&gt;
  &lt;listitem&gt;Beat Crazy&lt;/listitem&gt;
  &lt;listitem&gt;Here Come the Warm Jets&lt;/listitem&gt;
  &lt;listitem&gt;Kind of Blue&lt;/listitem&gt;
  &lt;listitem&gt;London Calling&lt;/listitem&gt;
  &lt;listitem&gt;Remain in Light&lt;/listitem&gt;
  &lt;listitem&gt;The Joshua Tree&lt;/listitem&gt;
  &lt;listitem&gt;The Indestructible Beat of Soweto&lt;/listitem&gt;
&lt;/list&gt;</pre></span>
<p>ϊsꍇ̌ʂ͎̂ƂłB</p>
<span class="PROGRAMLISTING"><pre>
Here is a moderately long list:
1.  A Love Supreme
2.  Beat Crazy
3.  Here Come the Warm Jets
4.  Kind of Blue
5.  London Calling
6.  Remain in Light
7.  The Joshua Tree
8.  The Indestructible Beat of Soweto</pre></span>
<p><span class="LITERAL">&lt;xsl:for-each&gt;</span> vfɂAXML \[XhLĝׂĂ <span class="LITERAL">&lt;listitem&gt;</span> vfJԂ܂B </p>
</td>
</tr>
</table>
</div>
</body>
</html>
