When used without any accompanying attributes, the <if> and
<ifnot> tags perform no useful function. However, with meaningful attributes, these
tags can be used to quickly and simply flag regions of mark-up for display under specific circumstances.
The <if> tag examines its defined attributes through equivalence comparisons
to variables whose names match the attribute names. If the specified attribute's value matches the variable's value
exactly, the region of mark-up between that <if> and its associated
</if> closing tag will be processed by LXP. Otherwise, that region (between
<if> and </if>) will be completely ignored
(including any LXP mark-up) up to its closing tag.
You may include in the <if> tag either an attribute name, a complete
attribute pair, or a series of attribute pairs, depending on the intended logical assessment you wish to make.
Providing only an attribute name (e.g., <if test>) causes LXP to check only
for the existence of
characters assigned to the variable value with that name. In this case, if
the variable is set to an empty value (or not set at all), the <if> match fails,
and its defined region is
(not displayed). Otherwise, if a value is found, the region is
processed as it would be normally.
Providing one or more attribute pairs results in each attribute value being compared to the variable with the
specified attribute name. When more than one attribute is specified in the tag,
match exactly for the <if> conditions to be considered a match as a whole, and for
the region to be processed.
Example 13-13 uses the <if> tag to check for the existence
of any variable value named name, and compares the variable named
access to the value of 1.
Example 13-13. Using the <if> tag
<if name access="1">
A <em>name</em> is set, and <em>access</em> is set to 1.<br />
The <ifnot> tag logically performs the opposite of the
<if> tag in every respect. For example, when multiple attributes are passed, each
equivalence comparison must
for the <ifnot> region to be
Example 13-14 uses the <ifnot> tag to test for the lack
of a variable called error, as well as to check that a variable named
access is not set to the value of 0.
Example 13-14. Using the <ifnot> tag
<ifnot error access="0">
An <em>error</em> is not set, and <em>access</em> is not set to 0.<br />
Note: You may not define two attributes with the same name in a single LXP tag (e.g., <ifnot access="0" access="2">
is not valid). Therefore, two logical assessments on one variable requires the use of two logic tags.
refers to placing tags within regions marked-up by other tags. You may safely
nest logical tags as much as you like, provided you carefully keep track of where they open and close.
In some cases, you may have to nest logic tags in order to perform multiple checks on a single variable. This is
because you can only place a variable's name inside of a logic tag once.
Example 13-15 nests several logic tags within one top-level
Example 13-15. Using nested logic
<strong>You have supplied an answer!</strong><br />
Your answer is correct!<br />
Your answer of <putvar name="answer">, though, is incorrect.<br />
<if answer="12" cheatcode>
You appear to be cheating, however.
In Example 13-15, the first <if> tag checks to see if an
argument titled answer is set at all. If it is not, the entire region it
encapsulates is muted.
The second <if> tag evaluates the passed
answer argument to see if it is equal to 12. If it is,
that <if> tag's region is processed. Otherwise, that region will be muted.
The <ifnot> tag then checks to see if the passed argument named
equal to 12. If it
is not, the region that the <ifnot> encapsulates will be processed.
Lastly, the final <if> tag in Example 13-15 checks to
see if the passed value for answer is equal to 12, and
for the existence of a passed argument called cheatcode. If the variable
answer is found to equal 12, and the variable
cheatcode is found at all, the region encapsulated by the last
<if> tag will be processed (meaning, in this case, that it is merely