Contains Element Test

1 min read

The elements presented in the content panel are quite flat, but there is a certain amount of nesting possible. For example, a span element may appear within a paragraph element or nested within another span element. Sometimes, this nesting is significant in correctly identifying content to convert.

The contains element test allows for a nested element to be tested. Thus, your rule can test outer and nested elements in combination. As well, your rule can place annotations on either the outer element or the nested elements. Be default, annotations are placed on the outer elements, but you can provide a label for the nested element, and place the annotation on them explicitly.

Example: contains element test

The following rule attempts to identify content that should be tagged as uicontrol. It is not enough for the term to be bold in the input document. However, bold text found in a paragraph styled as Step is determined to reliably identify a uicontrol.

contains element test

Example: annotating both the inner and outer elements

The following applies an annotation to the paragraph as well as the nested span.

We want the paragraph to be annotated as a step regardless of whether or not there happen to be any uicontrols. So we need to make sure that the entire test does not fail because the contains element test fails. That is, we don’t really care whether the contains element test evalutes to true or false. That’s why we have placed the contains element test under a logical or-group that include the literal true. This is a common idiom that you may find useful in your rules.