Reputation: 1024
What is the difference between these expressions?
<xsl:text>someValue</xsl:text>
<xsl:value-of select="'someValue'"/>
And which to use?
Upvotes: 0
Views: 48
Reputation: 21004
<xsl:value-of select=""/>
element is used to extract the value of a selected node.
The <xsl:text>
element is used to write literal text to the output. This element may contain literal text, entity references, and #PCDATA
.
Note that in your exemple, both will return the same as you specify to select the text 'someValue', but I tought it would be nice to tell you the difference between both.
Upvotes: 1
Reputation: 167581
Both <xsl:text>someValue</xsl:text>
and <xsl:value-of select="'someValue'"/>
create a text node with the contents someValue
so there is no difference and if you want to output a literal text it is up to you which form you prefer. Of course in general value-of
and its select
attribute allow you the use of an XPath expression of any type, so in case you don't want to output a string hard coded in XSLT you would use value-of
.
Upvotes: 1