|
|
|
<if></if>Provided by module: Tags: RXML tags The <if> tag is used to conditionally include its contents. <else> or <elseif> can be used afterwards to include alternative content if the test is false. The tag itself is useless without its plugins. Its main functionality is to provide a framework for the plugins. It is mandatory to add a plugin as one attribute. The other provided attributes are 'and', 'or' and 'not', used for combining different plugins with logical operations. Note: Since XML mandates that tag attributes must be unique, it's not possible to use the same plugin more than once with a logical operator. E.g. this will not work:
You have to use more than one tag in such cases. The example above can be rewritten like this to work:
The If plugins are sorted according to their function into five categories: Eval, Match, State, Utils and SiteBuilder. Eval pluginsThe Eval category is the one corresponding to the regular tests made in programming languages, and perhaps the most used. They evaluate expressions containing variables, entities, strings etc and are a sort of multi-use plugins.
The tests are made up either of a single operand or two operands separated by an operator surrounded by single spaces. The value of the single or left hand operand is determined by the If plugin. If there is only a single operand then the test is successful if it has a value different from the integer 0. I.e. all string values, including the empty string "" and the string "0", make the test succeed. If there is an operator then the right hand is treated as a literal value (with some exceptions described below). Valid operators are "=", "==", "is", "!=", "<", ">", "<=", and ">=".
The three operators "=", "==" and "is" all test for equality. They can furthermore do pattern matching with the right operand. If it doesn't match the left one directly then it's interpreted as a glob pattern with "*" and "?". If it still doesn't match then it's split on "," and each part is tried as a glob pattern to see if any one matches. In a glob pattern, "*" means match zero or more arbitrary characters, and "?" means match exactly one arbitrary character. Thus "t*f??" will match "trainfoo" as well as "tfoo" but not "trainfork" or "tfo". It is not possible to use regexps together with any of the if-plugins.
Match pluginsThe Match category contains plugins that match contents of something, e.g. an IP package header, with arguments given to the plugin as a string or a list of strings.
State pluginsState plugins check which of the possible states something is in, e.g. if a flag is set or not, if something is supported or not, if something is defined or not etc.
Utils pluginsUtils are additonal plugins specialized for certain tests, e.g. date and time tests.
SiteBuilder pluginsSiteBuilder plugins requires a Roxen Platform SiteBuilder installed to work. They are adding test capabilities to web pages contained in a SiteBuilder administrated site.
Attributes
|
||||||||||||||||||