About Arbortext Styler > Creating Contexts > Contexts Walk-Through
  
Contexts Walk-Through
This example walks you through the steps to create and modify a context.
Example: Working with Contexts
1. In Arbortext Editor, 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 > New Stylesheet.
4. In the Elements list, locate the para element. If need be, give it a Paragraph style from the Style list, accessed via the Edit > Style menu option.
5. Highlight the para element and choose Insert > Context.
6. In the Context dialog box, click New parent and select abstract from the drop down list as the parent element.
7. Click OK to save the context and exit the Context dialog box. The para element now includes the context para in abstract. Any formatting properties you specify for the para in abstract context are applied to a para element only when it is the child element of an abstract element.
8. With the para in abstract context selected, specify the following settings in the Text category:
Font size: 10
Italic: Yes
Text color: Red
9. Choose Preview > Arbortext Editor.
10. In Arbortext Editor, scroll to the top of the document and note that the content of the para element within the abstract element now displays in 10 point, red, italic text.
11. In Arbortext Editor, click in the para within the abstract element.
In Arbortext Styler, note that the para in abstract context is selected and the icon for the context is green and has an Arbortext logo. This indicates that the context has been selected in Arbortext Editor.
12. With the para in abstract context selected, choose Edit > Edit Context.
13. Select the abstract parent and click Delete. note that the context in the window changes back to para everywhere else.
14. Click New ancestor then select chapter. chapter now displays as the first element in the Context window, followed by an asterisk, which is a wildcard character. The asterisk indicates that the context applies to para elements anywhere within a chapter element.
15. Click OK to save the change and exit the Context dialog box. The para element now includes the context para anywhere in chapter.
16. Choose Preview > Arbortext Editor.
17. In Arbortext Editor, scroll to the top of the document and note that the content of the para element within the abstract element is no longer red and italic. The formatting of this para element is now obtained from Arbortext Styler default settings.
Scroll further down in the document, and note that the content of para elements within chapter elements displays in red, 10 point, italic text. Also note that the content of primary index terms within para elements within chapter elements displays in red, 10 point, italic text. The primary index term derives its formatting from the para anywhere in chapter context.
18. In Arbortext Styler, select the para anywhere in chapter context then choose Edit > Edit Context.
19. In the Context dialog box, select the asterisk (*) then click Delete. By deleting the asterisk, the chapter element becomes the parent of the para element.
20. Still in the Context dialog box, click on para then select first from the Position list. Note that the description field at the top of the window now says first para in chapter.
21. Click OK to save your change and exit the Context dialog box. The para element now includes the context first para in chapter. Any formatting you specify for this context applies only to the first para element within a chapter element.
22. Choose Preview > Arbortext Editor.
23. In Arbortext Editor, scroll through the document and note that only the content of the first para element within a chapter element displays in 10 point, red, italic text. All other para elements obtain their formatting from Arbortext Styler defaults.
24. In Arbortext Styler, select the listitem in itemizedlist context then choose Edit > Edit Context.
25. In the Context dialog box, click on listitem then select XPath Predicate from the Position list.
26. Type @userlevel in the XPath Predicate dialog box then click OK to save the predicate. Click OK again to save the change to the context and exit the Context dialog box. This creates the listitem[@userlevel] in itemizedlist context. Any formatting you specify for this context is applied only to listitem elements that have a userlevel attribute.
27. With the listitem[@userlevel] in itemizedlist context selected, specify the following settings in the Text category:
Font size: 20
Text color: Lime green
28. Choose Preview > Arbortext Editor.
29. In Arbortext Editor, scroll through the document and note that only one para element in the document is lime green — the only one that is nested within a listitem and has a userlevel attribute specified. The para therefore obtains its formatting from the listitem[@userlevel] in itemizedlist context. Formatting for all other para elements in the document is obtained from Arbortext Styler defaults.
30. In Arbortext Styler, select the para element then choose Insert > Context.
31. In the Context dialog box, click New parent then choose listitem from the drop down list. The context description changes to para in listitem.
32. Click New ancestor then choose chapter from the drop down list. The context description changes to para in listitem anywhere in chapter.
33. Click OK to save the new context and exit the Context dialog box. The context para in listitem anywhere in chapter is added as the first context in the list of para contexts because it is the most specific of all the configured contexts.
34. With the para in listitem anywhere in chapter context selected, specify the following settings in the Text category:
Font size: 16
Text color: Yellow
Underline: Yes
35. Choose Preview > Arbortext Editor.
36. In Arbortext Editor, scroll through the document and note that the content of all para elements within listitem elements display in 16 point, yellow , underlined text.
37. In Arbortext Styler, select the para in listitem anywhere in chapter context, and choose Edit > Delete. the context is deleted from the list of contexts for the para element.
38. With the para element still selected, choose Insert > Context.
39. Click New parent then choose listitem from the drop down list.
40. Click OK to save the new context and exit the Context dialog box. The para element now includes the context para in listitem.
41. With the para in listitem context selected, specify the following settings in the Text category:
Font size: 16
Text color: Orange
42. Choose Preview > Arbortext Editor.
43. In Arbortext Editor, scroll through the document and note that the content of all para elements within listitem elements no longer display in 16 point, yellow, underlined text. Note that in fact they are also not shown in orange text, as you would expect by the presence of the para in listitem context. This is the result of context priorities - examine the list of contexts for the para element and note that there are contexts with higher priorities than this one for para elements in listitem elements. It is these contexts that will lend their formatting to any paragraphs that appear in a list item.