Following is the xml file:
-------------------------------------
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="UTF-8"?>
- <wc>
- Delhi is the capital of India
- </wc>
I am able to count the number of Words using XSLT 1.0.
********** Requirement is if count of blank spaces is 3 then first 4 words of the node is to displayed. *************
Following is the xsl:
--------------------------------
Expand|Select|Wrap|Line Numbers
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
- <xsl:call-template name="Word_Count">
- <xsl:with-param name="text">
- <xsl:value-of select="wc"/>
- </xsl:with-param>
- <xsl:with-param name="space" select="' '"/>
- <xsl:with-param name="count" select="0"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="Word_Count">
- <xsl:param name="text"/>
- <xsl:param name="space"/>
- <xsl:param name="count"/>
- <xsl:choose>
- <xsl:when test="contains($text, $space)">
- <xsl:call-template name="Word_Count">
- <xsl:with-param name="text">
- <xsl:value-of select="substring-after($text, $space)"/>
- </xsl:with-param>
- <xsl:with-param name="space" select="' '"/>
- <xsl:with-param name="count">
- <xsl:value-of select="number($count + 1)"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise/>
- </xsl:choose>
- No of Blank Spaces : <xsl:value-of select="number($count)"/>
- <br/>
- No of Words : <xsl:value-of select="number($count) + 1"/>
- <br/>
- <xsl:text>.....................................</xsl:text>
- <br/>
- </xsl:template>
- </xsl:stylesheet>
Any help will be highly appreciated.....
Thnx,
Saurabh