I have the following XML:
<RichText>
Text
Text
Text
</RichText>
I would like to output the following HTML using XSLT 1.0 (2.0 if I really really have to):
<p>
Text<br/>
Text<br/>
Text
</p>
I've tried using the following XSL which gets close:
<xsl:template match="text()">
<xsl:param name="text" select="."/>
<!-- Because we would rely on $text containing a line break when using
substring-before($text,' ') and the last line might not have a
trailing line break, we append one before doing substring-before(). -->
<xsl:value-of select="substring-before(concat($text,' '),' ')"/>
<br/>
<xsl:if test="contains($text,' ')">
<xsl:apply-templates select=".">
<xsl:with-param name="text" select="substring-after($text,' ')"/>
</xsl:apply-templates>
</xsl:if>
<xsl:template>
This outputs:
<p><br>
Text<br>
Text<br>
Text<br>
<br></p>