source: ccr2ccd-xslt/trunk/lib/str.padding.template.xsl@ 748

Last change on this file since 748 was 748, checked in by Richard Braman, 14 years ago

ainitial file from Ken Miller / first pass at coding problems into Level 3 CCD

File size: 1.2 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:str="http://exslt.org/strings"
5 extension-element-prefixes="str">
6
7<xsl:template name="str:padding">
8 <xsl:param name="length" select="0" />
9 <xsl:param name="chars" select="' '" />
10 <xsl:choose>
11 <xsl:when test="not($length) or not($chars)" />
12 <xsl:otherwise>
13 <xsl:variable name="string"
14 select="concat($chars, $chars, $chars, $chars, $chars,
15 $chars, $chars, $chars, $chars, $chars)" />
16 <xsl:choose>
17 <xsl:when test="string-length($string) >= $length">
18 <xsl:value-of select="substring($string, 1, $length)" />
19 </xsl:when>
20 <xsl:otherwise>
21 <xsl:call-template name="str:padding">
22 <xsl:with-param name="length" select="$length" />
23 <xsl:with-param name="chars" select="$string" />
24 </xsl:call-template>
25 </xsl:otherwise>
26 </xsl:choose>
27 </xsl:otherwise>
28 </xsl:choose>
29</xsl:template>
30
31</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.