Re: [xsl] Generate N elements

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

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
<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 -->

Kenny Bogoe (BogoeMD) wrote:


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

Source xml:

Result xml:


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