Previous Next

Evaluates an expression, initialises a named variable if it does not exist, then assigns the result of the evaluation to the variable.

variable:Set( nameexpression )

Both name and expression are required. Expression may be a constant, a function (Example 1), or an XPath expression (Example 2).

A variable is created with name name if such a variable does not exist. The result of evaluating expression is assigned to the variable, overwriting any existing value of the variable.


Example 1

This example creates the variable "envxml" and sets it to the contents of the "env.xml" file.

<pc:evaluate select="variable:Set('envxml', files:XmlFile('env.xml'))"/>


Example 2

This example created the variable "mytableregexp" and sets it to the text contents of the <result> element in the outcome of an XSLT transformation executed by a <pc:apply> child node instruction. This outcome is a regular expression representing a list of tables, of the format




select uscsxsl.blend(
   '<example xmlns:pc="Processing.Command" pc:hideme="true">
    <pc:assign xml = "{sql:SqlStmnt('''', $sql)}" />
    <pc:evaluate select="variable:Set(''mytableregexp'', ./result/text())">
      <pc:apply   xml="{$xml}" xsl="{xsl:stylesheet}" >
        <xsl:stylesheet  version="1.0" xmlns:xsl="">
         <xsl:output method="xml" encoding="UTF-8"/>
          <xsl:template match="/">
              <xsl:for-each select ="*/T_TABLE">
                <xsl:value-of select="@TABLE_NAME"/>
                <xsl:if test="position()&lt;last()">
    <pc:comment-of><pc:copy-of select="$mytableregexp"/></pc:comment-of>  


See also