<html>
<head>
<title>count() ֐</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">count() ֐</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">
w肳ꂽm[hZbg̃m[hJEg܂B</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>m[hZbgB</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">o</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>m[hZbgɊ܂܂m[h̐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>XPath 4.1 ߁um[hZbg֐v</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><span class="LITERAL">count()</span> ֐mF邽߂Ɏgp XML hLgɎ܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;test&gt;
  &lt;p&gt;This is a test XML document used by 
  several of our sample stylesheets.&lt;/p&gt;
  &lt;question&gt;
    &lt;text&gt;When completed, the Eiffel Tower was the 
    tallest building in the world.&lt;/text&gt;
    &lt;true&gt;You're correct!  The Eiffel Tower was the 
    world's tallest building until 1930.&lt;/true&gt;
    &lt;false&gt;No, the Eiffel Tower was the world's 
    tallest building for over 30 years.&lt;/false&gt;
  &lt;/question&gt;
  &lt;question&gt;
    &lt;text&gt;New York's Empire State Building knocked 
    the Eiffel Tower from its pedestal.&lt;/text&gt;
    &lt;true&gt;No, that's not correct.&lt;/true&gt;
    &lt;false&gt;Correct!  New York's Chrysler Building, 
    completed in 1930, became the world's tallest.&lt;/false&gt;
  &lt;/question&gt;
&lt;/test&gt;</pre></span>
<p><span class="LITERAL">count()</span> ֐gpX^CV[gɎ܂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:template match="/"&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;Tests of the count() function:&lt;/xsl:text&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   count(/test)=&lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(/test)"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   count(/true)=&lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(/true)"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   count(//true)=&lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(//true)"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   count(//test|//true|//text)=&lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(//test|//true|//text)"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:variable name="numberOfQuestions" select="count(/test/question)"/&gt;
    &lt;xsl:for-each select="/test/question"&gt;
      &lt;xsl:text&gt;   This is question number &lt;/xsl:text&gt;
      &lt;xsl:value-of select="position()"/&gt;
      &lt;xsl:text&gt; of &lt;/xsl:text&gt;
      &lt;xsl:value-of select="$numberOfQuestions"/&gt;
<!--<?troff .Nd 10?>-->
      &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̌ʂ͎̂ƂłB</p>
<span class="PROGRAMLISTING"><pre>

Tests of the count() function:

   count(/test)=1
   count(/true)=0
   count(//true)=2
   count(//test|//true|//text)=5
   This is question number 1 of 2
   This is question number 2 of 2
</pre></span>
<p><span class="LITERAL">count()</span> ֐̍ŏ 4 ̌Ăяoł́AP XPath gp XML hLg̗vfJEg܂B<span class="LITERAL">count()</span> ̍Ō̌Ăяoł́AhLg <span class="LITERAL">&lt;question&gt;</span> vf̐JEgA̒lϐɊi[܂B<quote> x / y</quote> ̂悤ȃeLXg͈̐ʓIȋZ@łA<span class="LITERAL">count()</span>  <span class="LITERAL">position()</span> ̎gpł́A̐ǂ̂悤ɈʓIɍsĂ܂B</p>
</td>
</tr>
</table>
</div>
</body>
</html>
