Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

condition elements





It is possible to specify conditions for two usages:
  • To specify that an article should be present depending on a condition
  • To specify that a block of elements in an article should be present depending on a condition
This article explains the XML tags which can be used to specify a condition.

The "condition" element allows to add conditional content depending on the presence of a package or a property.

Condition on an article

A condition on an article is specified through the articleCondition element. The article will be present in the wiki only if the condition is evaluated as true.

Condition inside an article

A condition inside an article is specified through the condition element.

A condition can be put in almost eveywhere in the source for an article, including inside table or ul or ol elements.

Structure

A condition element has the following children:
  • One mandatory "if" child containing the content to be rendered if the condition is evaluated to true
  • One optional "else" child containing the content to be rendered if the condition is evaluated to false

Conditions inside a list

A condition can contain list items. For example:
   <ul>
      <li>the first item</li>
      <condition property="prop" condition="hasProperty">
         <if>
            <li>the second item</li>
         </if>
      </condition>
   </ul>

Conditions inside a table

A condition can contain rows. For example:
   <table>
      <row>
         <cell>
            <code>name</code>
            <code>value</code>
         </cell>
      </row>
      <condition property="prop" condition="hasProperty">
         <if>
            <row>
               <cell>
                  <code>name2</code>
                  <code>value2</code>
               </cell>
            </row>
         </if>
      </condition>
   </table>

Attributes of the condition

Both articleCondition and conditionelements can have the following attributes:
  • "condition": The names of the packages for a condition on packages, or the condition type for a condition on a property
  • "property": The name or the property for a condition on a property
  • "value": The value or the property for a condition on a property"

Package condition

A package condition is evaluated to true if some specified packages are present.

This type of condition has only one attribute:
  • "condition": The name or names of the packages (separated by commas) which must all be present for the condition to be evaluated as true. For example "myPack1, myPack2" is a valid value for the condition

Property condition

A property condition is evaluated to true if a property is preent, and optionnaly has a specified value.

This type of condition has the following attributes:
  • "condition": The condition type for a property
  • "property": The name or the property which must be present for the condition to be evaluated as true. If the "value" attribute is not present, the condition will be evaluated as true if the property is present
  • "value": The value or the property which must be present for the condition to be evaluated as true. If the "value" attribute is present, the condition will be evaluated as true if the property is present and its value is equal to "value"


Note that the possible values for the condition are:
  • "equal": the property value is equal to the value
  • "noEqual": the property value is not equal to the value
  • "greater": the property value is greater than the value
  • "smaller": the property value is smaller than the value
  • "greaterOrEqual": the property value is greater or equal than the value
  • "smallerOrEqual": the property value is smaller or equal than the value
  • "hasProperty": the property exists (in that case, the value is not used)
  • "hasNotProperty": the property does not exist (in that case, the value is not used)


For a numeric property ("count", "todo", and "errors"), the conditions use the numeric comparisons. For other properties (for example "lang"), the conditions use the String comparisons.

Examples

Examples on conditions on an article

Example with "condition": the article will only be present in the wiki if "myPack" is present:
   <article desc="an article">
     <articleCondition condition="myPack" />
   The article content
   </article>
Example with "property" and "value": the article will only be present if "myProperty" exists:
   <article desc="an article">
     <articleCondition property="myProperty" />
   The article content
   </article>

Examples on conditions inside an article

Example with "condition":
   <article desc="an article">
     <condition condition="myPack">
        <if>
   The text inside the if for myPack (will be added if "myPack" is present).
        </if>
        <else>
   The text inside the else for myPack (will be added if "myPack" is absent).
        </else>
     </condition>
   </article>
Example with "property":
   <article desc="an article">
     <condition property="myProperty">
        <if>
   The text inside the if, will be added if "myProperty" exists.
        </if>
        <else>
   The text inside the else, will be added if "myProperty" does not exist.
        </else>
     </condition>
   </article>
Example with "property" and "value":
   <article desc="an article">
     <condition property="myProperty" value="true">
        <if>
   The text inside the if, will be added if "myProperty" exists and its value is "true".
        </if>
        <else>
   The text inside the else, will be added if "myProperty" does not exist or its value is not "true".
        </else>
     </condition>
   </article>
Another example with "property" and "value":
   <article desc="an article">
     <condition property="myProperty" value="true">
        <if>
   The text inside the if, will be added if "myProperty" exists and its value is "true".
        </if>
        <else>
   The text inside the else, will be added if "myProperty" does not exist or its value is not "true".
        </else>
     </condition>
   </article>

See also


Categories: syntax

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.