Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2006, 04:49 PM
Authorized User
 
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count nodes based of if condition

Hi all

My stylesheet generates a text file.
I want to put dotted lines ----- after every 5 records in the output(text) file.
But, I have a if condition in the for-each loop.
See example, below

xml file
========

<Task due="true">
<Do>Call mother</Do>
</Task>
<Task>
<Do>Make a report</Do>
</Task>

I want to show the Task nodes which contains
attribute due="true", and need to put the dotted lines.after 5 tasks

thx
suri

 
Old December 7th, 2006, 08:00 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You want something like

<xsl:for-each select="Task[@due='true']">
   ....
   <xsl:if test="position() mod 5 = 1">
      <xsl:text>---------------</xsl:text>
   </xsl:if>
</xsl:for-each>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
QUERY EXECUTION based on IF condition drani C# 0 November 9th, 2007 04:14 PM
Pls help - Sorting based on condition kalwinhobbess Crystal Reports 0 September 10th, 2007 10:47 AM
popup based on condition msrnivas General .NET 0 July 11th, 2005 05:52 PM
XSL-help-sum of nodes baed on a condition skumar80 XSLT 2 November 8th, 2003 10:08 AM
count records where condition not true (IIF??) rpeksens Access 3 September 19th, 2003 03:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.