title: xslt count following records
body: <p>Using XSLT 1.0, I need to write Count of Txn records that "follow" the SegmentHeader. The number of Txn records I can write under each SegmentHeader is restricted. For example - If I have a total of 5 transaction records with a restriction of 3 per segment, they should be separated into 2 SegmentHeaders, holding 3 and 2 transaction records.</p>
  
  <p>Required Output:</p>
  
  <pre><code>&lt;file&gt;
      &lt;SegmentHeader&gt;
          &lt;TransactionCount&gt;3&lt;/TransactionCount&gt;
      &lt;/SegmentHeader&gt;
      &lt;Txn /&gt;
      &lt;Txn /&gt;
      &lt;Txn /&gt;
      &lt;SegmentHeader&gt;
          &lt;TransactionCount&gt;2&lt;/TransactionCount&gt;
      &lt;/SegmentHeader&gt;
      &lt;Txn /&gt;
      &lt;Txn /&gt;
  &lt;/file&gt;
  </code></pre>
  
  <p>By using "position() mod $recordLimit = 1" I am able to write both SegmentHeaders and Txn records as needed, but could not figure out a way to write the transaction count.</p>