The function string-join() joins a sequence of strings provided by the first argument using the second argument as a separator. If the first argument is not a sequence of strings a fatal error is issued. In the example zzz integers are cast to string with "cast as".
|
XSLT
<xsl:stylesheet xmlns:sch="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes=" sch"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/aaa"> <xxx> <xsl:value-of select="string-join(*,' : ')"/> </xxx> <yyy> <xsl:value-of select="string-join((*,'|||',*),'')"/> </yyy> <zzz> <xsl:value-of select="string-join(for $a in (1 to 10) return $a cast as sch:string,'-')"/> </zzz> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa> <bbb>How</bbb> <ccc>do</ccc> <ddd>you</ddd> <eee>do</eee> </aaa> |
Output
<xxx>How : do : you : do</xxx> <yyy>Howdoyoudo|||Howdoyoudo</yyy> <zzz>1-2-3-4-5-6-7-8-9-10</zzz> |
| Previous chapter: | Arithmetics |
| Next chapter: | Transforming strings with regular expressions |
| Previous page: | Joining strings with concat |
| Next page: | Absolute URIs' from relative ones with resolve-uri function |