O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declaring Attributes in DTDs

Declaring attributes and their types is very useful in XML. If you want your document to be valid, you must declare any attributes that you use before using them. You can give attributes default values and even require XML authors who use your DTD to assign values to attributes.

As we saw at the beginning of this chapter, you declare a list of attributes for an element with the <!ATTLIST> element:

<!ATTLIST ELEMENT_NAME 
    ATTRIBUTE_NAME TYPE DEFAULT_VALUE
					ATTRIBUTE_NAME TYPE DEFAULT_VALUE
					ATTRIBUTE_NAME TYPE DEFAULT_VALUE
    .
    .
    .
    ATTRIBUTE_NAME TYPE DEFAULT_VALUE>

In this case, ELEMENT_NAME is the name of the element that you're declaring attributes for, ATTRIBUTE_NAME is the name of an attribute you're declaring, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required