This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Position or Count



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
="../data_params/data_description_params/properties/property/@value"/>
               </xsl:variable>
               <xsl:apply-templates select="$states-top" mode="MapTables">
                    <xsl:with-param name="curr-label" select="."/>
                    <xsl:with-param name="theLayerName2" select
="$theLayerName2"/>
                    <xsl:with-param name="thePosition" select
="$thePosition"/>
               </xsl:apply-templates>
          </xsl:for-each>



<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
($curr-label/../data_params/data_description_params/properties/property/@value,'

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]