9.1. HTMLDirectionalityFinder, a configurable implementation of DirectionalityFinder

Class com.xmlmind.xmledit.edit.HTMLDirectionalityFinder is a ready-to-use, configurable, implementation of interface com.xmlmind.xmledit.edit.DirectionalityFinder. As you can see it in the above configuration excerpts, this class is used by all XXE stock configurations, and not only by the stock XHTML configurations.

HTMLDirectionalityFinder determines the directionality of an XML element by following a complex set of rules involving the dir attribute and the bdi and bdo specialized elements. These rules are specified in the HTML specification.

However HTMLDirectionalityFinder may be configured to be used for documents other than XHTML documents. A string property called options may be used to parametrize this class.

Parameter options has the following default value:

dir ltr rtl auto bdi bdo

Parameter options has the following syntax:

options -> [ role ]*

role -> attribute_role [ '=' actual_attribute_name ]?
        | dir_value_role [ '=' actual_dir_value ]?
        | element_role [ '=' actual_element_name ]?

attribute_role -> 'dir' | 'style' | 'lang' | 'xml:lang'
dir_value_role -> 'ltr' | 'rtl' | 'auto' | 'lro' | 'rlo'
element_role -> 'bdi' | 'bdo'



The HTML dir attribute.


Value ltr of the HTML dir attribute.


Value rtl of the HTML dir attribute.


Value auto of the HTML dir attribute.


Left-to-right override value of the DITA and DocBook dir attribute. Processed by XXE just like ltr.


Right-to-left override value of the DITA and DocBook dir attribute. Processed by XXE just like rtl.


The HTML bdi element.


The HTML bdo element.


The HTML style attribute. The CSS property of interest here is direction. Companion CSS property unicode-bidi is ignored.


The common lang attribute.


The standard xml:lang attribute.

In order to determine the directionality of an XML node, HTMLDirectionalityFinder examines each of its ancestor elements in turn and for each ancestor element[8], it examines the attributes and elements specified in parameter options in the following order: dir, bdi, bdo, style, xml:lang, lang.

[Note]What about a custom schema using directionality attributes, attribute values, elements different from those used by HTML?

A custom schema may have an equivalent of the HTML dir, style, bdo, ltr, rtl, etc, attributes, elements or attributes values, but with a different name or in a different namespace. In such case, the actual attribute name, element name or attribute value must be specified using the following syntax: role=actual_name_or_value.

Example: the MyCustomSchema equivalent of the HTML dir attribute is my:direction (where "my" is the prefix for namespace "http://acme.corp/namespace") and its values are left-to-right and right-to-left. The corresponding options are thus:

dir={http://acme.corp/namespace}direction ltr=left-to-right rtl=right-to-left

[8] This lookup is needed because attributes dir, lang and xml:lang are “inherited” and CSS property direction is inherited.