August 2003
Beginner to intermediate
240 pages
7h 44m
English
lang( ) — checks the language of the context node
| Defined in: XPath 1.0 |
Parameters: string langcode (required) |
| Return type: boolean |
This function examines the context node and returns
true if the declared language (with an
xml:lang attribute) matches. The comparison takes
into account the rules for language identifiers, such that a search
for “en” will still match
“en-gb”. If the context node
doesn’t contain an xml:lang
attribute, the nearest ancestor element node with an
xml:lang attribute will be consulted. If no
xml:lang declaration can be located, the return
value is false.
For an XPath data model matching the following XML:
<root xml:lang="x-klingon"> <context/> </root>
With context as the context node, this example
returns true:
lang("x")Read now
Unlock full access