[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Generate N elements

Subject: Re: Generate N elements
From: Mike Trotman <mike.trotman@xxxxxxxxxxxxx>
Date: Thu, 08 Jul 2004 14:07:24 +0100
kenneth trotman
Dave Pawsons XSLT FAQ has useful examples of this.

http://www.dpawson.co.uk/xsl/sect2/sect21.html

There are two main approaches:
- Repetiton - using recursive templates
- a neat approach Jeni Tennison pointed out by selecting document nodes in the XSLT stylesheet and using position() to limit the number
This can be used in a for-each loop
e.g.
<xsl:variable name='thisdoc' select='.'/>
<xsl:for-each select='document("")//*[position() &lt;= $num_times]'>
<!-- use $thisdoc if you want to access main document nodes -->
<!-- do whatever you want -->
</xsl:for-each>


Kenny Bogoe (BogoeMD) wrote:

Hi,

This is probably very simple... I need to generate N elements on the fly. N
is a number in my source xml.

Source xml:
<Root>
   <data>4</data>
</Root>

Result xml:

<Root>
   <info/>
   <info/>
   <info/>
   <info/>
</Root>


Thanks,
Kenny Bogoe



-- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ United Kingdom

/
tel :0208-239-6810
mob: 0794-725-9760
email: mike.trotman@xxxxxxxxxxxxx

UK Co. Reg:   4383635
VAT Reg.:   798 7531 60

/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.