Re: question on issue-110 (xml:lang vs. lang)

On Fri, 2013-01-25 at 12:17 +0100, Felix Sasaki wrote:
> Am 25.01.13 11:19, schrieb Jirka Kosek:
> > On 25.1.2013 9:01, Felix Sasaki wrote:
> >
> >> we had discussed on Wednesday
> >> http://www.w3.org/2013/01/23-mlw-lt-irc#T11-36-22
> >> that xml:lang and lang take precedence over the BCP 47 value conveyed by
> >> a "langRule". One clarification question: should we state that this
> >> relation also includes inherited values? e.g.
> >>
> >> <html xml:lang="en" ...>...
> >> <its:langRule selector="//h:p" langPointer="@class">
> >> ...
> >> <body lang="ja"> ...
> >> <p class="de">...
> >> </html>
> >>
> >> In this case the output of processing "langRule" would convey "en":
> >> xml:lang takes precedence over HTML lang. And xml:lang inherits to "p".
> > My instinct says that inheritence shouldn't be applied here and for p
> > element language should be selected using langRule.
> >
> Fine by me - so the output in the test suite would be
> 
> /html    lang="en"
> ...
> /html/body[1]    lang="ja"
> /html/body[1]/p[1]    lang="de"
> 
> Now, if "p" contains a "span" element, what would the language be? Probably
> 
> /html/body[1]/p[1]/span[1]    lang="de"

I would say certainly lang="de". I would also expect xml:lang to
take precedence over lang only when defined on the same node, so
I would expect the language to be "ja" on body.

getLang(node):
  if node/@xml:lang: return node/@xml:lang
  if node/@lang: return node/@lang
  if node selected by a langRule: return value from rule
  if node.parent: return getLang(node.parent)
  else: return ""

Seems to me that's the same algorithm we use for all other data
categories, except we don't define our own local attribute, using
xml:lang and lang instead.

--
Shaun

Received on Monday, 28 January 2013 19:28:20 UTC