[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Position or Count

Subject: Position or Count
From: Kevin_Gutch@xxxxxxxxxxx
Date: Wed, 31 Oct 2001 11:22:31 -0500
xsl if test position 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.