Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
How to separate words by space in xslt Sharepoint
2632 Views
Condition : where to use this... 
If you use substring to show some of the words it will cut the word in between the letters.
For example:
The word "content" is often used coll....

Instead of that use this following template to cut the paragraph by space.So that words not cut between the letters.
For Example:
The word "content" is often used colloquially....
Template : Strip words by space
<!--strip words by space -->
    <xsl:template name="FirstNWords">
     <xsl:param name="TextData"/>
     <xsl:param name="WordCount"/>
     <xsl:param name="MoreText"/>   
     <xsl:choose> 
     <xsl:when test="$WordCount &gt; 1 and (string-length(substring-before($TextData, ' ')) &gt; 0 or string-length(substring-before($TextData, ' ')) &gt; 0)"> 
        <xsl:value-of select="concat(substring-before($TextData, ' '), ' ')" disable-output-escaping="yes"/>
        <xsl:call-template name="FirstNWords"> 
        <xsl:with-param name="TextData" select="substring-after($TextData, ' ')"/> 
          <xsl:with-param name="WordCount" select="$WordCount - 1"/> 
          <xsl:with-param name="MoreText" select="$MoreText"/> 
        </xsl:call-template> 
      </xsl:when> 
       <xsl:when test="(string-length(substring-before($TextData, ' ')) &gt; 0 or string-length(substring-before($TextData, ' ')) &gt; 0)"> 
        <xsl:value-of select="concat(substring-before($TextData, ' '), '...')" disable-output-escaping="yes"/> 
       </xsl:when> 
      <xsl:otherwise> 
        <xsl:value-of select="$TextData" disable-output-escaping="yes"/> 
      </xsl:otherwise> 
     </xsl:choose> 
  </xsl:template>
  <!--Strip words by space -->
Call the template With your column
<xsl:call-template name="FirstNWords">
         <xsl:with-param name="TextData" select="@ShortDescription"/>
         <xsl:with-param name="WordCount" select="12"/>
</xsl:call-template>
Next Topics
Next lessons of current book.
Best Lessons of "Sharepoint(MOSS) XSLT codes"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details