|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Repeating something "n" times. [via variable]
If you cannot use recursion ( I love it :)) ),
try this stylesheet:
<xsl:stylesheet xmlns:xsl =
"http://www.w3.org/1999/XSL/Transform" version = "1.0"
>
<xsl:template match="/">
<xsl:call-template name="printBR">
<xsl:with-param name="number" select="2"/>
</xsl:call-template>
<xsl:text>===</xsl:text>
<xsl:call-template name="printBR">
<xsl:with-param name="number" select="4"/>
</xsl:call-template>
</xsl:template>
<xsl:template name = "printBR" >
<xsl:param name="number"/>
<xsl:variable name="brSet" >
<xsl:text><![CDATA[<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>]]></xsl:text>
</xsl:variable>
<xsl:value-of disable-output-escaping="yes"
select="substring($brSet,1,$number*4)"/>
</xsl:template>
</xsl:stylesheet>
robert@xxxxxxxxxxxx wrote:
>
> You're kidding me I have to do that? It'll work but is that the way it's
> done in XSL?
>
> This won't work in my case because my template does stuff before it
> outputs the <BR>'s and I don't want it to do that stuff again and I really
> didn't want to have to factor that code into another template because then
> I have to pass a parameter that spans two templates.
>
> On Mon, 6 Nov 2000, Mike Brown wrote:
>
> > robert@xxxxxxxxxxxx wrote:
> > > How do I repeat something 'n' times without a node list with n elements?
> >
> > Put the task in a named template that takes a numeric parameter and, if
> > the parameter is greater than one, calls itself when it's done, passing
> > in the parameter minus one.
> >
> > - Mike
> > ____________________________________________________________________
> > Mike J. Brown, software engineer at My XML/XSL resources:
> > webb.net in Denver, Colorado, USA http://www.skew.org/xml/
> >
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
******************************************
<firstName> Miloslav </firstName>
<surname> Nic </surname>
<mail> nicmila@xxxxxxxxx </mail>
<support> http://www.zvon.org </support>
<zvonMailingList>
http://www.zvon.org/index.php?nav_id=4
</zvonMailingList>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








