[whatwg] Early feedback on header association algorithm

I shall try to explain the general problem in more detail.
Suppose you have a template that inserts a table T into the Web page, and
some elements in the table have identifiers.  It is not a safe operation
because the identifiers can conflict with element identifiers on the
containing page, or element identifiers within code snippets submitted to
the template as arguments.  In order to preserve uniqueness of identifiers,
you can either rename them or use GUIDs.  The first operation is tricky if
the identifiers are referred to by other attributes and scripts; the other
is unintuitive and seems like an overshoot (because what you need are
page-unique identfiers, not globally unique identifiers).
If I had a solution to this problem, I would be happy to submit it.  I was
hoping for someone smarter than me to stand up and say "Oh, this is easy."
I also think this problem is not restricted to HTML, all markup languages
are affected.
My generic solution would be to add a global attribute named "local-id" and
add a method "HTMLElement.getChildById(arg)" to return the nearest (in terms
of the least depth) child of the element with the local-id equal to arg, or
the element itself.  (This is the reverse of syntactic scoping).  Elements
that have properties containing referring to other identifiers could locate
the referenced elements by local identifiers from the perspective of a
well-defined ancestor (FORM for LABEL, TABLE for TD, etc.)  But I am far
from being sure that it is the right thing to require and that it would
solve a significant class of problems in a satisfactory way.
Bonus example:
<P id=PA local-id=a >...</P >
<TABLE ID=T
><THEAD ><TR ><TH id=TA local-id=a >...
<TBODY ><TR ><TD some-property-that-refers-to-an-id="a" ></TABLE >
Now T.getChildById("a") === TA.
Chris

-----Original Message-----
From: whatwg-bounces@lists.whatwg.org
[mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Ian Hickson
Sent: Wednesday, October 29, 2008 8:16 PM
To: Kristof Zelechovski
Cc: 'WHATWG List'
Subject: Re: [whatwg] Early feedback on header association algorithm

On Wed, 29 Oct 2008, Kristof Zelechovski wrote:
>
> The problem of table header identifiers is a reflection a general 
> problem of locality in markup: you cannot use templates without renaming 
> the identifiers, which is the easy part, and replacing the internal 
> references to the identifiers, which is the hard part.  If you find this 
> remark silly because a solution is well-known, please forgive my 
> illiterate comment above; in that case, that solution should be applied.

Could I ask you to phrase your feedback in terms of changes you would like 
to see to the spec, ideally with examples? People have told me (and I 
concurr) that they have trouble following your feedback. (It is especially 
hard since you don't quote context.)

Received on Wednesday, 29 October 2008 13:49:34 UTC