After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 305885 - HTML Select name and id collision
HTML Select name and id collision
Product: libxml2
Classification: Platform
Component: general
Other All
: Normal minor
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Reported: 2005-05-30 02:05 UTC by Stuart Begg
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---

Only consider the name attribute of A elements as an ID (532 bytes, patch)
2007-06-10 01:18 UTC, Dagfinn I. Mannsåker
none Details | Review

Description Stuart Begg 2005-05-30 02:05:54 UTC
Please describe the problem:
I get the following error from xmllint (using --html) when parsing a file
containing a SELECT element which has the same value for its "name" and "id"

ByLabel.html:15: element select: validity error : ID iColourPref already defined
ter your colour preference: <select id="iColourPref" name="iColourPref" size="1"

I have used the same markup for <INPUT> elements (using the same value for the
"name" and "id" attributes) and xmllint does not complain.

The file is marked up as XHTML 1.0 Strict, and it passes the W3C validator.

Is this a problem with my markup or withe LibXML2?

Steps to reproduce:
1. Create an XHTML, with the following markup.

<select id="isel" name="isel"> ... </select>

2. Parse the file with xmllint using the following command:

xmllint --html file.html

3. You should see a validity error for this select element.

Actual results:
You get a validity error reported on the <select> element saying that the ID has
already been defined.

Expected results:
There should be no namespace collision and the document should be parsed without

Does this happen every time?

Other information:
The file seems to be valid with the W3C parser, but not with LibXML2. I'm using
xmllint supplied with cygwin (Windows 2000). I attempted to get the latest
independent version running of LibXML2 (2.6.19), but ran into some entity
problems I couldn't resolve. I suspect, though, that I would experience the same
result with the latest version of LibXML2.
Comment 1 Daniel Veillard 2005-09-01 09:56:24 UTC
The problem seems already fixed in CVS:

paphio:~/XML -> cat tst.html
  <select id="isel" name="isel"> ... </select>
paphio:~/XML -> xmllint --html tst.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
  <select id="isel" name="isel"> ... </select>
paphio:~/XML ->

Comment 2 Daniel Veillard 2005-09-05 09:00:18 UTC
This should be closed by release of libxml2-2.6.21,


Comment 3 Danek Duvall 2006-07-19 21:47:40 UTC
I believe I'm still seeing this:

% cat ep.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="en" xml:lang="en">

<p id="Search" name="Search">
% xmllint --html ep.html
ep.html:8: element p: validity error : ID Search already defined
<p id="Search" name="Search">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="en" xml:lang="en">
<p id="Search" name="Search">

The output is just fine, but the validity error is, as far as I can tell,
invalid.  The problem disappears if I remove the DTD entirely, but it shows up
when I use either the strict or the transitional XHTML DTD.

I'm seeing this with 2.6.23, on both Linux and Solaris.
Comment 4 Dagfinn I. Mannsåker 2007-06-10 00:11:57 UTC
I am still seeing this with libxml2 2.6.28 on Linux (Ubuntu Gutsy). Here's the test case:

$ xmllint --html test.html
test.html:6: element a: validity error : ID foo already defined
<a id="foo" name="foo">Foo</a>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<html lang="en">
<a id="foo" name="foo">Foo</a>
Comment 5 Dagfinn I. Mannsåker 2007-06-10 01:18:18 UTC
Created attachment 89671 [details] [review]
Only consider the name attribute of A elements as an ID

According to the HTML and XHTML specs, only the a element's name attribute shares name space with id attributes. For some of the elements it can be argued that multiple instances with the same name don't make sense, but they should nevertheless not be considered in the same namespace as other elements' id attributes.

See for all the elements that take name attributes and their semantics.