XML Script logo
_if statement
Usage

The _if command takes three arguments: test, then and else. All three parameters are optional (see below for when you may wish to omit the test parameter). The test parameter can only be specified as an attribute to the _if element, not as a sub-element. The then and else parameters may be specified as attributes or sub-elements. If neither then nor else are present as an attribute, the textual contents of the _if element will be deemed to represent then rather than else.

Warning: then and else elements are treated as "reserved words" within an _if element. Using __delay or __mode attributes will not hide then or else elements from the _if statement. Within an _if element, then and else should only be used as part of the _if statement.

If the test attribute is omitted from the _if element, it will default to $.debug, which will return true if $.debug has been set and is not null or zero. This allows debug statements to be added to templates easily using a simple, two tag, _if element with no attributes. Note however that only the textual content of the tag will be output, and any tags embedded outside of an explicit then or else will not be processed.

Examples

Using the _if element with then and without else

Using the _if element without then and with else

Using the _if element with attributes

Using the _if element with sub-element

Using the _if element with mixed syntax

Using the _if element with assumed content

Using the _if with the default $.debug test

Only textual content is used for implied elements

Using elseif tags within the _if command

Using elseif in nested if statements

Version

1.0

Ref

t.18

Date

6 July 1999

XML Script homepage | Documentation home | XML Script docs | Command list | Function list | X-Tract docs

X-Stream, X-Tract and XML Script are trade marks of DecisionSoft Limited
© Copyright 1998-2000 DecisionSoft Limited