title: Selecting specific entries in a for-each loop?
body: <p>I have the following XSL script:</p>
  
  <pre><code>&lt;xsl:for-each select="$AssignHistory/AssignmentHistory/*[name()=$week]/StudentItems/Item"&gt;
      Student (or assistant): &lt;xsl:value-of select="Name"/&gt;&lt;br /&gt;
  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>The actual XML StudentItems will have a varied number of items in it. Either:</p>
  
  <pre><code>1
  7
  14
  21
  </code></pre>
  
  <p>If there are 7, then I want to show the list content like this:</p>
  
  <pre><code>1
  2 / 3
  4 / 5
  6 / 7
  </code></pre>
  
  <p>If there are 14:</p>
  
  <pre><code>1
  2 / 3
  4 / 5
  6 / 7
  8
  9 / 10
  11 / 12
  13 / 14
  </code></pre>
  
  <p>Finally, if there are 21:</p>
  
  <pre><code>1
  2 / 3
  4 / 5
  6 / 7
  8
  9 / 10
  11 / 12
  13 / 14
  15
  16 / 17
  18 / 19
  20 / 21
  </code></pre>
  
  <p>At the moment I am just getting the varied "list" of names (understandably) but can I do the above? Example XML content:</p>
  
  <pre><code>    &lt;StudentItems&gt;
          &lt;Item&gt;
              &lt;Name Counsel="10"&gt;Matthew 1&lt;/Name&gt;
              &lt;Type&gt;Bible Reading (Main)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="44"&gt;John 2&lt;/Name&gt;
              &lt;Type&gt;#1 Student (Main)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name&gt;Robert 3&lt;/Name&gt;
              &lt;Type&gt;Assistant&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="38"&gt;Rachel 4&lt;/Name&gt;
              &lt;Type&gt;#2 Student (Main)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name&gt;Aimie 5&lt;/Name&gt;
              &lt;Type&gt;Assistant&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="48"&gt;Julie 6&lt;/Name&gt;
              &lt;Type&gt;#3 Student (Main)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name&gt;Diana 7&lt;/Name&gt;
              &lt;Type&gt;Assistant&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="5"&gt;Gordon 8&lt;/Name&gt;
              &lt;Type&gt;Bible Reading (Aux)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="39"&gt;Sadie 9&lt;/Name&gt;
              &lt;Type&gt;#1 Student (Aux)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name&gt;Bethany 1&lt;/Name&gt;
              &lt;Type&gt;Assistant&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="38"&gt;Zoe 2&lt;/Name&gt;
              &lt;Type&gt;#2 Student (Aux)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name&gt;Angela 3&lt;/Name&gt;
              &lt;Type&gt;Assistant&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name Counsel="37"&gt;Mary 4&lt;/Name&gt;
              &lt;Type&gt;#3 Student (Aux)&lt;/Type&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;Name&gt;Kate 5&lt;/Name&gt;
              &lt;Type&gt;Assistant&lt;/Type&gt;
          &lt;/Item&gt;
      &lt;/StudentItems&gt;
  </code></pre>
  
  <p>So where I mentioned a number, I am referring to the <strong>Item/Name</strong> in the list. Thank you for any assistance.</p>