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 26th, 2009, 09:54 AM
Authorized User
 
Join Date: Feb 2009
Posts: 43
Thanks: 10
Thanked 0 Times in 0 Posts
Default How to get the value of last 3 nested nodes using xsl:for-each

This gets the first nested nodes using xsl:for-each

Code:
<xsl:for-each select="$dcr[4 > position()]">
                  </xsl:for-each>
I have tried getting the last 3 nested nodes with this...

Code:
<xsl:for-each select="$dcr[4 &lt; position()]">
                  </xsl:for-each>
But it returns ever node.

Please help.
 
Old February 26th, 2009, 09:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your code looks correct (except it's getting all but the first four nodes, not the last three). So the error is in code you haven't shown us. Perhaps $dcr isn't what you think it is. Show a complete but small example.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old February 26th, 2009, 09:58 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Code:
<xsl:for-each select="$dcr[position() &gt; last() - 3]">
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
rabs (February 26th, 2009)
 
Old February 26th, 2009, 10:17 AM
Authorized User
 
Join Date: Feb 2009
Posts: 43
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Thanks Martin. That worked.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the value of first 3 nested nodes using xsl:for-each eruditionist XSLT 5 February 25th, 2009 04:18 PM
XSL multiple files in table (nested for-each ?) pedoublety XSLT 5 August 21st, 2007 08:00 AM
Handling recursive XML Nodes using XSL RichaM XSLT 5 June 21st, 2005 02:45 PM
XSL-help-sum of nodes baed on a condition skumar80 XSLT 2 November 8th, 2003 10:08 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





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