- From: Jukka K. Korpela <jkorpela@cs.tut.fi>
- Date: Sat, 28 Dec 2013 14:50:32 +0200
- To: www-validator@w3.org
2013-12-28 10:59, David Dorward wrote:
> On 28 Dec 2013, at 3:46, Kyle J. McKay wrote:
>
>> According to http://www.w3.org/TR/xhtml1/#prohibitions a elements may
>> not contain other a elements at any depth. Neither does HTML allow
>> nesting of a elements.
>>
>> Is this a known limitation of the validation service?
>
> It is a known limitation, but not of the service per se. The problem is
> that the DTDs for XHTML do not express the rule that one anchor cannot
> be a descendant of another anchor. I think I read somewhere that XML
> DTDs cannot express that type of rule.
That is correct. XML lacks the exclusion mechanism of SGML. HTML 4.01
Strict DTD says (in SGML):
<!ELEMENT A - - (%inline;)* -(A) -- anchor -->
but XHTML 1.0 Strict DTD says (in XML):
<!ENTITY % a.content
"(#PCDATA | %special; | %fontstyle; | %phrase; | %inline.forms; |
%misc.inline;)*">
<!ELEMENT a %a.content;>
Despite the different formulation, the rules are equivalent except for
the exclusion “-(A)” in the HTML 4.01 rule. The exclusion simply says
that the A element must not contain an A element as descendant, even if
the rule would otherwise allow it. Such an exclusion mechanism is not
present in the strongly simplified variant of SGML that is called XML.
The expressive power of element declarations in XML is limited to a
rather simple syntax defined at
http://www.w3.org/TR/REC-xml/#elemdecls
This is explicitly stated in “4.9. SGML exclusions” in the XHTML 1.0
specification, at
http://www.w3.org/TR/xhtml1/#h-4.9
> The rule is expressed in the HTML 4.01 DTDs and in the HTML 5 validation
> rules.
In HTML 4.01, it is indeed part of the formalized syntax and therefore
checked by validators.
In HTML5, which is work in progress, there is no formalized syntax (at
least not in a sense comparable to a DTD), so (experimental) HTML5
validators need to apply logic derived from the prose descriptions.
Those descriptions impose the restriction that an A element must not
have any “interactive content” descendant, and this includes A elements.
Experimental HTML5 validators seem to successfully enforce this
restriction. The error message is slightly cryptic, though: “An a start
tag seen but an element of the same type was already open.” It suggests
that it would generally be an error to start an element X inside an
element X – it is of course an error only if the content model of X does
not allow X. If you try to put <input> inside <a>, the error message is
much clearer: “The element input must not appear as a descendant of the
a element.”
Yucca
Received on Saturday, 28 December 2013 12:51:52 UTC