W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: [DOM4] XML lang

From: Marcos Caceres <w3c@marcosc.com>
Date: Wed, 5 Oct 2011 10:17:13 +0200
To: public-webapps <public-webapps@w3.org>
Message-ID: <E94A7A4AA7D143CD901F412BBB1F8C7C@marcosc.com>


On Wednesday, 5 October 2011 at 10:14, Marcos Caceres wrote:

> 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"; 
Bah, I hit send before I had finished the example (which is wrong). Anyway, you get the idea. 
Received on Wednesday, 5 October 2011 08:17:44 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:48 GMT