Skip to Content
Real World XML
book

Real World XML

by Steven Holzner
January 2003
Beginner to intermediate content levelBeginner to intermediate
1200 pages
23h 42m
English
Peachpit Press
Content preview from Real World XML

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)*> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Inside XML

Inside XML

Steven Holzner
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0735712867Purchase book