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:

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

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

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

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

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:36 UTC