Re: [xml] HTML id and name attributes



On Mon, Nov 07, 2005 at 03:19:17PM +1100, Michael Day wrote:

Hi,

Currently libxml treats both the "id" and "name" attributes as type ID
(this is done by xmlIsID in valid.c)

This is a problem for common HTML anchor markup using both like this:

    <a id="foo" name="foo">...</a>

This markup will produce an error message because the "foo" ID has been
defined multiple times, even though it is on the same element.

Would it be possible to only treat "id" as an ID and not "name"? This
would make it easier to parse HTML documents without spurious warnings as
well as being more compatible with XHTML, in which "name" is only defined
as an NMTOKEN attribute.

  It's an historical problem. Do people still use name in web pages, I guess
so. I suggest to rather change xmlIsID to check that if attr->name is 'name'
and there is an 'id' then return 0. This complexifies the test a bit but 
might work (worth testing because SAX2 callback may call it continuously
while adding the attributes on the element), if this doesn't work maybe
something more radical is in order, yes.

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]