How Do I Generate Some Text?

You can generate text in your output in several different ways. The simplest way is to use the <xsl:text> element. This element generates text to the output stream automatically. The <xsl:text> element is often necessary because many elements in the XSLT vocabulary can’t contain text.

A second way is to use the <xsl:value-of> element with various string functions. Say we’re going to generate a string that is the concatenation of several items in the current context. Combining <xsl:value-of> with the concat() function allows us to do this. Here’s an example:

<xsl:value-of select="concat('abc ', 'easy as ',123)"/>

This element is replaced with the text “abc easy as 123.”

Get XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.