String Split Template

May 26, 2011 at 2:07 PM

I had originally placed this in the string replace thread, but I think it's a bit different and should be it's own.


<xsl:template name="StringSplit">
  <xsl:param name="val" />
    <xsl:when test="contains($val, ';')">   
     <xsl:value-of select="substring-before($val, ';')" />
     <br />     
      <xsl:call-template name="StringSplit">     
       <xsl:with-param name="val" select="substring-after($val, ';')" />     
    <xsl:value-of select="$val" />

<td class="ms-vb">    
  <xsl:call-template name="StringSplit">      
    <xsl:with-param name="val" select="@YourColumn" />

May 26, 2011 at 2:12 PM

It is very similar to the MultiSelectDisplay, it's taking the values of a multiselect field, looking for the specified delimiter, and replacing it with a <br /> tag to put them on their own separate line in the cell. 

May 26, 2011 at 2:21 PM

And now that I look through the discussions, I see it's very similar to  Alex and I must have been reading the same blogs.