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

Re: FW: Linear counting problem in nested loop

Subject: Re: FW: Linear counting problem in nested loop
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 25 Jan 2004 08:51:10 -0500
nested for loops in xsl
At 2004-01-25 10:29 +0000, Mukul Gandhi wrote:
Please try the following XSL template -

<xsl:template match="/MENU">
  <xsl:for-each select=".//*">
   <xsl:if test="text()">
     <xsl:value-of select="position() div 2"/> for
<xsl:value-of select="text()"/>
   </xsl:if>
  </xsl:for-each>
</xsl:template>

Using position() is dependent on the way the information is processed by your stylesheet, not on where information is found in the source node tree. The above solution produces unwanted reports for interspersed text() nodes.


I supplied and demonstrated two one-line solutions to this problem in the following post:

http://www.biglist.com/lists/xsl-list/archives/200401/msg00884.html

Those solutions involved the count() function and the <xsl:number/> instruction that return results based solely on the source node tree and independent of how the information in the tree is processed.

I hope this helps.

........................ Ken

--
Public courses: sign up for one or both soon to reserve your seat!
Each week:  Monday-Wednesday: XSLT/XPath;  Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15           San Francisco, CA: 2004-03-22
Hong Kong, China: 2004-05-17           Bremen, Germany: 2004-05-24
World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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.