GNOME Bugzilla – Bug 305885
HTML Select name and id collision
Last modified: 2009-08-15 18:40:50 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" attributes: 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 incident. Does this happen every time? Yes. 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.
The problem seems already fixed in CVS: paphio:~/XML -> cat tst.html <html> <body> <select id="isel" name="isel"> ... </select> </body> </html> paphio:~/XML -> xmllint --html tst.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body> <select id="isel" name="isel"> ... </select> </body></html> paphio:~/XML -> Daniel
This should be closed by release of libxml2-2.6.21, thanks, Daniel
I believe I'm still seeing this: % cat ep.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Title</title> </head> <body> <p id="Search" name="Search"> </body> </html> % 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head><title>Title</title></head> <body> <p id="Search" name="Search"> </p> </body> </html> 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.
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" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head><title>Test</title></head> <body> <a id="foo" name="foo">Foo</a> </body> </html>
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 http://www.zvon.org/xxl/xhtmlReference/Output/Strict/attr_name.html for all the elements that take name attributes and their semantics.