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

[DOM4] XML lang

From: Marcos Caceres <w3c@marcosc.com>
Date: Wed, 5 Oct 2011 10:14:05 +0200
To: public-webapps <public-webapps@w3.org>
Message-ID: <12F6B33BB2C5441C9F87F4B75ED65DBA@marcosc.com>
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 GMT

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