[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Print number of chars depending upon int value
Ranjan K. Baisak wrote:
select="substring('...................................', 1, $myLength)"/> should do the trick! Like most things you'd accomplish with loops in traditional languages, this can be done in XSLT with recursion and named templates. Here's a simple stylesheet that prints 100 dots. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:call-template name="dots"> <xsl:with-param name="count">100</xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="dots"> <xsl:param name="count" select="1"/> <xsl:if test="$count > 0"> <xsl:text>.</xsl:text> <xsl:call-template name="dots"> <xsl:with-param name="count" select="$count -1"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> Obviously if you could call the dots template with the count param set to a value provided by the input document rather than a constant as seen here. -- Elliotte Rusty Harold elharo@xxxxxxxxxxxxxxx XML in a Nutshell 3rd Edition Just Published! http://www.cafeconleche.org/books/xian3/ http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
|
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
|