They're not repetitive. The XML namespace for XHTML and the doctype declaration aren't the same. Neither are the xml:lang
and lang
attributes. The XHTML 1.0 specification requires that all of these are included.
The attribute list for the <html>
element as described by the XHTML 1.0 Strict DTD is as follows:
<!ATTLIST html
%i18n;
id ID #IMPLIED
xmlns %URI; #FIXED 'http://www.w3.org/1999/xhtml'
>
(where %i18n
is an internal entity that represents the xml:lang
, lang
and dir
internationalization attributes, see below)
Notice the fourth line. It says that xmlns
is an attribute of a given URI value, and is fixed at that very namespace URL. That means if you omit the attribute or give it a different namespace, your document is invalid strict XHTML.
The %i18n
entity corresponds to these attributes:
<!-- internationalization attributes
lang language code (backwards compatible)
xml:lang language code (as per XML 1.0 spec)
dir direction for weak/neutral text
-->
<!ENTITY % i18n
"lang %LanguageCode; #IMPLIED
xml:lang %LanguageCode; #IMPLIED
dir (ltr|rtl) #IMPLIED"
>
The lang
attribute is for backwards compatibility (i.e. HTML ≤ 4.01), and xml:lang
is described by XML 1.0 (hence the xml
namespace seen here). I'm not too sure of the exact reason why xml:lang
should precede lang
, but it makes sense given that XHTML is merely HTML "reworded" into XML syntax (so to speak).
The dir
attribute defaults to ltr
(left-to-right text) if not specified, hence it's not a required attribute.