The string-join() function

Smartsite 7.4 - ...

The string-join() XPath 2.0 function returns a string created by concatenating the items in a sequence, with a defined separator between adjacent items.

XML CopyCode image Copy Code
string fn:string-join(arg1, string arg2)

Parameters:

  • arg1: a sequence of nodes.
  • string arg2: the separator.

Example

XML CopyCode image Copy Code
<html xmlns="http://www.w3.org/1999/xhtml" 
 xmlns:xf="http://www.w3.org/2002/xforms" 
 xmlns:fn="http://www.w3.org/2005/xpath-functions">
 <head>
  <title>Example</title>
  <xf:model>
   <xf:instance>
    <data xmlns="">
     <strings>
      <string index="1">a</string>
      <string index="2">b</string>
      <string index="3">c</string>
      <string index="4">d</string>
      <string index="5">e</string>
     </strings>
    </data>
   </xf:instance>
  </xf:model>
 </head>
 <body>
  <xf:group>
   <xf:output value="fn:string-join(strings/string, '-')" />
   <xf:output value="fn:string-join(strings/string[@index &gt; 3], '-')" />
   <xf:output value="fn:string-join(strings/string[@index &gt; 4], '-')" />
  </xf:group>
 </body>
</html>

The result will be:

a-b-c-d-e
d-e
e

Namespace

This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).