The @dir attribute

The @dir attribute provides instructions to processors about how bi-directional text should be rendered.

Bi-directional text is text that contains text in both text directionalities, right-to-left (RTL) and left-to-right (LTR). For example, languages such as Arabic, Hebrew, Farsi, Urdu, and Yiddish have text written from right-to-left; however, numerics and embedded sections of Western language text are written from left to right. Some multilingual documents also contain a mixture of text segments in two directions.

DITA contains the following attributes that have an effect on bi-directional text processing:
@xml:lang
Identifies the language and locale, and so can be used to identify text that requires bi-directional rendering.
@dir
Identifies or overrides the text directionality. It can be set to "ltr", "rtl", "lro", or "rlo"

In general, properly-written mixed text does not need any special markers; the Unicode bidirectional algorithm positions the punctuation correctly for a given language. The processor is responsible for displaying the text properly. However, some rendering systems might need directions for displaying bidirectional text, such as Arabic, properly. For example, Apache FOP might not render Arabic properly unless the left-to-right and right-to-left indicators are used.

The use of the @dir attribute and the Unicode algorithm is explained in the article Specifying the direction of text and tables: the dir attribute (http://www.w3.org/TR/html4/struct/dirlang.html#h-8.2) . This article contains several examples of how to use the @dir attribute set to either "ltr" or "rtl". There is no example of setting the @dir attribute to either "lro" or "rlo", although it can be inferred from the example that uses the <bdo> element, a now-deprecated W3C mechanism for overriding the entire Unicode bidirectional algorithm.

Processing expectations

Applications that process DITA documents, whether at the authoring, translation, publishing, or any other stage, SHOULD fully support the Unicode bidirectional algorithm to correctly implement the script and directionality for each language that is used in the document.

Applications SHOULD ensure that the root element in every topic document and the root element in the root map has values for the @dir and @xml:lang attributes.