Rules Editor Home | Documentation Home | Stilo
Guide to
Migrate 5.0.0 Rules Editor
Stilo
Context Annotations
Syntax
set-context(class=class;label=label;depth=depth)
class
arbitrary class name used to distinguish different contexts tracked
label
a label to apply to the new entry of a context
depth
the depth of the new entry of a context
clear-context(class=class;depth=depth)
class
name of the class you wish to clear
depth (optional)
the depth to which to clear the context
Purpose

The context tracking annotation may be used to track arbitrary contextual information about your document. The Migrate conversion does not use this annotation, but you can set context and then test it from other rules to help get annotations applied correctly.

The depth argument allows more than one piece (i.e. label) of context to be tracked for a given class. It is optional on clear-context. If no depth is specified, the entire context is cleared. But, if a depth is a specied, only the labels specified at a greater depth are removed.

Tracking Topic Types

For example, you might simply want to keep track of the current topic type, as this may affect the logic of your rules. For this, you can:

  • create a context tracking class called topic type,
  • apply labels which are topic types (e.g. concept, task, or reference),
  • and set the depth to the nesting depth of the topic.

By setting the depth, the context tracker will remember the outermost topic types when an inner topic type is started. When a new topic begins, clear the context, but only to the depth of the new topic. This will clear the tracking of the context for inner topics that are not complete. You can now also set a new tracking entry for the topic that is just beginning.