Thanks, Mukul
Just what I needed. Thank you very much.
Kenny
Hi Kenny,
The following modified stylesheet does something
like that -
<?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:with-param name="y" select="10"/>
</xsl:call-template>
</Root>
</xsl:template>
<xsl:template name="generateTag">
<xsl:param name="x"/>
<xsl:param name="y"/>
<info value="{$y}"/>
<xsl:if test="$x > 1">
<xsl:call-template name="generateTag">
<xsl:with-param name="x" select="$x - 1"/>
<xsl:with-param name="y" select="$y + 10"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
--- "Kenny Bogoe (BogoeMD)" <kenny(_at_)bogoe(_dot_)com> wrote:
Thanks, Mukul. Thanks, Mike.
Will it be complicated to get N=4 elements with
different attribute values
in the result tree, like:
<Root>
<info value="10"/>
<info value="20"/>
<info value="30"/>
<info value="40"/>
</Root>
(attribute values are calculated on the fly as well,
like)
Best regards,
Kenny
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(_at_)bogoe(_dot_)com>
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
--+------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
--+------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--