<!ELEMENT Transaction (AddAddress | RemoveAddress | UpdateAddress)> <!ELEMENT AddAddress (AddressBookEntry)> <!ELEMENT RemoveAddress (AddressID)> <!ELEMENT UpdateAddress (AddressID, AddressBookEntry)> <Transaction> <AddAddress> <AddressBookEntry> ... </AddressBookEntry> </AddAddress> </Transaction>In this example an online address book application is being developed. There are several transactions that can take place, lick adding new entries, deleting entries, updating entries.
This allows a way for several related types of documents to be grouped into a single document type structure. A processing system will always know which DTD to expect, but can still handle the documents differently based on the first nested element type. This makes sharing common definitions between the different document easy.
This is also a way that multiple XML document can be gathered into a single larger document. For example a log file might consist of several fragments, for example:
<Log> <Time>Jan 15, 1999 10:58AM</Time> <Event>Startup</Event> </Log> <Log> <Time>Jan 15, 1999 11:02AM</Time> <Event>Message Received from Bob</Event> </Log> ...Since there is no root element in the file it cannot be processed "as is". To process this, one can prepend a start tag, for example "<LogFile>", in front of the file, and append the end tag "</LogFile>" to the end of the file to be able to process it as a single XML document.