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 October 29th, 2010, 08:28 PM
Registered User
 
Join Date: Oct 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing the first 10 nodes that match criteria

Hi all,

Below is an excerpt from my xml tree. I need to print out the first 10 <article> nodes. But I can't figure out how to count them. position() doesn't work since they appear under different parents. I'm trying to do something like:
for-each folder/article and counter < 10
print contents of article
Code:
<folder>
    <article>
    <article>
</folder>
<folder>
    <article>
</folder>
<folder>
    <article>
    <article>
    <article>
</folder>
<folder>
    <article>
    <article>
</folder>
Any help is appreciated.
 
Old October 30th, 2010, 02:04 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Try the below:
Code:
<xsl:variable name="article">
 <xsl:copy-of select="//article"/>
</xsl:variable>
 
<xsl:template match="root">
<xsl:copy-of select="$article/article[position() &lt; 11/>
</xsl:template>
there can be a better solution than this.
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10, listing 10-10-app kiwibrit BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 2 August 18th, 2009 04:21 AM
Printing nodes as they appear in the XML spidergirl1979 XSLT 4 January 21st, 2008 05:50 AM
template match doesnt match the required node Tomi XSLT 2 March 12th, 2007 06:24 AM
match in a set of nodes dextermagnific XSLT 13 July 11th, 2006 04:26 AM
prompting for criteria before printing civa Access VBA 1 March 26th, 2005 10:50 AM





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