About Arbortext Styler > Creating Conditions > Nesting Conditions
  
Nesting Conditions
This topic section describes how to build a set of nested conditions, providing an example of an instance in which nested conditions could be used.
Suppose you have a list whose constituent elements include the following attributes (note that these elements and their attributes are included in the axdocbook doctype):
itemizedlist element:
attribute role - possible values large and small specify whether the list should be indented by 0pt or 24pt, respectively. If the value of role is not specified, its value defaults to small and all the list items are indented by the measure specified for small, i.e. 0pt
attribute mark - possible values arrow and number specify whether the entries in the list should be marked with an arrow character or numbered, respectively.
listitem element:
attribute override - if set, overrides the list marker set for list entries by the mark attribute on itemizedlist. If the attribute is not set, the list marker for the entry defaults to the symbol specified by the mark attribute on itemizedlist.
If neither the mark attribute on the itemizedlist element nor the override attribute on the listitem element have been specified, the list entries should be displayed in red text and marked with an asterisk. In this way the document writer can identify when the list item has not had an important attribute specified.
Using the available attributes to create single, flat conditions would involve the creation of maintenance of 12 conditions and 33 tests to ensure all possible attribute combinations are captured. With nested If, Else If and Else conditions, however, the combinations can be managed in ten conditions and eight tests:
If the role attribute on itemizedlist is set to small, or has no value, draw list entries with an indent of 0pt
1. When condition 1 applies, and the override attribute on a listitem element has any value, use the value of override as the list item marker and draw the list entry with an indent of 0pt
2. When condition 1 applies, and the mark attribute has a value of arrow, mark the list item with a arrow and draw it with an indent of 0pt
3. When condition 1 applies, and the mark attribute has a value of number, mark the list item with a number and draw it with an indent of 0pt
4. When condition 1 applies, and the override or mark attributes have not been specified, mark the list item with an asterisk and draw it in red text with an indent of 0pt
If the role attribute on itemizedlist is set to large, draw list entries with an indent of 24pt
1. When condition 2 applies, and the override attribute on a listitem element has any value, use the value of override as the list item marker and draw list entry with an indent of 24pt
2. When condition 2 applies, and the mark attribute has a value of arrow, mark the list item with a arrow and draw it with an indent of 24pt
3. When condition 2 applies, and the mark attribute has a value of number, mark the list item with a number and draw it with an indent of 24pt
4. When condition 2 applies, and the override or mark attributes have not been specified, mark the list item with an asterisk and draw it in red text with an indent of 24pt
To create these conditions, follow the steps detailed below. Note that all conditions are created for the listitem in itemizedlist context.
Example: Creating Nesting Conditions
1. In Arbortext Editor, open the file transport.xml located at Arbortext-path/samples/styler.
2. Choose Styler > Edit Stylesheet to open the associated stylesheet for edit. This is a read only stylesheet so you will need to save a local copy if you want to make amendments.
3. Locate the itemizedlist element in the Elements list - note that is of the style List-Bulleted, which outputs its list entries with a bullet marker at a set indent. We will override these defaults with the conditional formatting for the list items in the list.
4. Locate the listitem in itemizedlist context in the Elements list.
5. Choose Insert > Condition to create a new condition for the context. The New Condition dialog box opens. Ensure that If is selected in the Condition type field.
6. Click the New Attribute Test button. The New Attribute Test dialog box opens.
7. Elect to test the attribute of the Ancestor of the current element, and select itemizedlist from the dropdown menu.
8. Select role from the Attribute name drop down menu, and set the Attribute value field to match Comparison=small.
9. Click OK to save the test and exit the dialog box. The test now appears in the Tests area of the New Condition dialog box.
10. Click the New Attribute Test button again, to create a new test in the New Attribute Test dialog box.
11. Elect to test the attribute of the Ancestor of the current element, and select itemizedlist from the dropdown menu.
12. Select role from the Attribute name drop down menu, and set the Attribute value field to match Not assigned any value.
13. Click OK to save the test and exit the dialog box. The test now appears in the Tests area of the New Condition dialog box, separated from the previous test by the word “AND”.
14. In the Condition is true if field, select Any test is true. The two tests are now separated by the word “OR”, indicating that a particular set of formatting properties should be applied if either of these tests return true.
This is an image of the Edit Condition dialog box, showing the two tests in an OR arrangement
15. Click OK to save the condition and exit the dialog box. The condition is now displayed for the listitem in itemizedlist context in the Elements list, described as If attribute “role” of element “itemizedlist”=”small” or attribute “role” of element “itemizedlist” is not assigned any value.
16. Navigate to the Generated text category to set the formatting properties for this condition. Leave the Numbers and Bullets option set to Bullet. Click the Details button to open the Bullet dialog box, in which you can set the default indent for the list.
17. Set the bullet to indent at 0pt, then set the text following the bullet to tab to 16pt. Specify that following lines should indent to 16pt.
18. Click OK to save the formatting properties and exit the dialog box.
19. Choose Insert > Condition to create the next condition.
20. In the New Condition dialog box, ensure that If is selected in the Condition type field. Elect to create a new attribute test.
21. Elect to test the attribute of the current element, and select override from the Attribute name dropdown menu.
22. Set the Attribute value field to match Assigned any value.
23. Click OK to save the test and exit the dialog box. The test now appears in the Tests area of the New Condition dialog box.
24. Click OK to save the condition and exit the dialog box. The condition is now displayed for the listitem in itemizedlist context in the Elements list, described as If attribute “override” is assigned any value.
25. Navigate to the Generated text category to set the formatting properties for this condition. Set the Numbers and Bullets option set to None. Move to the Add-before field, and click the Edit button to open the Generated Text Editor. Since you are creating a non-default marker for the list entry, you must set the marker and the following space via generated text.
26. Choose InsertAttribute Content. The Insert Attribute Content dialog box opens.
27. Select (Current Element) from the Element drop down list, and override from the Attribute to insert menu. Here you have specified that when the override attribute is present, its value should be used as the marker for the list item for which it is set.
28. Still in the Generated Text Editor, choose Insert > Leaders, Rule or Space. The Insert Leaders, Rule or Space dialog box opens.
29. Select Space in the Type field, then set a Specified Length of 12pt.
30. Click OK to save the settings and exit the dialog box.
31. Click OK to save the gentext settings and exit the Generated Text Editor.
32. Navigate to the Indent category to set the indent for the list entry - since you have created a non-default marker for the entry you cannot use the Bullet dialog box to set the indent.
33. Set the Alignment field to Left, the Left Indentation to 16pt relative to its Parent left indent, and the First Line Indentation to 0pt relative to its Parent first line indent.
This is an image of the Indent category for the selected condition of the listitem in itemizedlist element, showing the suggested left indent settings
34. Choose Insert > Condition to create the next condition.
35. In the New Condition dialog box, ensure that Else if is selected in the Condition type field. Elect to create a new attribute test.
36. Elect to test the attribute of the Ancestor of the current element, and select itemizedlist from the dropdown menu.
37. Select mark from the Attribute name drop down menu, and set the Attribute value field to match Comparison=arrow.
38. Click OK to save the test and exit the dialog box. The test now appears in the Tests area of the New Condition dialog box.
39. Click OK to save the condition and exit the dialog box. The condition is now displayed for the listitem in itemizedlist context in the Elements list, described as Else if attribute "mark” of element “itemizedlist”=”arrow”.
40. Navigate to the Generated text category to set the formatting properties for this condition. Leave the Numbers and Bullets option set to Bullet. Click the Details button to open the Bullet dialog box, in which you can set the default indent and bullet character for the list item.
41. Set the bullet character to an arrow, by selecting it from the Insert Symbol dialog box that appears when you click the Character button.
42. Set the bullet to indent at 0pt, then set the text following the bullet to tab to 16pt. Specify that following lines should indent to 16pt.
43. Click OK to save the formatting properties and exit the dialog box.
44. Choose Insert > Condition to create the next condition.
45. In the New Condition dialog box, ensure that Else if is selected in the Condition type field. Elect to create a new attribute test.
46. Elect to test the attribute of the Ancestor of the current element, and select itemizedlist from the dropdown menu.
47. Select mark from the Attribute name drop down menu, and set the Attribute value field to match Comparison=number.
48. Click OK to save the test and exit the dialog box. The test now appears in the Tests area of the New Condition dialog box.
49. Click OK to save the condition and exit the dialog box. The condition is now displayed for the listitem in itemizedlist context in the Elements list, described as Else if attribute "mark” of element “itemizedlist”=”number”.
50. Navigate to the Generated text category to set the formatting properties for this condition. Set the Numbers and Bullets option to Number. Click the Details button to open the List Item Number dialog box, in which you can set the default indent and numbering for the list item.
51. Leave the default numbering style as shown.
52. Set the number to align to the left and indent at 0pt, then set the text following the number to tab to 16pt. Specify that following lines should indent to 16pt.
53. Click OK to save the formatting properties and exit the dialog box.
54. Choose Insert > Condition to create the next condition.
55. In the New Condition dialog box, ensure that Else is selected in the Condition type field. All options in the New Condition dialog box are disabled, since the formatting properties for this condition apply in all other cases and as such do not need tests to verify a match.
56. Click OK to save the test and exit the dialog box. The test now appears in the Tests area of the New Condition dialog box.
57. Click OK to save the condition and exit the dialog box. The condition is now displayed for the listitem in itemizedlist context in the Elements list, described as Else.
58. Navigate to the Generated text category to set the formatting properties for this condition. Leave the Numbers and Bullets option set to Bullet. Click the Details button to open the Bullet dialog box, in which you can set the default indent and bullet character for the list item.
59. Set the bullet character to an asterisk, by selecting it from the Insert Symbol dialog box that appears when you click the Character button.
60. Set the bullet to indent at 0pt, then set the text following the bullet to tab to 16pt. Specify that following lines should indent to 16pt.
61. Navigate to the Text category and set the Text color field to Red.
62. Click OK to save the formatting properties and exit the dialog box.
63. You now have five sibling conditions for the listitem in itemizedlist context, as shown below:
This is an image of the listitem in itemizedlist element in the window, displaying its 5 sibling conditions all on the same level
If you wish to group the conditions so their formatting properties are only applied when a particular combination of attributes is encountered, nest some of the conditions as shown in the next step. The steps show how to nest the conditions relating to the override and mark attributes within a group whose matching capability is led by the presence of the role=small or no value.
64. Highlight conditions 2–5 in the above list, and click the Increase Level toolbar button 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 rightwards. You will see that the selected conditions are moved one place to the right in the Elements list, thus making them child conditions of the condition If attribute “role” of element “itemizedlist”=”small” or attribute “role” of element “itemizedlist” is not assigned any value”.
This is an image of the listitem in itemizedlist element in the window, displaying conditions 2–5 as children of condition 1
Now conditions 2–5 will only be matched once condition 1 has been matched.
65. The next step is to create another group of conditions, with the difference that its matching capability is led by the presence of the role=”large” attribute. To accomplish this, repeat steps 4–64 to set up conditions as defined in the list below:
1) Else if attribute “role” of element “itemizedlist”=”large”
1.1) If attribute “override” is assigned any value
1.2) Else if attribute “mark” of element “itemizedlist”=”arrow”
1.3) Else if attribute “mark” of element “itemizedlist”=”number”
1.4) Else
Note that condition 1 should be an Else If condition, rather than If as in the first set, to indicate that it is an alternative if the first condition in the first set does not match.
Use all the same settings for these conditions as you used in the other set, the only change being the size of the indent applied under each of the conditions. Set the bullet to indent at 24pt, then set the text following the bullet to tab to 40pt. Specify that following lines should indent to 40pt.
66. You now have two groups of conditions, as shown below:
This is an image of the listitem in itemizedlist element in the window, displaying its 10 conditions in two groups of five nested conditions
67. A summary of the conditions you have created and the associated formatting properties they apply is shown below:
if role = small or role has no value
if override has value
use value of override for marker and small indent for
list entry
else if mark=arrow
use arrow marker and small indent for list entry
else if mark=number
use number marker and small indent for list entry
else
use asterisk marker, red text and small indent for
list entry
else if role =large
if override has value
use value of override for marker and large indent for
list entry
else if mark=arrow
use arrow marker and large indent for list entry
else if mark=number
use number marker and large indent for list entry
else
use asterisk marker, red text and large indent for
list entry