/**
* Pseudo-class handler for :lang
*
* Note that this does not implement the spec in its entirety because we do
* not presume to "know the language" of the document. If anyone is interested
* in making this more intelligent, please do so.
*/
protected function lang($node, $value)
{
// TODO: This checks for cases where an explicit language is
// set. The spec seems to indicate that an element should inherit
// language from the parent... but this is unclear.
$operator = strpos($value, '-') !== FALSE ? EventHandler::isExactly : EventHandler::containsWithHyphen;
$match = TRUE;
foreach ($node->attributes as $attrNode) {
if ($attrNode->localName == 'lang') {
if ($attrNode->nodeName == $attrNode->localName) {
// fprintf(STDOUT, "%s in NS %s\n", $attrNode->name, $attrNode->nodeName);
return Util::matchesAttribute($node, 'lang', $value, $operator);
} else {
$nsuri = $attrNode->namespaceURI;
// fprintf(STDOUT, "%s in NS %s\n", $attrNode->name, $nsuri);
return Util::matchesAttributeNS($node, 'lang', $nsuri, $value, $operator);
}
}
}
return FALSE;
}