I'm trying to modify the out-of-the-box rendering of the xslt list view webpart to collapse the terms, and show (..more) if there are more than 1 term in the field. I already did this for an "Authors" field (user field), which shows a pop-up for the rest of the users using jQuery.

Maybe the pic will tell you more.


Now, I'm trying to do the same for a taxonomy field, but I'm not having much success. I checked the xslt from SPD, and copied it to my custom xslt file in VS2010, but it doesn't work.

This is the relevant part found in SPD (for the field "Country").

<xsl:template name="FieldRef_printTableCell_EcbAllowed.Country" match="FieldRef[@Name='Country']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="hide">
   <xsl:param name="thisNode" select="."/>
   <xsl:param name="class" />
   <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
     <xsl:attribute name="height">100%</xsl:attribute>
     <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
   <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:apply-templates select="." mode="PrintFieldWithECB">
    <xsl:with-param name="thisNode" select="$thisNode"/>

I tried modifying it by adding some random text messages inside the templates, so I know the xslt works, and finds the field. But it does not.

 <xsl:template match="FieldRef[(@Encoded) and @Name='Country']" ddwrt:dvt_mode="body" mode="Lookup_body" ddwrt:ghost="hide">
 Some random text
   <xsl:param name="thisNode" select="."/>
<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" /></xsl:template>

Usually, "Some random text" should also appear in the field, if it was a user field, or number etc. but this time it does not.

So I was wondering maybe you have an idea on how this custom rendering for taxonomy fields can be done.

2 Answers 2


In your case for rendering Taxonomy field in template the following attributes are specified correctly:

a) match attribute (value correspond to field internal name)

match="FieldRef[(@Encoded) and @Name='Country']"

b)mode attribute (Taxonomy field has Lookup type)


Please remove another attributes, your template should look like shown below:

<xsl:template match="FieldRef[(@Encoded) and @Name='Country']"  mode="Lookup_body">
 Some random text
   <xsl:param name="thisNode" select="."/>
<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" /></xsl:template> 

Calling this template might be an issue

 <xsl:template match="FieldRef[(@Encoded) and @Name='Country'] ... >

I'm not sure but i think the call to this template is not really correct that is why you never see the text.

  • This is how I got the xslt from SPD. Rest assured I tried different combinations (even without the @Encoded part), but to no avail. Jul 20, 2012 at 13:27

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.