[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Generate N elements


Subject: Re: [xsl] Generate N elements
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Thu, 8 Jul 2004 05:34:42 -0700 (PDT)

Hi Kenny,
  The following recursive stylesheet does this -

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  
<xsl:output method="xml" indent="yes" />
  
<xsl:template match="/Root">
  <Root>
    <xsl:call-template name="generateTag">
      <xsl:with-param name="x" select="data" />
    </xsl:call-template>
  </Root>  
</xsl:template>
  
<xsl:template name="generateTag">
  <xsl:param name="x" />
  <info/>
  <xsl:if test="$x > 1">
    <xsl:call-template name="generateTag">
       <xsl:with-param name="x" select="$x - 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul

--- "Kenny Bogoe (BogoeMD)" <kenny@xxxxxxxxx> 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



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


Current Thread