} /**
* @throws ExpressionErrorException
*/
public function translateLang(XPathExpr
$xpath, FunctionNode
$function): XPathExpr
{ $arguments =
$function->
getArguments();
foreach ($arguments as $token) { if (!
($token->
isString() ||
$token->
isIdentifier())) { throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.
implode(', ',
$arguments));
} } return $xpath->
addCondition(sprintf( 'ancestor-or-self::*[@lang][1][starts-with(concat('
."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')"
.', %s)]',
'lang',
Translator::
getXpathLiteral(strtolower($arguments[0
]->
getValue()).'-'
) ));
}