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

Empty Elements

The last remaining DTD content model is the empty-content model. In this case, the elements you declare cannot hold any content (either PCDATA or other elements).

Declaring an element to be empty is easy; you just use the keyword EMPTY, like this:

<!ELEMENT CREDIT_WARNING EMPTY> 

Now you can use this new element, <CREDIT_WARNING>, like this:

<CREDIT_WARNING /> 

Note that although empty elements cannot contain any content, they can have attributes (such as the XHTML <img> element). We'll see how to add attributes to element declarations in the next chapter. Here's how I declare and put the <CREDIT_WARNING> element to work:

Listing . ch03_06.xml
 <?xml version = "1.0" standalone="yes"?> <!DOCTYPE DOCUMENT [ <!ELEMENT DOCUMENT (CUSTOMER)*> ...

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