Elementname: SetVariable

Description

Associates a value with a variable name. The value can be a simple value or a more complex one consisting of several elements.

Allowed attributes: select, trace, variable

Child elements: Attribute, Columns, Copy-of, Element, ForAll, Loop, Paragraph, SortSequence, Switch, TableNewPage, Tablehead, Tablerule, Td, Tr, Value

Parent elements: AtPageCreation, AtPageShipout, Case, Contents, ForAll, Include, Layout, Loop, Otherwise, Record, SavePages, Until, While

Attributes

select (XPath Expression, optional)

The value of the contents.

trace (optional)

Show information about the assignment in the log file.

yes:

Show information.

no:

Don't show information (default).

variable (text)

The name of the variable that holds the contents.

Remarks

Variables have global scope.

Example

<Record element="product">
  <SetVariable variable="wd" select="5"/>
  <PlaceObject>
    <Textblock width="{ $wd }">
      <Paragraph>
        <Value select="$articlenumber"/>
      </Paragraph>
    </Textblock>
  </PlaceObject>
</Record>

The following example shows a more complex scenario: you can collect complex elements in a variable.

<Record element="products">
  <SetVariable variable="articletext"/>
  <ProcessNode select="article"/>
  <PlaceObject>
    <Textblock>
      <Value select=" $articletext "/>
    </Textblock>
  </PlaceObject>
</Record>

<Record element="article">
  <SetVariable variable="articletext">
    <!-- the previous contents is added -->
    <Value select="$articletext"/>
    <Paragraph>
      <Value select=" @description "/>
    </Paragraph>
  </SetVariable>
</Record>

See also

Value

Commands

Version: 3.5.9 | Start page | Command reference | Other language: German