About Arbortext Styler > Arbortext Styler Dialog Boxes > Context Dialog Box
Context Dialog Box
The Context dialog box opens when you choose to create a new condition via the Insert > Context menu option, or edit an existing condition by choosing the Edit > Edit Context menu option. The title of the dialog box will be either New Context or Edit Context, depending on which operation you used to invoke it. Use the options in this dialog box to create or edit a context for the element selected in the Elements list.
The Context dialog box contains the following options:
Element: elementname - Displays a read-only description of the context. The associated window lists the selected element, along with any ancestors or parents that have been selected.
New Ancestor - Allows you to specify that the element to which the context applies must occur inside a specific ancestor, which you choose from a list of valid ancestor elements. The ancestor can occur at any level (parent, grandparent, great-grandparent and so on). An asterisk wildcard is inserted between the element and the new ancestor to represent that any number of levels can occur between the two. This allows you to create a context that formats the selected element any time it is found within the ancestor element.
For example, if para is the element for which you are creating a context, and table is the ancestor element, the resulting context is para anywhere in table. The formatting for this context is applied to any para element within a table element, including both of the following situations:
New Parent - Enables you to specify that the element selected in the Context window must occur immediately within another element, which you choose from a list of valid parent elements. For example, if you are creating a context for title, and you select chapter as the parent element, the resulting context (title in chapter) only applies to title elements whose parent element is chapter:
The title in chapter context does not apply to the following hierarchy because section, not chapter, is the parent element of title:
Edit - Enables you to change the selected ancestor, parent, or wildcard. When you highlight the ancestor, parent, or wildcard and select Edit, a dropdown menu appears containing elements from your document. Select a new ancestor or parent from the menu. You can also edit the highlighted element directly.
Delete - Removes the selected ancestor, parent, or wildcard. You cannot remove the element for which you are creating the context.
Position - Specifies the position of an element in the context relative to sibling elements of the same type. Highlight the element in the context hierarchy to which the position should apply, then select one of the following options:
any (the default)
not first
not last
not first or last
XPath Predicate - Opens the XPath Predicate dialog box, in which you can specify an XPath expression to test for an attribute.
If you enter the name of a namespaced element in the XPath Predicate dialog box, you will not be prompted to declare the namespace if it does not already exist. Ensure you have declared the namespace for the stylesheet by creating an element with the applicable prefix, or the XPath expression you enter in this field will not be valid
Edit predicate - This button is enabled when the position of a selected context is defined via an XPath predicate. Clicking the button opens the XPath Predicate dialog box, in which you can modify the predicate.
At start of HTML chunk - When selected, this option indicates that an element is the first element in an HTML chunk. Highlight the element in the context hierarchy to which the position should apply, then select the option.
At top level of document - When selected, this option indicates that the element is the top-level element in the document.
Select this option when an element sometimes (but not always) occurs as the top level element of the document.
If the element is always used as the top level element in documents, it is preferable to apply the Document style to the element rather than use this option. See the description of the Document style in Applying Styles for further information.
It is important that the top level element in the document instance is either given the Document style or has a context where At top level of document is checked. If the outermost element of a document instance is not so styled, publishing may fail.
Include in ancestor and parent lists - Contains options by which you can specify that User Formatting Elements and/or Styler Formatting Elements are included in the lists of valid ancestors and parents. Refer to Elements Overview for more information on elements of these types.
You may encounter anomalies in the display of a context defined using an XPath predicate, or a position qualifier other than “any” on a parent or ancestor, if you are publishing with FOSI. If the source element is subsequently declared in the generated text of another element, any context(s) defined using the methods described will not be included in the FOSI output. You will be presented with a warning message. To overcome this, use one of the alternatives:
Context with XPath predicate: include the XPath test in a condition of the original element, rather than a context.
Create special contexts for the cases where the element occurs in generated text. These contexts should not use XPath or position qualifiers on parents or ancestors, and should be placed above contexts that do in the Elements list.
For example, you could define a table element with three contexts, each one of which uses an XPath predicate to set the font size of the table content based on the value of the pgwide attribute of the table (for example, the context table[@pgwide=90]) You might then decide that you want the title of your book to include a table, and set the generated text of the title in book context to always output a table, based on the Insert > Markup > table menu option. If you then publish your document for print via FOSI you will see warning messages advising you that each of the contexts that contain the XPath predicate will be ignored for the table output in the title of book context, for example:
[A31450] ERROR: Cannot evaluate XPath expression in stylesheet.
An XPath Predicate is used in a Styler context for an element
that occurs in generated text. (The predicate may have been
generated by Styler to represent a position qualifier on a parent
or ancestor.) This context will be ignored in FOSI-based outputs.

Element: table. XPath expression: table[@pgwide=90].
To overcome this anomaly, create conditions based on XPath tests for the table, rather than contexts. For example, the condition If XPath expression (@pgwide=90) is true for the table will provide the same output for the table based on the pgwide attribute, but will not cause errors when publishing when the table is used in generated text for the title of the book.
In both cases, however, if the context with the XPath predicate or the position qualifier is not the one that should be output in the generated text anyway, and its omission by FOSI has no bearing on the required output of your document, you may simply ignore the error message.