home contribute faq download

FunctX XQuery Functions

functx:repeat-string

Repeats a string a given number of times

Google
Webxqueryfunctions.com

Description

The functx:repeat-string function returns a string consisting of a given number of copies of $stringToRepeat concatenated together. To pad a string to a particular length, use the functx:pad-string-to-length function.

Arguments and Return Type

NameTypeDescription
$stringToRepeat xs:string? the string to repeat
$count xs:integer the desired number of copies
return value xs:string

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:repeat-string
  ( $stringToRepeat as xs:string? ,
    $count as xs:integer )  as xs:string {

   string-join((for $i in 1 to $count return $stringToRepeat),
                        '')
 } ;

Examples

XQuery ExampleResults
functx:repeat-string('*', 6)
******
functx:repeat-string('abc', 3)
abcabcabc

See Also

functx:pad-string-to-lengthPads a string to a desired length
functx:pad-integer-to-lengthPads an integer to a desired length by adding leading zeros

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley