<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>What&#039;s The (Share)Point? &#187; functions</title>
	<atom:link href="http://whatsthesharepoint.com/tag/functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://whatsthesharepoint.com</link>
	<description>Another resource for MS SharePoint information.</description>
	<lastBuildDate>Tue, 13 Dec 2011 16:21:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>XSL:split-string function</title>
		<link>http://whatsthesharepoint.com/2010/02/xslsplit-string-function/</link>
		<comments>http://whatsthesharepoint.com/2010/02/xslsplit-string-function/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 21:59:35 +0000</pubDate>
		<dc:creator>David Petersen</dc:creator>
				<category><![CDATA[problems]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[display form]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsl]]></category>

		<guid isPermaLink="false">http://whatsthesharepoint.com/?p=158</guid>
		<description><![CDATA[One of the reasons I like developing for SharePoint is that I get to work with many different technologies and platforms.  When I am designing a custom list for (display, edit or new), There are times where I may have a delimited string in a field that I want to display differently on the screen. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the reasons I like developing for SharePoint is that I get to work with many different technologies and platforms.  When I am designing a custom list for (display, edit or new), There are times where I may have a delimited string in a field that I want to display differently on the screen.  Since the forms are all XSL style sheets, it is helpful to have a few XSL templates to process the data.</p>
<p>I wrote this XSL template so I could wrap some HTML around any element in a delimited list.  This is specifically geared towards XSL 1.0.  In XSL 2.0, I would most likely use <em>tokenize</em>.  I&#8217;m not an expert at XSL so if anyone has any suggestions that would improve this template, please leave comments.</p>
<pre language="XML">&lt;xsl:template name="split-string"&gt;
&lt;xsl:param name="list" /&gt;
&lt;xsl:param name="delimiter" /&gt;
&lt;xsl:param name="id" /&gt;
&lt;xsl:if test="normalize-space($list)"&gt;
&lt;xsl:variable name="newlist"&gt;
&lt;xsl:choose&gt;
&lt;xsl:when test="contains($list, $delimiter)"&gt;
&lt;xsl:value-of select="normalize-space($list)" /&gt;
&lt;/xsl:when&gt;
&lt;xsl:otherwise&gt;
&lt;xsl:value-of select="concat(normalize-space($list), $delimiter)"/&gt;
&lt;/xsl:otherwise&gt;
&lt;/xsl:choose&gt;
&lt;/xsl:variable&gt;

&lt;xsl:variable name="first" select="substring-before($newlist, $delimiter)" /&gt;
&lt;xsl:variable name="remaining" select="substring-after($newlist, $delimiter)" /&gt;
&lt;!-- This is where you need to put the display code --&gt;
&lt;a&gt;
&lt;xsl:attribute name="href"&gt;./Attachments/&lt;xsl:value-of select="$id" /&gt;/&lt;xsl:value-of select="$first" /&gt;&lt;/xsl:attribute&gt;
&lt;xsl:attribute name="target"&gt;_blank&lt;/xsl:attribute&gt;
&lt;img src="~/_layouts/images/doclink.gif" width="16" height="16" alt="" border="0" /&gt;
&lt;xsl:value-of select="$first" /&gt;
&lt;/a&gt;
&lt;!--  end display code --&gt;
&lt;xsl:if test="$remaining"&gt;
&lt;!-- I put a little display code here also --&gt;
&lt;br /&gt;
&lt;!-- end display code --&gt;
&lt;xsl:call-template name="split-string"&gt;
&lt;xsl:with-param name="list" select="$remaining" /&gt;
&lt;xsl:with-param name="delimiter"&gt;
&lt;xsl:value-of select="$delimiter"/&gt;
&lt;/xsl:with-param&gt;
&lt;xsl:with-param name="id"&gt;&lt;xsl:value-of select="$id" /&gt;&lt;/xsl:with-param&gt;
&lt;/xsl:call-template&gt;
&lt;/xsl:if&gt;
&lt;/xsl:if&gt;
&lt;/xsl:template&gt;
</pre>
<p>You can add or remove variables depending on what you need.  In the above example code, I had a semi-colon list of email attachment file names that were attached to the list.  I wanted to create a &#8216;clickable&#8217; link to each file, which is why I needed the ID field.  Normally, you wouldn&#8217;t need the ID field.</p>
<p>This is how I called the template in my XSL:</p>
<pre language="XML">&lt;xsl:call-template name="split-string"&gt;
&lt;xsl:with-param name="list"&gt;&lt;xsl:value-of select="@EmailAttachmentNames" /&gt;&lt;/xsl:with-param&gt;
&lt;xsl:with-param name="delimiter"&gt;;&lt;/xsl:with-param&gt;
&lt;xsl:with-param name="id"&gt;&lt;xsl:value-of select="@ID" /&gt;&lt;/xsl:with-param&gt;
&lt;/xsl:call-template&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://whatsthesharepoint.com/2010/02/xslsplit-string-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

