Quoting Michael Glavassevich <[EMAIL PROTECTED]>:

> Hi Jake,
>
> Jacob Kjome <[EMAIL PROTECTED]> wrote on 09/24/2006 11:46:57 PM:
>
> <snip/>
>
> > Ok, then how about...
> >
> >      public synchronized Element getElementById( String elementId )
> >      {
> >          Element idElement = super.getElementById(elementId);
> >          if (idElement != null) {
> >              return idElement;
> >          }
> >          idElement = getElementById( elementId, this );
> >          if (idElement != null) {
> >              idElement.setIdAttribute("id", true);
> >          }
> >          return idElement;
> >      }
> >
> > That seems to work just as well and seems like it addresses the issue
> > you just mentioned, no?
>
> Hmmm.... That's still going to have some wonky behaviour. Consider the
> following code snippet:
>
> Document doc = ...;
> Attr id = ...; // name = "id", value = "foo"
> System.out.println(id.isId()); // false
> doc.getElementById("foo");
> System.out.println(id.isId()); // true
> doc.normalizeDocument(); // validate
> System.out.println(id.isId()); // false
>
> The IDness of "id" will change as a side-effect of calling
> getElementById() and/or normalizeDocument(). If this attribute really is
> an ID isId() should always return true. Perhaps a better way to address
> this would be for the HTML DOM to enforce the IDness of these attributes
> and store their values in the "identifiers" map as they're added to the
> tree.
>

I'm not looking at the Xerces HTML DOM code right now (I will when I get home),
but do you have the feeling that this can be centrally managed, or will there
have to be code in multiple places to manage this?  That is, can code simply be
added to Element.setAttributXXX() methods to check for the attribute being "id"
and, if so, call the applicable this.setIdAttribute() method?  If so, that
sounds like a pretty simple change and should work in all situations.  And then
getElementById() in HTMLDocumentImpl can simply be commented out to let the
superclass's method do the work by pulling it from the "identifiers" map.

Thoughts?

Jake

> > Jake
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to