Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2007, 06:32 AM
Authorized User
 
Join Date: Feb 2007
Location: CHENNAI, TAMILNADU, India.
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
Reply With Quote
  #2 (permalink)  
Old February 16th, 2007, 08:16 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
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.
Reply With Quote
  #3 (permalink)  
Old February 16th, 2007, 08:35 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
  #4 (permalink)  
Old February 19th, 2007, 12:22 AM
Authorized User
 
Join Date: Feb 2007
Location: CHENNAI, TAMILNADU, India.
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
Reply With Quote
  #5 (permalink)  
Old February 19th, 2007, 04:39 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:57 PM.


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