|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How can I simulate a replicate-function in xsl: re
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 12:12 AM 3/14/02, Rene de Vries wrote:
>Can you tell me how to simulate a replicate-function in xsl:
>replicate('abc',3) -> 'abcabcabc'
You can't do this as a simple function. You either need an extension
function or recursive named templates.
If you know the string in advance, you could use a substring:
substring('abcabcabcabcabcabcabcabcabcabcabcabcabc',3*3)
But the named template is the most general solution:
<xsl:call-template name="replicate">
<xsl:with-param name="string" select="'abc'"/>
<xsl:with-param name="num" select="3"/>
</xsl:call-template>
<xsl:template name="replicate">
<xsl:param name="string" select="''"/>
<xsl:param name="num" select="1"/>
<xsl:value-of select="$string"/>
<xsl:if test="$num > 1">
<xsl:call-template name="replicate">
<xsl:with-param name="string" select="$string"/>
<xsl:with-param name="num" select="$num - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
~Chris
- --
Christopher R. Maden, Principal Consultant, crism consulting
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4 5DFC AC52 F825 AFEC 58DA
-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.8
iQA/AwUBPJBfZqxS+CWv7FjaEQIxIgCg0B5U381uaVhWXpoW9Nhv8nU5yAwAnReE
t0lncbpsjxhfpuyx9RILvKHj
=yJ/Q
-----END PGP SIGNATURE-----
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








