title: Selecting multiple text() nodes between elements
body: <p>I need to output the following xml to the browser exactly as it appears below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;content&gt;
    &lt;text&gt;
      &lt;h1&gt;Services&lt;/h1&gt;
      &lt;h2&gt;Engineering&lt;/h2&gt;
      This is the first bit of text:
        &lt;listofitems&gt;
          &lt;listitem&gt;Database Analysis Tools&lt;/listitem&gt;
          &lt;listitem&gt;Website Development&lt;/listitem&gt;
          &lt;listitem&gt;Intranet Development&lt;/listitem&gt;
          &lt;listitem&gt;Database Development&lt;/listitem&gt;
        &lt;/listofitems&gt; 
      This is the second piece of text:
        &lt;listofitems&gt;
          &lt;listitem&gt;Hardware&lt;/listitem&gt;
          &lt;listitem&gt;Software&lt;/listitem&gt;
        &lt;/listofitems&gt;
      This is the final piece of text.
    &lt;/text&gt;
  &lt;/content&gt;
  </code></pre>
  
  <p>The problem is with the text strings inside the &lt;text&gt; element - the bits not enclosed in their own tags, i.e. 'This is the first bit of text:', 'This is the second piece of text:' and 'This is the final piece of text.'</p>
  
  <p>I can output all three bits of text in a single block if I use &lt;xsl:value-of select="."/&gt;, but obviously that's not how they appear in the original XML. If I use &lt;xsl:value-of select="text()"/&gt; I get nothing back (I believe text() only references the first child node, which in this case is another element).</p>
  
  <p>I can output the last bit of text with &lt;xsl:value-of select="node()[last()]/self::text()"&gt;; I can access each text() node by referencing it directly, e.g. &lt;xsl:value-of select="text()[3]"/&gt;, but as this is meant to be used with random XML which could be of any format I won't be able to reference nodes directly in this way. I tried a for-each on text()[*] but it didn't work. Any ideas how I can do this?</p>