Bugzilla – Bug 853
Disallow <link> from having both rel='' and itemprop=''
Last modified: 2011-08-19 16:16:41 CEST
It appears that the validator always requires <link> to have a rel attribute. Henri, can this constraint be expressed in a schema or should I add it to Assertions.java?
(In reply to comment #0) > It appears that the validator always requires <link> to have a rel attribute. > > Henri, can this constraint be expressed in a schema or should I add it to > Assertions.java? This is something that should be expressed in the schema. I'm happy to make the schema change for it myself, if you want.
(In reply to comment #0) > It appears that the validator always requires <link> to have a rel attribute. As far as I can tell, it doesn't, actually. Do you have a test case where it's requiring a rel attribute on a link in the body of a document? (as opposed to the head) I say that because, after examining the schema, I see that Henri's initial schema implementation actually anticipated this recent change that Hixie made -- in that Henri added a new link.elem.phrasing pattern to the schema, which is allowed only in the body and not in the head, and which does not allow the rel attribute, but which does require the itemprop attribute. (The existing link.elem pattern remains unchanged -- it is only allowed in the head, and must have the rel attribute, and can't have the itemprop attribute.) So, unless you have a document the demonstrates a test case in which the validator does not conform to the current spec, we should close this bug out.
<!DOCTYPE html> <html itemscope> <title></title> <link itemprop="foo" href="bar"> Error: Element link is missing required attribute rel. Apparently it's only in <head> that rel is required. I'm happy for you (Michael) to fix both of these issues. Is it OK to have both in one bug?
(In reply to comment #3) > <!DOCTYPE html> > <html itemscope> > <title></title> > <link itemprop="foo" href="bar"> > > Error: Element link is missing required attribute rel. > > Apparently it's only in <head> that rel is required. But that link ends up in the head, right? Not in the body - http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Chtml%20itemscope%3E%0A%3Ctitle%3E%3C%2Ftitle%3E%0A%3Clink%20itemprop%3D%22foo%22%20href%3D%22bar%22%3E%0A
(In reply to comment #4) > (In reply to comment #3) > > <!DOCTYPE html> > > <html itemscope> > > <title></title> > > <link itemprop="foo" href="bar"> > > > > Error: Element link is missing required attribute rel. > > > > Apparently it's only in <head> that rel is required. > > But that link ends up in the head, right? Not in the body - > > http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Chtml%20itemscope%3E%0A%3Ctitle%3E%3C%2Ftitle%3E%0A%3Clink%20itemprop%3D%22foo%22%20href%3D%22bar%22%3E%0A Yes. rel shouldn't be required in <head> if there's an itemprop attribute, right?
(In reply to comment #5) > (In reply to comment #4) > > (In reply to comment #3) > > > <!DOCTYPE html> > > > <html itemscope> > > > <title></title> > > > <link itemprop="foo" href="bar"> > > > > > > Error: Element link is missing required attribute rel. > > > > > > Apparently it's only in <head> that rel is required. > > > > But that link ends up in the head, right? Not in the body - > > > > http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Chtml%20itemscope%3E%0A%3Ctitle%3E%3C%2Ftitle%3E%0A%3Clink%20itemprop%3D%22foo%22%20href%3D%22bar%22%3E%0A > > Yes. rel shouldn't be required in <head> if there's an itemprop attribute, > right? ah, when I first read the current spec, I missed the part that says "When used with the itemprop attribute, the element can be used both in the head element and in the body of the page, subject to the constraints of the microdata model." (because Hixie has it in a NOTE...) Anway, OK, now that I understand the actual requirements, I will make this change in the schema. I should be able to get it pretty quickly checked in and deployed at http://www.w3.org/html/check for testing. Will ping you as soon as I do
OK, I just pushed a change from my workspace to: http://www.w3.org/html/check (In reply to comment #3) > I'm happy for you (Michael) to fix both of these issues. Is it OK to have both > in one bug? Which two issues do you mean? The change I made just now was to make either itemprop or rel required on the <link> element in the head (previously, it had required just rel, and itemprop was optional).
(In reply to comment #7) > OK, I just pushed a change from my workspace to: > > http://www.w3.org/html/check > > (In reply to comment #3) > > I'm happy for you (Michael) to fix both of these issues. Is it OK to have both > > in one bug? > > Which two issues do you mean? The change I made just now was to make either > itemprop or rel required on the <link> element in the head (previously, it had > required just rel, and itemprop was optional). 1. Disallowing both rel and itemprop on the same <link> 2. The incorrect error for missing rel on <link> in <head> Both are likely fixed by the same changes.
(In reply to comment #8) > 1. Disallowing both rel and itemprop on the same <link> > > 2. The incorrect error for missing rel on <link> in <head> > > Both are likely fixed by the same changes. OK, yeah -- those should both be fixed by the change I made; you test case validates. Feel free to give it a try at http://www.w3.org/html/check when you have a chance. For now, I'll go ahead and push it upstream so we've also have it at validator.nu the next time Henri re-reploys.
Everything looks OK in my ad-hoc testing, thanks!
https://bitbucket.org/validator/syntax/changeset/51b2578b6d58
for the record here: I needed to make a refinement to the schema handling of the rel-or-itemprop constraint: https://bitbucket.org/validator/syntax/changeset/35be31e29fc9 but it's just a schema-internal change; the effect on validation is exactly the same