title: How to get last position in XSLT
body: <p>How can I get last position</p>
  
  <pre><code>&lt;contrib contrib-type="author" corresp="no"&gt;
    &lt;surname&gt;Duan&lt;/surname&gt;
  &lt;/contrib&gt;
  &lt;contrib contrib-type="author" corresp="no"&gt;
    &lt;surname&gt;Ding&lt;/surname&gt;
  &lt;/contrib&gt;
  &lt;contrib contrib-type="author" corresp="no"&gt;
    &lt;surname&gt;Li&lt;/surname&gt;
  &lt;/contrib&gt;
  &lt;contrib contrib-type="author" corresp="no"&gt;
    &lt;surname&gt;Miao&lt;/surname&gt;
  &lt;/contrib&gt;
  </code></pre>
  
  <p>This is the XSL</p>
  
  <pre><code>&lt;xsl:template match="contrib"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="position()=last()"&gt;
        &lt;xsl:apply-templates /&gt;
        &lt;xsl:text&gt; and &lt;/xsl:text&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:apply-templates/&gt;
        &lt;xsl:text&gt;, &lt;/xsl:text&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>I need this Output: Duan, Ding, Li and Miao</p>
  
  <p>Can anyone tell me what's wrong with it? Thanks in advance.</p>