Search code examples
sharepointxpathwindows-sharepoint-services

Sharepoint/WSS: helping writing xpath conditional expression


Assuming there is some way to do this... I am using WSS 3.0 and SP Designer 2007. I've changed a list to its XSLT data view in SPD, and am trying to add a formula to display the first 250 characters of the body text, and then IF there are additional characters, add a "(more)" link to the list item.

The problem I'm running into is the conditional aspect... the following successfully adds the "(more)" text and links correctly. But I can't seem to figure out how to only execute it if the body text > 250 characters. Any ideas?

concat(substring(@Body,0,250),'... <a href="/Lists/Highlighted%20Items/DispForm.aspx?ID=',@ID,'">(more)</a>')  

I can use string-length(@Body) to get the length... but how do I put these together?

Thanks, Mark


Solution

  • Does this help?

    <xsl:choose>
        <xsl:when test="string-length(@Body) &gt 250"></xsl:when>
        <xsl:otherwise></xsl:otherwise>
    </xsl:choose>