Quackit Logo

Got a MySpace Page?

Get "www.yourname.com" for your MySpace page. Learn how >>.

DTD Attribute Types - Enumerated

Print Version

The enumerated attribute type provides for a list of possible values. This enables the DTD user to provide one value from the list of possible values.

The values must be surrounded by parentheses, and each value must be separated by a pipe (|).

Syntax:

<!ATTLIST element_name
attribute_name (value1 | value2 | value3) default_value>

Example:

<!ATTLIST tutorial
published (yes | no) "no">

Valid XML - The following XML document would be valid, as it conforms to the above DTD:

<tutorials>
  <tutorial published="yes">
    <name>XML Tutorial</name>
  </tutorial>
  <tutorial published="no">
    <name>HTML Tutorial</name>
  </tutorial>
  <tutorial>
    <name>CSS Tutorial</name>
  </tutorial>
</tutorials>

Invalid XML - The following XML document would be invalid because the value of the first attribute does not match one of the options of the ATTLIST declaration:

<tutorials>
  <tutorial published="true">
    <name>XML Tutorial</name>
  </tutorial>
  <tutorial published="no">
    <name>HTML Tutorial</name>
  </tutorial>
  <tutorial>
    <name>CSS Tutorial</name>
  </tutorial>
</tutorials>

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!