问题
You can find various documents that say to specify the language of the content of an XML document, use xml:lang
, like this:
<foobar xml:lang="en">...</foobar>
HTML and XHTML has the attribute dir
that lets you specify that the text should be considered left-to-right by default, or right-to-left by default:
<html dir="rtl">...</html>
Is there an equivalent attribute for XML? Is the only solution to include Unicode RIGHT-TO-LEFT mark in every text node?
回答1:
The W3C XML Recommendation itself does not address directionality (although it does address language identification as you mention with xml:lang
).
However, in the W3C Best Practices for XML Internationalization, see Best Practice 2: Defining markup to specify text direction for how to use the its:dir attribute and its:dirRule element to specify directional markup via the Internationalization Tag Set.
来源:https://stackoverflow.com/questions/38995517/does-xml-officially-support-a-dir-or-xmldir-attribute