I need to output the following xml to the browser exactly as it appears below:
<?xml version="1.0" encoding="UTF-8"?>
<content>
<text>
<h1>Services</h1>
<h2>Engineering</h2>
This is the first bit of text:
<listofitems>
<listitem>Database Analysis Tools</listitem>
<listitem>Website Development</listitem>
<listitem>Intranet Development</listitem>
<listitem>Database Development</listitem>
</listofitems>
This is the second piece of text:
<listofitems>
<listitem>Hardware</listitem>
<listitem>Software</listitem>
</listofitems>
This is the final piece of text.
</text>
</content>
The problem is with the text strings inside the <text> 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.'
I can output all three bits of text in a single block if I use <xsl:value-of select="."/>, but obviously that's not how they appear in the original XML. If I use <xsl:value-of select="text()"/> I get nothing back (I believe text() only references the first child node, which in this case is another element).
I can output the last bit of text with <xsl:value-of select="node()[last()]/self::text()">; I can access each text() node by referencing it directly, e.g. <xsl:value-of select="text()[3]"/>, 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?