Evaluates a script expression to generate a text string.
Syntax
<xsl:eval language="language-name" >
Attributes
- language
- Active Scripting language used for the expression contained within this element. If left unspecified, the current scripting language is used, as specified by a language attribute on an ancestor. If no such attribute exists, JScript® (compatible with ECMA 262 language specification) is used. This attribute accepts the same values as the language attribute on the HTML SCRIPT element.
Element Information
Number of occurrences Unlimited Parent elements xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:for-each, xsl:if, xsl:otherwise, xsl:pi, xsl:template, xsl:when, output elements Child elements (No child elements) Requires closing tag Yes. XSL is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed.
Remarks
The contents of this element are treated as an expression. Alternatively, this element can also contain a sequence of script statements. The value returned by the script is converted to a string.
The reserved characters <, >, and & are escaped using the character entities <, >, and & respectively.
Other than at the text level, xsl:eval does not provide a mechanism for affecting structural transformation. See the expr attribute on xsl:if and xsl:when.
Example
The following fragment demonstrates a call to a user-defined routine, Celsius.
<xsl:stylesheet language="VBScript" xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <xsl:eval>Celsius(32)</xsl:eval> </xsl:template> <xsl:script language="VBScript"> Function Celsius(fDegrees) Celsius = (fDegrees - 32) * 5 / 9 End Function </xsl:script> </xsl:stylesheet>
See Also