This project is read-only.

MultiSelectDisplay XSL Template

Mar 11, 2012 at 1:44 AM

I have a dispform.aspx form showing a parent child with my child as the dvwp. Obviously (things can't be overly simple now cold they??) all my multiselect fields in my child dvwp lost their individual hyperlinks to their respective item when I converted the original LVWP to an XSLT form . After researching how  to retrieve my hyperlinks I recalled your SPXSLT templates. To make the multiselects look a little more user friendly or "nicer" as per your description, I've decided to try out your cool MultiSelectDisplay template until or including the point where I can have thise nicer appearance AND my hyperlinks back (thanks Microsoft).

I have followed your instructions for referencing the templates and have included an excerpt of my dispform.aspx page. 

.........
<xsl:stylesheet version="1.0" exclude-result-prefixes="rs z o s ddwrt dt msxsl" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:o="urn:schemas-microsoft-com:office" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:ddwrt2="urn:frontpage:internal"> <xsl:import href="https://myfantastikdomain/central/XSL/MultiSelectDisplay.xsl"/> <xsl:output method="html" indent="no" /><xsl:decimal-format NaN="" /> <xsl:param name="PageUrl" /> <xsl:param name="PagePath" /> <xsl:param name="HttpHost" />
............
However, upon saving and viewing, the child dvwp displays the standard XSLT rendering error: SharePoint Designer cannot render the XSLT in this Data view.... etc.
Am I in error of interpreting your instructions? Thank god people like you, what I consider savoirs to our ECM plight, are around to provide useful tools like this. I tell you, dealing with SharePoint is analogously like trying to pull a string through a tube from both ends. You adjust the string to grab at one end but in doing so pull the string too far into the other end of the tube. So you adjust the other end only to find now you've lost the string on the other end and on and on like a never ending if then else loop.
Thanks
CW
Coordinator
Mar 12, 2012 at 3:02 AM

Carl:

It soiunds like you've edited the default DispForm.aspx, which is a no-no. It can get you into these stuck situations where you're trying to fix a problem that you've caused and can't revert. Try right clicking on the DispForm.aspx page in SPD and choosing Revert to Site Template (the wording may be a little different).

If that doesn't fix the problem, you might consider recreating the list. Whenever you want to edit one of the default forms, take a copy of it - I usually call mine DispFormCustom.aspx, for exanmple - and edit that. Once you get it working the way you want it, change the default for in the list settings.

M.

Mar 12, 2012 at 2:43 PM
Edited Mar 13, 2012 at 3:58 PM

TX M. I'll look into it but I never directly edit the default forms. Its either CEWP or a copy as you described. Probably the site is experiencing Carlitis again ;)

From: sympmarc [email removed]
Sent: Sunday, March 11, 2012 10:02 PM
To: Williams,Carl [Ontario]
Subject: Re: MultiSelectDisplay XSL Template [SPXSLT:348140]

From: sympmarc

Carl:

It soiunds like you've edited the default DispForm.aspx, which is a no-no. It can get you into these stuck situations where you're trying to fix a problem that you've caused and can't revert. Try right clicking on the DispForm.aspx page in SPD and choosing Revert to Site Template (the wording may be a little different).

If that doesn't fix the problem, you might consider recreating the list. Whenever you want to edit one of the default forms, take a copy of it - I usually call mine DispFormCustom.aspx, for exanmple - and edit that. Once you get it working the way you want it, change the default for in the list settings.

M.

Mar 13, 2012 at 4:21 PM

Ok, sorry but I'm really confused. To test, I'm simply using a blank page with just the DVWP.

  1. At the top of the page, I added the <xsl:import line:

    <XSL><xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt"...........etc.
    <xsl:import href="https://myfantastikdomain/central/XSL/MultiSelectDisplay.xsl"/>   (this file is verified as being present by ctl-click and it opens)
    <xsl:output method="html" indent="no"/>
    
  2. At the bottom of the page I added the parameters for the MultiSelectDisplay right at the end of the XSL code:

    .......another previous template
    </xsl:template>
    <xsl:variable name="NiceDisplay">
      <xsl:call-template name="MultiSelectDisplay"> 
        <xsl:with-param name="MultiSelectValue" select="@RelatedTo"/>    (Multiselect with vakues of names: [Smith, John;Doe, John;Doe, Jane.....] 
        <xsl:with-param name="MultiSelectDelimiter" select="';'"/>
        <xsl:with-param name="MultiSelectSeparator" select="'|'"/>
      </xsl:call-template>
    </xsl:variable>
    </xsl:stylesheet></XSL>
    
With either both sections added or one added or one removed to determine the problem the page renders with:
"Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator."
I thought I was following the instructions.
Mar 13, 2012 at 4:40 PM

Update:

1.  I added the full function at the top of the page:

<XSL><xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl.........etc.


<xsl:output method="html" indent="no"/>
<xsl:template name="MultiSelectDisplay">
  <xsl:param name="MultiSelectValue"/>
  <xsl:param name="MultiSelectDelimiter"/>
  <xsl:param name="MultiSelectSeparator"/>
  <xsl:choose>
   <xsl:when test="contains($MultiSelectValue, $MultiSelectDelimiter)">
    <xsl:value-of select="concat(substring-before($MultiSelectValue, $MultiSelectDelimiter), $MultiSelectSeparator)" disable-output-escaping="yes"/>
    <xsl:call-template name="MultiSelectDisplay">
     <xsl:with-param name="MultiSelectValue" select="substring-after($MultiSelectValue, $MultiSelectDelimiter)"/>
     <xsl:with-param name="MultiSelectDelimiter" select="$MultiSelectDelimiter"/>
     <xsl:with-param name="MultiSelectSeparator" select="$MultiSelectSeparator"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="$MultiSelectValue" disable-output-escaping="yes"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
</xsl:variable><xsl:decimal-format NaN=""/> 2. At the bottom of the page I kept the parameters:
</xsl:template> .....end of previous template
<xsl:variable name="NiceDisplay">
  <xsl:call-template name="MultiSelectDisplay">
    <xsl:with-param name="MultiSelectValue" select="@RelatedTo"/>
    <xsl:with-param name="MultiSelectDelimiter" select="';'"/>
    <xsl:with-param name="MultiSelectSeparator" select="'|'"/>
  </xsl:call-template>
</xsl:variable>
    </xsl:stylesheet></XSL>
Now the page renders fine, but there's no change to the field in question. Still delimited with ';'.

Coordinator
Mar 13, 2012 at 4:50 PM

You should be putting the MultiSelectDisplay template in the XSL section of the DVWP, usually just at the bottom for easy reference. Then you add a call to the template where you want to use the value.

M.

Mar 13, 2012 at 4:54 PM

Hi M. I thought I was doing that as per my 11:21am post.

Coordinator
Mar 13, 2012 at 5:04 PM

It's pretty hard for me to tell exactly where you're putting things. When you say page, maybe you mean DVWP?

In number 2 in the 11:21am post, you're defining the variable outside any templates. Generally it makes more sense to call the template inline where you need it. So something like:

<td>
...display column...
</td>
<td>
...display column...
</td>
<td>
    <xsl:call-template name="MultiSelectDisplay">
      <xsl:with-param name="MultiSelectValue" select="@RelatedTo"/>
      <xsl:with-param name="MultiSelectDelimiter" select="';'"/>
      <xsl:with-param name="MultiSelectSeparator" select="'|'"/>
    </xsl:call-template>
</td>

You don't need to define a variable unless you want to use it in multiple locations.

M.

Mar 13, 2012 at 5:18 PM

Yes, sorry, I'm simply using a blank page with only a DVWP. It is my naivety of XSL as I’m thinking it was similar to a script where you place it in a spot in a page or CEWP and it gets called regardless.

 

I’ll try to find the proper <td> to place the variable. Thanks for being patient, this is my second time ever having looked at xsl and you templates are the only useful thing I found in my research (that I could partially understand J) to spruce up/parse the appearance of these “you know what” multiselect columns. Next thing is to add the hyperlink back to the value since they come with their own ID and you know the list they came from. So that should be........fairly...........easy on a Tuesday with a full moon.