Your DTD is syntactically legal, and the document is valid against the DTD, but the triple declaration of the type attribute on the Phone element probably doesn't mean what you want it to mean. The first declaration of a given attribute takes precedence, so what you have is equivalent to
<!ATTLIST Phone type CDATA "mobile">
which means that Phone may take a type attribute whose values can be any character-data (so: any string expressible in XML), and whose default value is "mobile
". The two following re-declarations of the same attribute with different default values are ignored.
If you are seeking to say that the attribute can take the values "mobile
", "work
", or "fax
" and no others, what you want to use is an enumerated type:
<!ATTLIST Phone type (mobile | work | fax) "mobile">
If what you want to say is that the attribute can take any value, but the values "mobile", "work", and "fax" are well known values and software should be prepared for them, then you need to say so in prose; there is no way to say just that in DTD notation. You can say something rather similar by giving Phone two attributes (type and othertype), with the rule that type can take the three values in your exercise, and also the value "other
", while the othertype attribute takes any string as a value, and has meaning only when type="other"
. So a home phone number could be tagged <Phone type="other" othertype="home">...</Phone>
.
<!ATTLIST Phone type (mobile | work | fax | other) #REQUIRED
othertype CDATA #IMPLIED >