I have a stylesheet where I would prefer to insert predefined string variable in xsl text element, but can’t find any pointers while searching the web.
For example:
<xsl:variable name="var" select="node()/ref/text()"/>
...
<xsl:text>Some text where I want to append $var variable desperately</xsl:text>
...
I tried with $var, ($var), {$var}…
Note that
<xsl:text>is only needed to control the behavior on whitespace. Most of the time, you can simply type text and just include this element when the result is not what you expected – I guess knowing the rules for when to use<xsl:text>doesn’t hurt, however. 🙂 (And it’s not complicated: Use<xsl:text>if otherwise, your text nodes would only have white space or if they would include additional whitespace you want to avoid at either end.)EDIT: Note that whitespace in variables doesn’t need
xsl:textfor protection when used, that is only for the XSL parsing step: