blob: 564b3422ef301e9c2f61e5559ca13d05d22de47d [file] [log] [blame]
njn15d7c342005-09-30 01:43:32 +00001<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:str="http://www.ora.com/XSLTCookbook/namespaces/strings">
4
5<!-- This file was copied with some adaptations from the examples
6supplied with the XSLT Cookbook by Sal Mangano, (C) 2003 O'Reilly &
7Associates, ISBN 0-596-00372-2. -->
8
9 <xsl:template name="str:dup">
10 <xsl:param name="input"/>
11 <xsl:param name="count" select="1"/>
12
13 <xsl:choose>
14 <xsl:when test="not($count) or not($input)"/>
15 <xsl:when test="$count = 1">
16 <xsl:value-of select="$input"/>
17 </xsl:when>
18 <xsl:otherwise>
19 <!-- If $count is odd append an extra copy of input -->
20 <xsl:if test="$count mod 2">
21 <xsl:value-of select="$input"/>
22 </xsl:if>
23 <!-- Recursively apply template after doubling input and
24 halving count -->
25 <xsl:call-template name="str:dup">
26 <xsl:with-param name="input" select="concat($input,$input)"/>
27 <xsl:with-param name="count" select="floor($count div 2)"/>
28 </xsl:call-template>
29 </xsl:otherwise>
30 </xsl:choose>
31 </xsl:template>
32
33</xsl:stylesheet>