Posts

Showing posts with the label String Manipulation

XSLT String Manipulation - Remove spaces in Field Value for use in URL

XSLT function sets the value of a parameter to the value of the required field, after processing to remove spaces. The parameter is then used to set part of url in the href attribute of an <a> tag. <xsl:template name="dvt_1.groupheader0"> <xsl:param name="fieldtitle" /> <xsl:param name="fieldname" /> <xsl:param name="fieldvalue" /> ....... other template params 1. Add a parameter to store <xsl:param name="stringNoSpaces" > <xsl:call-template name="stringreplace"> <xsl:with-param name="stringvalue" select="@Field-XPath" /> <xsl:with-param name="from" select="string(' ')" /> </xsl:call-template> </xsl:param> ....... main template code <a href="/FirstURLComponent/{$stringNoSpaces}"><xsl:value-of select="$fieldvalue" /></a> ....... remaining template code </xsl:...

Bulk File Rename files to remove or replace illegal characters - allow upload/migration to SharePoint Document Library

SharePoint document libraries can not store files if illegal characters exist in the file name ( Illegal Characters in SharePoint (MOSS 2007) ). Migrating/uploading a large number of documents and files to a SharePoint document library can become tedious if you have to rename each file containing illegal characters each time the copy fails (or delayed write error). To save a time and effort when migrating a large number of files, freeware bulk file renaming utilities are available which allow conditional renaming of files in a directory any sub directories. The software I used to bulk rename files to remove unsupported characters prior to migrating to SharePoint was the PFrank File Renamer , written by Peter Frankenberger. PFrank allows a series of conditions and rename actions to be performed on each file in a specified directory and any sub directories to remove or replace characters or strings from filenames. The most common is the "&" (ampersand) character, which I re...

SharePoint XSL String Replacement Function

Creating a list view Web Part to display data from a look-up field containing multiple look-ups. I ran into a problem when creating a list view Web Part in SharePoint Designer that displays data from look-up fields. If the field only allowed a single look-up, the list view was easy to create with no customisation required for the Web Part to display properly. After adjusting the look-up column/field to allow multiple selections, the result was an "Unable to display Web Part" message. To allow the multiple selection look-ups to be listed I needed to customise the XSL template to list each value in the look-up field. The following XSL template I adapted from http://wwww.maya.com/local/doc/xslt/FAQ/html_format/xsl/sect2/replace.html l, which solved my problem. The data from the multiple selection lookup field is returned in a string format, with each selection delimited with a ";". The following function replaces each occurance of the first string ";" with ...