Re: Level 3: Element.setIdAttribute*()

On Fri, 2002-11-01 at 17:18, Fred L. Drake, Jr. wrote:
> Given that I know at least Ray is listening, I'll ask a few questions
> about the intentions for the setIdAttribute*() methods being added to
> the Element interface.
> 
> Let's start with a minimal sample document:
> 
>     <!DOCTYPE e [
>         <!ATTLIST e id ID #IMPLIED>
>     ]>
>     <e id="me" attr="you"/>
> 
> Let's also presume we have a Level 3 Document representing this
> document:
> 
>     doc = parse(...)
>     e = doc.documentElement
>     a1 = e.getAttributeNode("id")
>     a2 = e.getAttributeNode("attr")
> 
> If at this point we make the call:
> 
>     e.setIdAttribute("attr")
> 
> then... what happens?  The draft is clear that
> doc.getElementById("you") should return the document element in this
> case.  What about doc.getElementById("me")?  Is it still considered an
> ID?  The specification should be explicit about the interaction with
> the "Validity constraint: One ID per Element Type" constraint (XML
> 1.0 2nd ed., section 3.3.1), validation features, and this method.

attr and me will both be considered as ID. The notion of ID is in fact
not restricted to XML 1.0. This also permits a schema language to allow
aliases for ID.

> Next question:
> 
> Is the "ID-ness" of the attribute associated with the element node,
> the attribute node, their association, or the association between the
> element and the attribute *name*?  If the attribute node is removed
> from the element and added to a different element, is it still an ID?

 The ID-ness is an association between the attr node and the element
node. If the attr node is removed, it will loose its ID-ness. If
re-attached to the document element, it may get back its ID-ness if the
implementation is "schema-awared" or if you use normalizeDocument.
Consequently, renaming a Node will not affect isId() as currently
defined.

> If the attribute node is replaced with another of the same name, does
> the new attribute node become an ID, is the original ID restored, or
> does the element end up with no ID?

It will loose its ID-ness (again, unless the implementation knows more
about the schema).

> I hope these questions make sense!

They do and the draft needs clarification. We spent lots of time last
week discussing setIdAttribute()/isId()...

> A simpler question, also related to IDs:  Is there any expectation
> that an attribute or method will be added that allows an application
> to get the ID of an element without having to loop over the attribute
> nodes and check the isId attribute?

No, but we will certainly consider this functionality.

Philippe

Received on Monday, 4 November 2002 11:16:38 UTC