title: count the number of elements in an XSL for-each loop?
body: <p>I have been trying for the past day to figure out how to count the number of elements in an XSL for-each loop.  I have tried doing it with javascript but can't seem to get it to work.  I'm not sure if it's just a matter of not displaying the output correctly or if you can even do this with XSLT.  Any help would be appreciated.  This is a nasty bug that I was not prepared for. </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var colATotal=0;
  
  function loopCounterA(){
    colATotal++;
  }
  
  function printA(){
     document.write(colATotal);
  }
  &lt;/script&gt;
  
  &lt;xsl:for-each select='bookmarks/category'&gt;
  &lt;xsl:for-each select='./bookmark'&gt;
  
  &lt;script type="text/javascript"&gt;
  loopCounterA(); 
  printA();
  &lt;/script&gt;
  
  &lt;/xsl:for-each&gt;
  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p><strong>From comments:</strong></p>
  
  <blockquote>
    <p>I figured showing all the code may be
    a waste of time. I have a div columnA
    and a div columnB, both of which are
    vertical columns. My boss wants all of
    the bookmarks to wrap, but i can't
    start the wrap in the middle of a
    category block. My intention is to
    keep track of 3 variables to do this:
    total bookmarks in columnA so far (A),
    total bookmarks in columnB so far (B),
    and the number of bookmarks in the
    next category block to be placed (C).
    if B + C is greater than A, I will
    place the block into columnA and I'll
    place it into columnB otherwise. Does
    this make more sense now? Thx so much.</p>
  </blockquote>