Advanced bidi support

There are many properties that you can set to enable bidirectional support in documents.

Bidi properties in the templates

Some of the template elements have the direction property. The value of this property can be set to ltr (left-to-right), rtl(right-to-left), contextual or empty (the default setting). If the value of this property is empty, the direction of the corresponding element is inherited or has a default for the current document value.

The following template elements have the direction property:
  • Container, Paragraph, Table Cell, List Item: The property affects each logical paragraph of the text, for which the direction is not explicitly defined.
  • Table : The property defines the way of displaying columns (from left to right or in the opposite direction) and affects each cell, for which the direction is not explicitly defined.
  • List: The property affects each list item for which the direction is not explicitly defined.
  • Text: The property affects the content of the current element only. It cannot be inherited from or by other elements.

You can set the direction property from the Properties view in Document Studio.

Direction property set in the Properties view

Bidi properties in the document specifications

The following bidi-specific properties of the runtime metadata are used to control layout of the generated document and base direction of its text contents.

Type Value Description
bidi true, false (default) Used as a trigger to switch on or off bidi-specific functionality.
document direction ltr, rtl Defines the layout of the document. If both document direction and output locale metadata properties are empty, document direction is set to ltr.If document direction is empty, its actual runtime value depends on the value of output locale property. For bidi locales this is rtl. For other locales this is ltr.
text direction ltr, rtl, contextual,empty (default) Defines the base text direction.empty means that the default text direction is the same as the document direction.

In Launcher, you can set properties by the Properties view or by the Configure Metadata Properties window:

Setting bidi properties in the Properties view for document specifications

Bidi properties can be referenced from Rational® Publishing Engine templates using the internal variable _sessionInfo:

Session info in a script expression

From the products which use the built-in RRDG engine, bidi properties can be set programmatically. For example, in case of Rational DOORS® Next Generation, we can have something like this:
LocalDocumentGenerator docGen = new LocalDocumentGenerator(new RRDGEngineImpl());
    String config = docGen.getConfigurationPath(configFolder.toURI());
    DocumentSpecificationBuilder builder = new DocumentSpecificationBuilder();
    RPEDocumentSpecification docSpec = builder.create(config);
    RPEMetadata metadata = docSpec.getRuntime().getMetadata();
    metadata.addProperty(new Property(RPEConfigConstants.PROPERTY_DOCUMENT_DIRECTION, new Value("","rtl"));
Note: The previous version of Rational Publishing Engine used the bidi property of the Microsoft Word output to switch on or off bidi-specific functionality. This property is no longer supported, although it is still shown in the Word Output Properties view.

Determining elements and base text direction of their contents at runtime

The direction of the element specifies alignment, layout and the base text direction of its contents.

Container ,Paragraph, Table ,Table Cell, List and List Item have their own direction property. If the value of this property is empty, the actual direction of the corresponding element is inherited from the closest ascendant, having a non-empty direction property. If it turns out that there is nothing to inherit, the direction of element is defined by the document direction property of the document.

If Container ,Paragraph, Table ,Table Cell, List or List Item have their own or inherited contextual direction property, the actual direction of these elements is determined by their text contents. However, if this is not possible (either the text is not placed into the current element directly or it contains neutral characters only), the actual direction is inherited from the closest ascendant, having a non-empty and non-contextual direction property. If it turns out that there is nothing to inherit, the direction of element is defined by the text direction property of the document.

If Container ,Paragraph, Table ,Table Cell, List or List Item have a Text element with a non-empty direction property as their first direct child, the actual direction of such elements is determined from the resolved direction of this Text element.

If Table or List have their own or inherited contextual direction property, the actual direction of these elements is inherited from the closest ascendant, having a non-empty and non-contextual direction property. If it turns out that there is nothing to inherit, the direction of the element is defined by the document direction property of the document.

If the direction of the Text element is not empty, the contents of this element (which can be only the part of the logical paragraph) appear in the generated document as an isolated segment of the text, formatted in accordance with this property. If the Text element has its own contextual direction property, the base direction of the corresponding text segment is determined from its contents. If the text segment contains only neutral characters, the base text direction is defined by the text direction property of the document.

The direction of Table Of Contents, Table Of Tables and Table Of Figures is defined by the document direction property of the document. It specifies their layout (for example, the relative positions of the section numbers, their names and page numbers) only. Text in the names of a section, for any direction of these elements, should look the same as it appears in the body of the document.

The direction of Table Caption and Figure Caption is defined by the document direction property of the document. It specifies their layout (for example, the relative positions of the labels and contents). The base text direction of each part of captions is defined by the text direction property of the document.

The direction of Footnote is defined by the document direction property of the document. It specifies the layout of the contents (for example, the relative positions of the footnote number, its contents and their alignment). The base text direction of the footnote's contents is defined by the text direction property of the document.

The direction of Comment is undefined. The base text direction of its contents is defined by the text direction property of the document.

The direction of Header and Footer is defined by the document direction property of the document.

Handling Rich Text (XHTML)

The contents of the Text element can be presented by XHTML fragments. These fragments are parsed and handled as collections of template elements:
  • P, H1-H6 - as paragraphs with different styles
  • DIV - as Container
  • TABLE - as Table
  • TD - as Table Cell
  • OL,UL - as Lists
  • LI - as List Item

The values of style direction and attribute dir found in the block-level html elements such as P, DIV, H1-H6, LI, TD, as well as in the TABLE, OL and UL, are recognized and converted into the Rational Publishing Engine formatting property direction. If both the style and attribute are defined for the current html element, the value of dir is used.Set content for current element

The contents of block-level html elements are handled as a sequence of text elements with different styles. You can use html SPAN elements with the style direction. These SPAN elements are handled as a text element having the style direction property. (However, these elements should not contain any additional markup inside. SPAN elements with additional markup are not supported and might cause unexpected results.)


Feedback