lang Function
A version of this page is also available for
4/8/2010
Returns True if the xml:lang attribute of the context node is the same as a sublanguage of the language specified by the argument string.
Syntax
boolean lang(string)
Parameters
- string
A string specifying a language.
Return Value
Returns True if the xml:lang attribute of the context node is the same as a sublanguage of the language specified by the argument string.
Remarks
The language of the context node is determined by the value of the xml:lang attribute on the context node, or if the context node has no xml:lang attribute, by the value of the xml:lang attribute on the nearest ancestor of the context node that has an xml:lang attribute. If there is no such attribute, lang() returns False. If there is such an attribute, lang() returns True if the attribute value is equal to the argument (ignoring case) or if there is a suffix starting with "-
", such that the attribute value is equal to the argument, ignoring the suffix of the attribute value and ignoring case.
Given the following XML elements:
<para xml:lang="en"/>
<div xml:lang="en"><para/></div>
<para xml:lang="EN"/>
<para xml:lang="en-us"/>
The following function call returns True for all.
lang("en")