[xsl] Position or Count

Subject: [xsl] Position or Count
From: Kevin_Gutch@xxxxxxxxxxx
Date: Wed, 31 Oct 2001 11:22:31 -0500
I have an xslt(outputting text) that contains the following:

<xsl:for-each select="//layer_params">
               <xsl:variable name="thePosition" select="position()"/>
               <xsl:variable name="theLayerName2">
               <xsl:value-of select
               <xsl:apply-templates select="$states-top" mode="MapTables">
                    <xsl:with-param name="curr-label" select="."/>
                    <xsl:with-param name="theLayerName2" select
                    <xsl:with-param name="thePosition" select

<xsl:template match="//ROWSET" mode="MapTables">
          <xsl:param name="curr-label"/>
          <xsl:param name="theLayerName2"/>
          <xsl:param name="thePosition"/>
          <xsl:variable name="layerExistence2">
          <xsl:value-of select="key('state-lookup',substring-after

          <xsl:if test="$layerExistence2 ='TRUE'">
               <xsl:if test="$thePosition != last()">
                    <xsl:value-of select="$thePosition"/>
               <xsl:if test="$thePosition = last()">
                    <xsl:value-of select="$thePosition"/>

What I am trying to do is print the position number with a comma until it
is the last number which will then only print the number. This has been
easy enough in the past but I have a new wrinkle in my code. With <xsl:if
test="$layerExistence2 ='TRUE'"> only some layers pass the test. So the
result is mass confusion (on my part) for the $Position variable
determining if it is the last element or not. I only want it to use
elements that pass the test to determine position.

 I have tried creating and binding the position variable inside the test
with little luck. Any ideas.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread