Description
The functx:pad-string-to-length function returns $stringToPad appended with enough repetitions of $padChar to make its length $length . The function will truncate $stringToPad if its length is greater than $length .
Arguments and Return TypeName | Type | Description |
$stringToPad |
xs:string? |
the string to pad |
$padChar |
xs:string |
the character(s) to use as padding |
$length |
xs:integer |
the desired length |
return value |
xs:string |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:pad-string-to-length" as="xs:string"
xmlns:functx="http://www.functx.com">
<xsl:param name="stringToPad" as="xs:string?"/>
<xsl:param name="padChar" as="xs:string"/>
<xsl:param name="length" as="xs:integer"/>
<xsl:sequence select="
substring(
string-join (
($stringToPad, for $i in (1 to $length) return $padChar)
,'')
,1,$length)
"/>
</xsl:function>
|
ExamplesXPath Example | Results |
---|
functx:pad-string-to-length('abc', '*', 6) |
abc*** |
functx:pad-string-to-length('abcdef', '*', 4) |
abcd |
functx:pad-string-to-length('', '*', 4) |
**** |
See AlsoHistory |
Recommended Reading:
|