The string-pad() function
Smartsite 7.2 - ...
The string-pad() extension function returns a new string of the specified length in which either the beginning (pad left) or the end (pad right) of the specified string is padded with the specified character.
XML | Copy Code |
---|---|
string exf:string-pad(arg1, string paddingCharacter, int totalLength, bool padLeft) |
Parameters:
- arg1: a node reference or string literal.
- paddingCharacter: the padding character.
- totalLength: the number of characters in the resulting string.
- padLeft (optional): set to true to enable left padding. Otherwise right padding is applied.
Example
XML | Copy Code |
---|---|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0"> <head> <title>Example</title> <xf:model> <xf:instance> <data xmlns=""> </data> </xf:instance> </xf:model> </head> <body> <xf:group ref="/data" appearance="full"> <xf:label /> <xf:output value="exf:string-pad('1234','0',4,true())" /> <xf:output value="exf:string-pad('1234','0',8,true())" /> <xf:output value="exf:string-pad('hello','.',5)" /> <xf:output value="exf:string-pad('hello','.',10)" /> </xf:group> </body> </html> |
The result will be:
1234
00001234
hello
hello.....
Namespace
This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).