[DOM4] XML lang

Would it be possible to add something to DOM4 to allow one to find out what language (xml:lang) was inherited from up the chain, if any? 

Use cases: 

1. I need to find elements of a particular type/name that are in a particular language (in tree order), so that I can extract that information to display to a user.

2. I need to check what the language of an element is (if any), without walking up the tree to look for an xml:lang attribute. Walking the tree is expensive, specially when XML says that xml:lang value is inherited by default.

(my motivation is making it simpler to implement Widget's i18n model, which relies on xml:lang's inheritance propagating through an XML document: having something to access the XML values above would make the implementation easier). 

Just of the top of my head:

<foo>
<bar xml:lang="en"/>
<bar xml:lang="en-us">
<baz xml:lang="">
</bar> 
</foo>

//using BCP 47 [lookup] algorithm 
var listOfElements = document.getElementsByLang("en-us"); 

listOfElements[1].lang == "en"; 
listOfElements[0].lang == "en-us"; 

[lookup]
http://tools.ietf.org/html/bcp47#page-2-12
-- 
Marcos Caceres

Received on Wednesday, 5 October 2011 08:14:37 UTC