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 February 14th, 2007, 06:32 AM
Authorized User
 
Join Date: Feb 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to SOMANATHAN10
Default Finding the 10th row in a xsl

I am not able to use the position function and predicate the if
condition along with for-each does not work for me.

    <xsl:for-each select="catalog/cd">
     <xsl:if some condition>
     For every 10th time I need to call a template.
   How to identify the every 10th row???


C.SOMA
__________________
C.SOMA
 
Old February 16th, 2007, 08:16 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Sometime I use a variable & MOD:

Code:
 

<xsl:for-each select="catalog/cd">
<xsl:variable name="pos" select="position()"/>
     <xsl:if $pos mod 10 = 1>
.......
This is not tested. let me know how it works out.
 
Old February 16th, 2007, 08:35 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Is this supposed to be a question, or is it some random musings? If you want people to spend time helping you, please say clearly what you are trying to achieve and where your difficulty lies.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old February 19th, 2007, 12:22 AM
Authorized User
 
Join Date: Feb 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to SOMANATHAN10
Default

Mich,

This is my question:I am trying to call header template when an if condition is satisfied. See the following lines in the code snippet.
I am not able to call the header template as the position value is frequently changing.Anyhow I want to identify the every 10th row.This is my requirement.
<xsl:if test position() mod 10 = 1>
<xsl:call-template name="header">
</xsl:if>

code snippet:
===========

 <xsl:for-each select="/job/summary/sunAlertReport/rs:sunAlertReportSummary/rs:sunAlertSummaryList/rs:sunAlertSummary/rs:sunAlertId[generate-id()=generate-id(key(&apos;distinct-segcode&apos;,.))]">
                                    <xsl:sort order="ascending" select="."/>
                                    <xsl:variable name="SA" select="."/>
                                    <xsl:if test="count(/job/summary/sunAlertReport/rs:sunAlertReportSummary/rs:sunAlertSummaryList/rs:sunAlertSummary[rs:sunAlertId=$SA]/rs:oriNext/rs:oriNextList/rs:oriRule[rs:severity = 'Critical']) &gt; 0">
                                    <xsl:if test position() mod 10 = 1>
                                    <xsl:call-template name="header">
                                    </xsl:if>
                                    <xsl:call-template name="saItem">
                                    <xsl:with-param name="hostCount" select="$hostCount"/>
                                    <xsl:with-param name="severity">Critical</xsl:with-param>
                                    </xsl:call-template>
                                    </xsl:if>
                                </xsl:for-each>

C.SOMA
 
Old February 19th, 2007, 04:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Looks like a tough one to crack with XSLT 1.0. Can you use 2.0?

Please try to describe your *requirements", that is, the input and output of the transformation, not the code you are trying to write to solve the requirement. Then we could consider alternative approaches.

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
IDENTIFYING 10TH ROW IN A XSL SOMANATHAN10 XSLT 0 February 13th, 2007 07:04 AM
Dynamically Finding Elements in XSL tclancy XSLT 2 March 1st, 2006 03:25 PM
help in xsl getting row number pandian XSLT 6 January 23rd, 2006 10:00 AM
datagrids question -- finding a specific row bazookajoe76 C# 1 January 22nd, 2005 12:08 PM
Finding the row with the lowest time value Paulsh Access VBA 3 November 16th, 2004 03:06 PM





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