18. DTD for an Attribute Default Value

A default value for an attribute can be assigned using quotes in the attribute's declaration. The application of this rule is ideal for simple text values.

Example 18.1 An Immediate Attribute Value
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE rootelement [
<!ELEMENT rootelement (childelement*)>
<!ELEMENT childelement (#PCDATA)>
<!ATTLIST childelement
	sampleattribute CDATA "0">
]>
<rootelement>
	<childelement sampleattribute="1">
		Child element content.
	</childelement>
	<childelement>
		Child element content.
	</childelement>
</rootelement>
	

In the above example the second childelement element would have a default sampleattribute value of "0".