Name
[2.0] string-join()
Given a sequence of strings and a separator string, returns a string containing each string from the sequence, separated by the second string.
Syntax
xs:stringstring-join(xs:string*,xs:string)
Inputs
A sequence of xs:strings
and a string used as a separator.
Outputs
An xs:string that
contains all of the strings in the sequence, separated by the
second argument. If the second string is a zero-length string, the
strings in the sequence are concatenated without a separator. If
the sequence is the empty sequence, string-join() returns a
zero-length string.
Defined in
XQuery 1.0 and XPath 2.0 Functions and Operators section 7.4, Functions on String Values.
Example
Here is a stylesheet that tests the string-join() function:
<?xml version="1.0"?>
<!-- string-join.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
A test of the string-join() function:
</xsl:text> <xsl:variable name="testSequence" as="xs:string*"> <xsl:sequence select="('Brooklyn', 'Manhattan', 'Williamsburg', 'George Washington', 'Tribeca')"/> </xsl:variable> <xsl:text>
 Our sequence of strings:
 </xsl:text> <xsl:value-of select="$testSequence" separator="
 "/> <xsl:text>

 string-join($testSequeqnce, ' - ') = </xsl:text> <xsl:text>
 </xsl:text> <xsl:value-of select="string-join($testSequence, ' - ')"/> <xsl:text>

 Courtesy ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access