2

I've been chasing some weird problems with a Custom Field Type on a page that has a list view web part with Designer-provided Conditional Formatting.

It seems like the XSL for the fields have been frozen since I added the Conditional Formatting; it no longer changes when the custom field type's XSL is updated and redeployed.

Unfortunately it could be that I'm suffering a symptom of a deployment problem, so I'm just checking that I'm not chasing my own tail.

Is the XSL frozen/copied/snapshotted by SharePoint Designer; and if so, is this feature documented anywhere?

3 Answers 3

2

I think here you will need, first of all, to understand, how the conditional formatting actually works.

Conditional formatting in SPD is not more than a visual way to define Xsl property of XsltListViewWebPart and other standard webparts, which use xsl transformations. Xsl property contains custom xsl code, and links to standard SharePoint xslt files, like main.xsl.

By default, XsltListViewWebPart receives your data in some xml representation, then applies transformations, defined in main.xsl and other SharePoint files, and after this you're getting the final html.

But if Xsl property is defined, XsltListViewWebPart will use it, rather than standard transformations.

From this point, you can see now, that if you will define something in Xsl property (how the conditional formatting tool does), you can modify main.xsl file and other standard transformations files as many times as you wish - but SharePoint will always use local Xsl property.

Fortunately, XSL transformations allow to use links to standard files inside your customized Xsl property. So, Xsl property redefines not the whole main.xsl file, but only small parts of it. These parts (called xsl templates), however, are copy-pasted from their sources, and detached from sources from that moment.

So, if your formatting freezes, the only solution here is to reapply conditional formatting each time you change something in your custom field rendering template.

You can examine the Xsl code, which were generated by conditional formatting tool, selecting the Code tab at the bottom pane in SPD:

SPD Code tab

Here is an example for Xsl property, generated by conditional formatting, which changes background color to green for one column, if title of the item contains text 'Green' (formatted & commented by me, of course, don't think SharePoint indents the code :) ):

<xsl>
 <xsl:stylesheet 
   xmlns:x="http://www.w3.org/2001/XMLSchema" 
   xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 
   version="1.0" 
   exclude-result-prefixes="xsl msxsl ddwrt" 
   xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
   xmlns:asp="http://schemas.microsoft.com/ASPNET/20" 
   xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:msxsl="urn:schemas-microsoft-com:xslt"
   xmlns:SharePoint="Microsoft.SharePoint.WebControls"
   xmlns:ddwrt2="urn:frontpage:internal" 
   xmlns:o="urn:schemas-microsoft-com:office:office"> 

  <!-- linked files -->
  <xsl:include href="/_layouts/xsl/main.xsl"/> 
  <xsl:include href="/_layouts/xsl/internal.xsl"/> 

  <xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]"/>
  <xsl:param name="dvt_apos">&apos;</xsl:param>

  <!-- this xsl template is redefined -->
  <xsl:template 
    name="FieldRef_printTableCell_EcbAllowed.LinkTitle"
    match="FieldRef[@Name='LinkTitle']" 
    mode="printTableCellEcbAllowed" 
    ddwrt:dvt_mode="body" 
    ddwrt:ghost="" 
    xmlns:ddwrt2="urn:frontpage:internal">

    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />

    <td>
        <!-- attributes for td -->

        <xsl:attribute name="style">

            <!-- here our 'green' condition is evaluated, and the green background is applied -->
            <xsl:if 
              test="contains(normalize-space($thisNode/@Title), 'Green')"
              ddwrt:cf_explicit="1">background-color: #71B84F;</xsl:if>

        </xsl:attribute>

        <!-- and this xsl code below is copy-pasted from some standard files -->
        <!-- it doesn't do any conditional formatting work, as you can see -->
        <!-- it is now detached from it's source -->

        <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
            <xsl:attribute name="height">100%</xsl:attribute>
            <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
        </xsl:if>
        <xsl:attribute name="class">
            <xsl:call-template name="getTDClassValue">
              <xsl:with-param name="class" select="$class" />
              <xsl:with-param name="Type" select="@Type"/>
              <xsl:with-param name="ClassInfo" select="@ClassInfo"/>
            </xsl:call-template>
        </xsl:attribute>

        <!-- next, inner template is called here -->
        <xsl:apply-templates select="." mode="PrintFieldWithECB">
            <xsl:with-param name="thisNode" select="$thisNode"/>
        </xsl:apply-templates>

    </td>
  </xsl:template>
 </xsl:stylesheet>
</xsl>
0
1

I'm not quite sure what you mean. XSL is just the XML processing instructions that convert the XML data into HTML for display on the page. So yes, the XSL would be static in that regard. Conditional formatting is just further instructions on how to handle particular rows of data that is output.

1
  • Ah, I see the confusion: the XSL for the field rendering is not static as would normally be the case because I'm changing the field type's own XSL and redeploying it to see the results. I'll update my question.
    – Stu Pegg
    Commented May 17, 2011 at 20:36
1

I've noticed when working with the XSLT List View Web Part, that sometimes changes to the XSLT do not show up. This usually happens to me because there is some invalid XSLT in my stylesheet, so it uses the last stylesheet that worked. As long as there is invalid XSLT it continues to use the old stylesheet. Try opening your page in design mode of Designer, look at where the web part should be, and see if there is an error message displayed. I don't know if this is what's happening to you, but it worth a look.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.