I am trying to learn XSLT. I am simply getting crazy. Variables should be declared within xsl:variables entity and instantiated with their names having the $ symbol just before them (like perl variables), right? Why on earth this code:
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'> <xsl:variable name='color' select=''red'' /> <p>$color</p> </xsl:template> </xsl:stylesheet>
results in the literal string: ‘$color’ being written parsing a simple non empty xml document using the msxsl parser? Many thanks
Use
<xsl:value-of select='$color'/>instead of writing$colordirectly to the document.See also this question.