ATTLIST Declarations of xml:lang
Although the XML 1.0 specification defines the
xml:lang attribute, you still have to declare it in the
DTDs of valid documents. For example, this information
declares the maxim element used
several times in this chapter:
<!ELEMENT maxim (#PCDATA)> <!ATTLIST maxim xml:lang NMTOKEN #IMPLIED>
Here I’ve used the NMTOKEN
type, since all legal language codes are well-formed XML name
tokens.
You may declare the xml:lang attribute in any convenient way.
For instance, if you want to require its presence on the maxim element, you could make it #REQUIRED:
<!ATTLIST maxim xml:lang NMTOKEN #REQUIRED>
Or, if you wanted to allow only French and English text in your documents, you might specify it as an enumerated type with a default of English like this:
<!ATTLIST maxim xml:lang (en | fr) 'en'>
Unless you use an enumerated type, the parser will not check that the value you give it follows the rules outlined here. It’s your responsibility to make sure you use appropriate language codes and subcodes.