CCR-CCD module (still in development):
[openemr.git] / ccr / ccd / lib / str.padding.template.xsl
blobb98fe504b5cfbc611fec0bf13bf108f04e21a41c
1 <?xml version="1.0"?>
3 <!-- This is a public domain script released from http://exslt.org/ -->
5 <xsl:stylesheet version="1.0"
6 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:str="http://exslt.org/strings"
8 extension-element-prefixes="str">
10 <xsl:template name="str:padding">
11 <xsl:param name="length" select="0" />
12 <xsl:param name="chars" select="' '" />
13 <xsl:choose>
14 <xsl:when test="not($length) or not($chars)" />
15 <xsl:otherwise>
16 <xsl:variable name="string"
17 select="concat($chars, $chars, $chars, $chars, $chars,
18 $chars, $chars, $chars, $chars, $chars)" />
19 <xsl:choose>
20 <xsl:when test="string-length($string) >= $length">
21 <xsl:value-of select="substring($string, 1, $length)" />
22 </xsl:when>
23 <xsl:otherwise>
24 <xsl:call-template name="str:padding">
25 <xsl:with-param name="length" select="$length" />
26 <xsl:with-param name="chars" select="$string" />
27 </xsl:call-template>
28 </xsl:otherwise>
29 </xsl:choose>
30 </xsl:otherwise>
31 </xsl:choose>
32 </xsl:template>
34 </xsl:stylesheet>