lang

The lang function determines whether the context node matches the given language and returns boolean true or false.

Syntax

lang(string )

Parameters

string

The language code or localization (language and country) code to be matched.

Return value

true if the context node matches the given languages. Otherwise, false.

Description

Given this fragment of XML:

xml
<p xml:lang="en">I went up a floor.</p>
<p xml:lang="en-GB">I took the lift.</p>
<p xml:lang="en-US">I rode the elevator.</p>

And this part of an XSL template:

xml
<xsl:value-of select="count(//p[lang('en')])" />
<xsl:value-of select="count(//p[lang('en-GB')])" />
<xsl:value-of select="count(//p[lang('en-US')])" />
<xsl:value-of select="count(//p[lang('de')])" />

The output might be:

3
1
1
0

Specifications

XPath 1.0 4.3

Gecko support

Supported.