Skip to content
Amal Hashim
All posts
Snippet

SharePoint XSLT: ends with

XSLT 1.0 has no ends-with function, so compare the last characters of the string with substring.

1 min read#SharePoint#SharePoint 2010

XSLT 1.0, which SharePoint 2010 uses, has no ends-with function. Take the last characters with substring and compare them.

This checks whether the URL ends with .pdf:

xml
<xsl:when test="substring($url, string-length($url) - 3) = '.pdf'">

The start position is the string length minus 3, so substring returns the final four characters.