All posts tagged XSLT

Cleaning up Multi Choice fields in Content Query Web Part

I recently had to put together a Content Query Web Part that displayed a multiple choice field. By default the multiple choice field displays delimited with “;#”. Additionally sometimes you will find this combination of characters on the beginning and the ending of the string. Here is my XSLT template to clean up the choice field and substitute your replacement characters. Additionally I split out some of the supporting templates as they are very useful on their own.

Usage

<xsl:variable name="CleanFieldValue">
     <xsl:call -template name="cleanMultiChoice">
          <xsl:with -param name="choiceValue" select="@FieldValue"></xsl:with>
     </xsl:call>
</xsl:variable>
 
<xsl:call -template name="replaceCharsInString">
     <xsl:with -param name="stringIn" select="$CleanFieldValue"></xsl:with>
     <xsl:with -param name="charsIn" select="';#'"></xsl:with>
     <xsl:with -param name="charsOut" select="', '"></xsl:with>
</xsl:call>

Continue reading →