api:equals
Version 25.3.9411
Version 25.3.9411
api:equals
Use the api:equals keyword to compare the value of an attribute to a reference value. Unlike api:check, api:equals throws an exception if the specified item does not contain the specified attribute. If the specified attribute exists and its value matches, the comparison succeeds.
Note: Both api:equals and api:check expect the name of the attribute whose value should be compared with a given value. To compare two values, use api:select instead. For example:
<api:select value="[company_name]">
<api:case value="CompanyA">
<img src="http://www.companya.com/favicon.ico" />
</api:case>
<api:case value="CompanyB">
<img src="http://www.companyb.com/favicon.ico" />
</api:case>
<api:default>
<img src="http://www.myhosting.com/generic.ico"/>
</api:default>
</api:select>
Parameters
- item: The item in which to compare the attribute. If no item is specified, the default output item is used.
- attr: The name of the attribute to compare.
- case: Whether to use case-sensitive or case-insensitive comparison. The default is case-sensitive comparison; to use case-insensitive comparison, set this to
ignore. - value: The value to compare the attribute with.
- action: The action to perform if equality is met. Allowed values:
break,continue.
Control Attributes
None
Example
Like other conditional keywords, the body of api:equals can also contain an api:else keyword, which is executed if the values do not match. This example lists all files except .err files:
<api:call op="fileListDir">
<api:equals attr="file:extension" value=".err">
<api:else>
<api:push/>
</api:else>
</api:equals>
</api:call>
See Also
- api:select: Choose between more than one alternative.
- api:notequals: Create a block that is executed when equality is not met.