About Arbortext Styler > Creating Conditions > Working with Conditions
  
Working with Conditions
This topic describes how to create, edit, and delete a condition.
To Create a Single Condition for an Element Context
1. In Arbortext Styler, select an element context from the Elements list.
2. Choose Insert > Condition to display the Condition dialog box. The selected context displays in the read-only Condition for field.
3. Click one of the New... buttons to open the required dialog box:
New Attribute Test: opens the New Attribute Test dialog box with the name of the selected element in the Current Element field
New Content Test: opens the New Content Test dialog box with the name of the selected element in the Current Element field
New XPath Test: opens the New XPath Test dialog box
New Chunk Test: opens the Start of HTML Chunk Test dialog box
* 
Start of HTML chunk tests should only be created for conditions that are intended to apply properties in chunked HTML outputs (EPUB, HTML Help, and Web). Tests of this nature will return a value of false in conditions specified for Arbortext Editor, print/PDF, HTML File or RTF outputs.
4. Create the required test and click OK from within the relevant dialog box to save the change. A description of that test will be added to the list of tests in the Tests: field of the Condition dialog box.
5. Repeat steps 3 and 4 as required, if you wish to create multiple tests for the condition.
6. If you have created more than one test, choose either All tests are true (AND) or Any test is true (OR) to confirm how many if the tests must match for the condition to be true. If you select All tests are true, Arbortext Styler will only apply the condition's associated formatting properties when all the tests in the Tests list are true. If you select Any test is true, Arbortext Styler applies the condition's formatting properties if at least one test in the Tests list is true.
7. Click OK when you have finished creating tests to save your changes and exit the Condition dialog box.
8. The condition is listed under the context’s name in the Elements list, for example If attribute “arch” is not assigned any value.
To Edit a Condition
1. In Arbortext Styler, choose the condition you want to edit from the Elements list.
2. Choose Edit > Edit Condition to open the Condition dialog box.
3. Select the test you want to edit from the Tests: list and click Edit.
4. Edit the test as necessary, and click OK when you are finished.
5. Click OK when you have finished creating tests to save your changes and exit the Condition dialog box.
To Delete a Condition
1. In Arbortext Styler, choose the condition you want to delete from the Elements list, and select the Edit > Delete menu option.
* 
You can select multiple conditions for deletion.
2. A message displays to confirm that you want to delete the selected item. Choose Yes to delete the condition.
To Delete a Test from a Condition
1. In Arbortext Styler, choose from the Elements list the condition whose test you want to delete, then click Edit > Edit Condition.
2. In the Tests list, select the test you want to delete and click DELETE. Repeat this process for each test you want to delete.
* 
You will not be prompted to confirm the deletion.
You cannot delete all tests in a condition. You must have a least one test in a condition to close the Condition dialog box.
3. Click OK when you have finished deleting tests to save your changes and exit the Condition dialog box.
Example: Formatting a Block Indent Using a Condition
The following example describes how to apply left and right indents (a block indent) using a condition. You can add left, right, hanging, and block indent formatting to block styled elements (note: indent formatting is not permitted for elements styled as inline, i.e. where the Structure type option in the Breaks category is set to Inline).
* 
If an element configured in the DTD or schema to have the xml:space=”preserve” attribute set is added to the stylesheet during either a New Stylesheet operation, or by choosing Insert > Add Elements from document or Doctype, its style will be set automatically to Preformatted. Arbortext Styler will not allow the style to be changed. When an element’s style is Preformatted, it has a value of Preformatted for the Alignment field in the Indent category and you will not be able to change this setting.
1. Open the transport.xml document located at Arbortext-path/samples/styler.
2. Choose File > Save As to create a local copy of transport.xml.
3. 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.
4. In Arbortext Editor, click in the para element within the abstract element, and choose Edit > Modify Attributes.
5. Type block in the role field, and then click OK. Note that the para element now has a role=”block” attribute.
6. In Arbortext Styler, select the para everywhere else context, and then choose Insert > Condition.
7. In the New Condition dialog box, click New Attribute Test to open the New Attribute Test dialog box.
8. Make the following settings in the dialog box:
Test attribute of: Current element
Attribute name: role
Attribute value: Comparison = block
9. Click OK, and then click OK in the Condition dialog box.
Note that the para everywhere else context now has the following condition: If attribute “role” = “block”.
10. Select the condition you just created in the Elements list, and go to the Indent category.
11. Set Alignment to Left if it isn't already set.
12. Set Left to 2.00in, and set Relative to to Left margin.
13. Set Right to 2.00in, and set Relative to to Right margin.
14. Choose Preview > Print.
15. In the Print Preview window, note that only the content of the para element within the abstract element is indented from both the right and the left sides. All other para elements are not indented because they did not meet the condition role=”block”.