Plasma GitLab Archive
Projects Blog Knowledge


[UP]
The UI language
 ui:a
 ui:alist-value and ui:alist-item
 ui:application
 ui:button
 ui:checkbox
 ui:cond
 ui:context
 ui:default
 ui:dialog
 ui:dyn-enum-value and ui:dyn-enum-item
 ui:dynamic
 ui:encode
 ui:enum-value and ui:enum-item
 ui:enumerate
 ui:enumeration and ui:enum
 ui:false
 ui:file
 ui:form
 ui:if
 ui:ifexpr
 ui:iflang
 ui:ifvar
 ui:imagebutton
 ui:iter-*
 ui:iterate
 ui:page
 ui:param
 ui:popup
 ui:radio
 ui:richbutton
 ui:select
 ui:server-popup
 ui:special
 ui:string-value
 ui:template
 ui:text and ui:password
 ui:textarea
 ui:translate
 ui:true
 ui:use
 ui:variable
 t:*, q:*, and p:*
 l:*
 $param
 $[expr]
 Dot notation (v1.v2)
   
The element ui:if

This element compares two values. If the result is true, the inner nodes are expanded and the condition code is set to true; otherwise the inner nodes are ignored, and the conditon code is set to false.

Declaration

Level: Control structure

<!ELEMENT ui:if ANY>

<!ATTLIST ui:if
          value1   CDATA         #REQUIRED
          value2   CDATA         #REQUIRED
          op       CDATA         "eq"
>
Attributes

  • value1: The first operand of the comparison

  • value2: The second operand of the comparison

  • op: The comparison operator

Since WDialog-2.1 it is allowed to pass more than two operands to the comparison function, although there is not any application for this feature in WDialog itself. User-defined comparison functions may take advantage from this, however. Additional operands are passed as attributes value3, value4 and so on.

Sub elements

All page body elements may occur as sub elements.

Operators

The following operators are defined for ui:if:

  • eq: string equality

  • ne: string inequality

  • match: the first operand matches the regular expression denoted by the second operand (see notes on regular expressions below)

  • nomatch: the first operand does not match the regular expression denoted by the second operand (see notes on regular expressions below)

  • int-eq: integer equality

  • int-ne: integer inequality

  • int-lt: the first operand is less than the second operand

  • int-le: the first operand is less or equal than the second operand

  • int-gt: the first operand is greater than the second operand

  • int-ge: the first operand is greater or equal than the second operand

Since WDialog-2.1, it is possible to call any function defined for bracket expressions. The function is called with two (or more) strings as arguments, and it is expected that the function returns a number indicating a boolean result: 0 is considered as the false value, and a non-zero number is considered as the true value. Currently, there aren't any other functions that would make sense to be called. The user may, however, define further functions.

Regular expressions

The engine matching regular expressions is PCRE (Perl-compatible regular expressions), so the Perl syntax is used. The expressions are not anchored by default, so have to write ^ and $$ to force anchoring. ^ matches the beginning of the string, and $$ matches the end of the string ("single-line expressions"). Note that you have to write double dollars $$ because the dollar character is the escape character for template parameters.

Hints

Note that template parameters and bracket expressions within ui:if are unconditionally evaluated. See ui:cond for a discussion of the consequences of this fact.

Example

<ui:if value1="$[n]" value2="1" op="int-gt">
  The result has more than one solution: ...
</ui:if>
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml