About Arbortext Styler > Creating Conditions > Conditions Overview
  
Conditions Overview
With Arbortext Styler, you can make formatting properties conditional by assigning conditions to element contexts. This allows you to apply different formatting properties to the same element context depending on the circumstances under which the context appears. The circumstances are determined by the results of tests carried out against the content of the document to which the stylesheet applies.
A condition consists of a set of tests and an associated set of formatting properties. Tests based on the following can be included in a condition:
Attribute value of the current element or any of its ancestors
Content of the current element or any of its ancestors
XPath expressions to support more complex tests
Position of the element in an HTML chunk
When the tests specified for the context match for the context exactly as they are described, the formatting properties associated with the condition overlay the existing formatting properties given to the context itself.
The emphasis element can be used to illustrate a simple example of conditional formatting. Initially, you can format emphasis as italic in all contexts. If you want to change the formatting of emphasis from italic to bold, you can add an attribute test that checks the role attribute on the emphasis element. If role=“bold” (true), then bold formatting is applied to the font.
* 
In this case, you must explicitly turn off the italic property in the Text category for the context (set it to no) if you do not want emphasis to be formatted as bold italic.
See Working with conditions for further information.
Conditions are listed in the Elements list in Arbortext Styler, shown below the context to which they apply. Conditions are identified by the presence of the condition icon The condition icon - the yellow element icon overlaid by an A in a circle with an attached diagonal line, which changes to include a red strikethrough bar The invalid condition icon - the condition icon struck through with a red line if the condition's position relative to its siblings is invalid.
You may also use Arbortext Styler's Validate Stylesheet feature, accessed via the Tools > Validate Stylesheet menu option, to check your stylesheet. Any invalid conditions present in the stylesheet will be written to the Arbortext Styler Log.
* 
Conditions are not identified by number for the context to which they apply, simply by their type. For example, a condition previously described as #1 If attribute “arch” includes the whole word “print” will simply be shown as If attribute “arch” includes the whole word “print”.
In certain circumstances it is useful to take advantage of the ability to create If, Else If or Else conditions, and nest those conditions within one another. The format and purpose of each of these condition types is explained below:
If condition - a general condition type, made up of one or more condition tests. An If condition can either be used as an individual condition or as part of a group. In the latter case it is evaluated as the first condition of a group, with any sibling Else if and Else conditions in the group being processed as alternatives if the If condition returns false.
Else if condition - takes the same form as the If condition, with the added requirement that it must follow a sibling If or Else If condition in a group to be valid. The Else If condition is only evaluated if the sibling If or Else If conditions preceding it in a group return false.
Else condition - has no condition tests associated with it, and simply forms the final alternative to be processed when all If and Else If conditions in a group have returned false.
Groups of conditions may be arranged within the scope of another condition, in which case they are evaluated only if the parent condition has returned true. When conditions are arranged in this way they are referred as nested conditions.
Toolbar buttons allow you to move conditions with relation to other conditions in a group:
The button with which to move objects up in a list - a page of lines of which the third one is green, with an arrow on the left hand side of the page pointing upwards - move up
The button with which to move objects down in a list - a page of lines of which the third one is green, with an arrow on the left hand side of the page pointing downwards - move down
The button with which to move objects to the right in a list - a page of lines of which the second one is green, with an arrow on the left hand side of the page pointing right - increase nesting level
The button with which to move objects to the left in a list - a page of lines of which the second one is green, with an arrow on the left hand side of the page pointing left - decrease nesting level
For further information, please refer to Creating If, Else/If, and Else Conditions and Nesting Conditions.
Because Arbortext Styler applies the formatting properties of all true conditions to an element context, the order of single level conditions is important. So, for example, if an element context has two conditions that are true, and the first one specifies Arial and the second condition specifies Helvetica, Helvetica will be applied.