title: XPath to count total number of string tokens of several nodes in XSLT 1.0?
body: <p>Is there a neat XPath expression to count string tokens of a set of nodes? Eg;</p>
  
  <pre><code>&lt;set&gt;
    &lt;hi&gt;hello, there, world&lt;/hi&gt;
    &lt;hi&gt;foo, bar&lt;/hi&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>The answer I want for the above example is the value <code>5</code>. The first <code>&lt;hi&gt;</code> has 3 tokens. The second <code>&lt;hi&gt;</code> has 2 tokens.</p>
  
  <p>The <code>&lt;set&gt;</code> may contain any number of <code>&lt;hi&gt;</code> nodes, each of which may contain any number of tokens. A token is a string separated by a comma followed by space.</p>
  
  <p>I've tried;</p>
  
  <pre><code> &lt;xsl:value-of select="count(str:tokenize(/set//hi, ', '))"/&gt;
  </code></pre>
  
  <p>but that returns the number of tokens of the first node, ie. <code>3</code>.</p>
  
  <p>I'm using XSLT 1.0. (PHP libxml version 2.7.3)</p>