title: Count number of word occurrences in strings using XQuery
body: <p>We have a very similar XML file to this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;nodeOne&gt;
    &lt;nodeTwo&gt;
      &lt;nodeThree&gt;
        foo bar zoo
      &lt;/nodeThree&gt;
    &lt;/nodeTwo&gt;
  &lt;/nodeOne&gt;
  &lt;nodeOne&gt;
    &lt;nodeTwo&gt;
      &lt;nodeThree&gt;
        foo bar
      &lt;/nodeThree&gt;      
    &lt;/nodeTwo&gt;
  &lt;/nodeOne&gt;
  &lt;nodeOne&gt;
    &lt;nodeTwo&gt;
      &lt;nodeThree&gt;
        zoo bar
      &lt;/nodeThree&gt;      
    &lt;/nodeTwo&gt;
  &lt;/nodeOne&gt;
  </code></pre>
  
  <p>What I would like to achieve is to count the occurrences of every word (delimitered by a whitespace) inside <code>nodeThree</code>. Considering the above example, the output would be something like:</p>
  
  <pre><code>foo 2
  bar 3
  zoo 2
  </code></pre>
  
  <p>I've tried to fetch every <code>text()</code> of <code>nodeThree</code>, and tried to <code>tokenize()</code> it into sequences of strings. Then, I thought, I might be able to join them and group, count afterwards, but I was not able to do so. Tried a lot of things until now.</p>