Re: [xsl] Print number of chars depending upon int value

Subject: Re: [xsl] Print number of chars depending upon int value
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 22 Apr 2005 12:47:19 +0100
> Should not there be an alternative for any function in
> xslt2.0 in xslt 1.0. 

No, of course not.
What would be the difference between (xslt1 + xslt1 versions of all
xslt2 features) and xslt2.

This is not specific to xslt, for any language, if a new feature is
added in a new version, it's not available in the old one.

> Otherwise it is required to write 100 lines of code as
> mentioned by Eliot Harold.


In this case it's not 100's of lines. Unless your padding needs to be
really long (ie nore characters than there are nodes in your stylesheet)
then you can do

<xsl:for-each select="(document('')//node())[position() &lt;=
$count]">.</xsl:for-each>

if you want to do a fully general recursive loop then something like

<xsl:template name="x">
 <xsl:param name="n"/>
  <xsl:if test="$n!=0">.<xsl:call-template name="x">
     <xsl:with-param name="n" select="$n - 1"/>
     </xsl:call-template>
  </xsl:if>
</xsl:template>

which is 7 lines, 3 of which are just closing open elements so it's
really only 3 lines of code.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread