How can I strip line breaks from my XML with XSLT?
- by Eric
I have this XSLT:
<xsl:strip-space elements="*" />
<xsl:template match="math">
<img class="math">
<xsl:attribute name="src">http://latex.codecogs.com/gif.latex?<xsl:value-of
select="text()" /></xsl:attribute>
</img>
</xsl:template>
Which is being applied to this XML (notice the line break):
<math>\text{average} = \alpha \times \text{data} + (1-\alpha) \times
\text{average}</math>
Unfortunately, the transform creates this:
<img
class="math"
src="http://latex.codecogs.com/gif.latex?\text{average} = \alpha \times \text{data} + (1-\alpha) \times 					\text{average}" />
Notice the whitespace character literals. Although it works, it's awfully messy. How can I prevent this?