How to set element value dynamically based on for each loop count
- by user1515918
Here is snippet of an xsl file that I am trying to make work. 
I would like to change value for element request-tot-queries in the header based on loop count in the Body. Your help would be greatly appreciated!
<HEADER>
  <request-tot-queries>$Counter</request-tot-queries>
</HEADER>
<Body>
 <xsl:for-each select="//Request/Responses/Pooled/ResidenceHistory/Residencies/Residency">
 <count><xsl:variable name="counter" select="position()"/></count>
  <xsl:if test="DateRange/To/Date[@Type!='Present']">
   <subject-query>
      .
      .
      .
   </subject-query>
  </xsl:if>
 </xsl:for-each>
</Body>