Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference variable in xsl:text element?

Tags:

xslt

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}...

like image 669
theta Avatar asked Jul 23 '12 14:07

theta


People also ask

How do you call a variable in XSLT?

XSLT <xsl:variable> The <xsl:variable> element is used to declare a local or global variable. Note: The variable is global if it's declared as a top-level element, and local if it's declared within a template. Note: Once you have set a variable's value, you cannot change or modify that value!

What is text () in XSLT?

The <xsl:text> element is used to write literal text to the output. Tip: This element may contain literal text, entity references, and #PCDATA.

What is &# xA in XSLT?

The simplest way to do this in an XSLT stylesheet is to use the character entities for the newline ( &#xA; ) and tab ( &#x9; ) characters.


1 Answers

xsl:text is only used to output fixed text, and it cannot contain nested instructions. The instruction to output variable text is xsl:value-of.

like image 199
Michael Kay Avatar answered Nov 15 '22 22:11

Michael Kay