Example 20. DTD for an Attribute with a Specified Value

An attribute value can be set so that it must always have a specified value using the #FIXED keyword. It is not necessary to apply the fixed attribute value to elements as the XML processor passes that attribute and its value from the DTD to the underlying application. If however, the attribute is explicitly used it must be set to the value that is set as the default.

Example 19.1 An example of a required attribute value:
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE rootelement [
<!ELEMENT rootelement (childelement*)>
<!ELEMENT childelement (#PCDATA)>
<!ATTLIST childelement
	sampleattribute CDATA #FIXED "afixedvalue">
	<childelement>Child element.</childelement>
	<childelement sampleattribute="afixedvalue">
		Child element.