Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using multi item lookup fields in a list (eg: "Data Subjects"). I then have a web part page with a Data View Web part connected to this list.

The data within Lookup fields span the column width but I wish each new item of data to start on a new line for clarity.

Example:

Apples; Pears; Peaches;

I am trying to insert the following XSL into code view:

<xsl:param name="text" select="@Data_x0020_Subjects"/>  
<xsl:choose>
<xsl:when test="contains($text, ';')">
<xsl:value-of select="substring-after($text, ';')"/>
<xsl:value-of select="concat(.,'&#xA;')"/>
</xsl:when>
</xsl:choose>
</xsl param>

However, I get various errors relating to the location of the XSL: or "keyword xsl:stylesheet may not contain xsl:choose"

Newbie to XSL so any help would be much appreciated!

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

At first glance, you are closing off your xsl param in the first line. Then you have an unnecessary and mistyped closing xsl param tag which can be removed. You'll also want to include an xsl:otherwise so that if no multiple selection is made, the text is returned.

This might be helpful, look at question 1. You'll need to do a recursive template to do it, it isn't as easy as doing a string replace, you have to break the components up and interject some html into the output.

Using the above link, and this one, I was able to get it working as a sample. This is the template to add with all the other templates defined in the XSL.

<xsl:template name="StringSplit">
<xsl:param name="val" />
<xsl:choose>
  <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:call-template>
  </xsl:when>
  <xsl:otherwise>
      <xsl:value-of select="$val" />
   </xsl:otherwise>
</xsl:choose>
</xsl:template>

Then in your rowview, you'd call this template as such:

<td class="ms-vb">
    <xsl:call-template name="StringSplit">
      <xsl:with-param name="val" select="@YourColumn" />
    </xsl:call-template>
</td>
share|improve this answer
    
Hi Eric, thanks for your help. I have tried the following revised xsl with no luck <xsl:param name="text" select="@Data_x0020_Subjects"/> <xsl:choose> <xsl:when test="contains($text, ';')"> <xsl:value-of select="substring-after($text, ';')"/> <xsl:value-of select="concat(.,'&#xA;')"/> <xsl:otherwise></xsl:otherwise> </xsl:when> </xsl:choose> the place i thought would be most suitable is between an <xsl template> and closing </xsl template> tags. I am getting "Failed setting processor stylesheet: 0x80004005 : keyword xsl:param may not be used here" –  Stephen May 25 '11 at 11:01
    
Without seeing your full xslt, it will be difficult to debug. You'll need to utilize a template like I had linked in order to break apart the multiple values. You'd also want to include <xsl:value-of select="$text" /> within your otherwise markup so that singular items will be displayed. –  PirateEric May 25 '11 at 12:29
    
Edited answer with the solution. –  PirateEric May 26 '11 at 13:50
    
nice post..... thanx.. i am facing filter problem with multivalue parameters..any suggestions? –  user4284 Aug 8 '11 at 11:55
add comment

Your Answer

 
discard

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.