SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am relatively new to SP development; I am trying to do the following in SP 2010: I have a list field containing e-mail addresses separated by semicolons. I would like to insert a newline character after every third address or so to improve the appearance of the field content in the list.

I did a little bit of research and I came across SP events but it looks like I should really only be using them for validation and if I want to modify data. The most likely solution I found is XSLT formatting; but I would dread to have to find a way to implement that logic in XSLT, is there a better way to go about this?

Many thanks

share|improve this question
up vote 3 down vote accepted

It of course could be customized on the client side, but customization the Rendering of a Field on a List View using XSLT is preferable option here.


(the method described here represents one of the possible ways how it could be customized with XSLT)

In SharePoint Designer (SPD) open view page in Designer Mode. Select list item in List View that have to be customized and then click Customize Item as shown on picture below
enter image description here

Switch to Code mode and replace generated code for rendering email addresses with the following one:

  <!--xsl:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
     <xsl:call-template name="SplitEmailAddresses">
         <xsl:with-param name="emailAddresses" select="$thisNode/@EmailAddresses" />


a) Generated code for printing field values of email addreses commented out here

b) For rendering field is used SplitEmailAddresses template here, the source code for it is provided below

c) For selecting field value is used query $thisNode/@EmailAddresses, where EmailAddresses correspond to field internal name of email addresses separated by semicolons

 <xsl:template name="SplitEmailAddresses" ddwrt:ghost="">
        <xsl:param name="emailAddresses" select="."/>
        <xsl:param name="separator" select="';'"/>
        <xsl:param name="counterEmail" select="1"/>

        <xsl:if test="($counterEmail mod 4) = 0">

            <xsl:when test="not(contains($emailAddresses, $separator))">
                 <xsl:value-of select="$emailAddresses" disable-output-escaping="yes" />
                <xsl:value-of select="substring-before($emailAddresses, $separator)" disable-output-escaping="yes"/>
                <xsl:call-template name="SplitEmailAddresses">
                    <xsl:with-param name="emailAddresses" select="substring-after($emailAddresses, $separator)"/>
                    <xsl:with-param name="separator" select="';'"/>
                    <xsl:with-param name="counterEmail" select="$counterEmail+ 1"/>

Gist link

After these changes the resulting page should like the shown below enter image description here

share|improve this answer
Wow. The best answer I have received on a StackExchange site. By far. Thank you Sir. – martijn_himself Jan 8 '13 at 11:10
I'm glad I was able to help. – Vadim Gremyachev Jan 8 '13 at 16:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.