xsl-list
[Top] [All Lists]

RE: Count Words

2004-08-08 15:11:28
You could use the exslt:tokenize extension function with XSLT 1.0, or the
built-in tokenize() function with XSLT 2.0.

Alternatively:

<xsl:variable name="in" select="normalize-space(hey_diddle)"/> 

<xsl:value-of select="string-length(translate($in, translate($in, ' ', '')))
+ 1"/>

Michael Kay
 

-----Original Message-----
From: Karl J. Stubsjoen [mailto:karl(_at_)meetscoresonline(_dot_)com] 
Sent: 08 August 2004 21:19
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Count Words

Hello,

Given the following:

=========== xml source ==========
<poem>
  <hey_diddle>
      Hey diddle diddle, the cat and the fiddle,
      The cow jumped over the moon,
      The little dog laughed to see such sport,
      And the dish ran away with the spoon.
  </hey_diddle>
</poem>
=========== /xml source ==========

How do I count how many words are contained within the node 
<hey_diddle/>?

Karl

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>