lang
Returns true if the context node has an xml:lang attribute with a value that either matches exactly the testlang argument, or is a subset of it. Otherwise, the function returns false.

Languages
XQuery, XSLT 2.0, XSLT 3.0.
Parameters
Name | Type | Description |
---|---|---|
testlang | xs:string | The language code to check, for example, "en". |
Example
The following XML contains para elements with different values for the xml:lang attribute.
<page> |
The mapping illustrated below filters only the German paragraphs, regardless of the country variant, with the help of the lang function.

XSLT 2.0 mapping
In the mapping above, for each para in the source, an item is created in the target, conditionally. The condition is provided by a filter which passes on to the target only those nodes where the lang function returns true. That is, only those nodes that have the xml:lang attribute set to "de" (or a subset of "de") will satisfy the filter's condition. Consequently, the mapping output is as follows:
<items> |
Note that the lang function operates in the context of each para, because of the parent connection between para and item, see also The Mapping Context.