XML & XSL - xsl:eval


The xsl:eval tag evaluates an expression.

Syntax

<xsl:eval language="language-name">

Attributes

Parent Elements

Child Elements

None.

Purpose

xsl:eval contains an expression which is evaluated. xsl:eval can also contain a sequence of script statements. The script return value is converted to a string. Reserved characters <, >, &, " and ' are escaped using &lt;, &gt;, &amp, &quot;, &apos; respecitvely.

The example below shows the evaluation of an expression using the xsl:eval tag.

<xsl:stylesheet language="JavaScript">

	<xsl:template match="/">
		<xsl:eval>temperature(32,"Celcius")</xsl:eval>
	</xsl:template>
 
	<xsl:script language="JavaScript">
		function temperature (fltDegrees, strTo)
		{
			if (strTo == "Celcius")
			{
				return ((fltDegrees - 32) * 5) / 9;
			}
			else
			{
				return ((fltDegrees * 9) / 5) + 32;
			}
		}
	</xsl:script>

</xsl:stylesheet>