14.2. A Simple DTD for E-mail

Before going any further with parsing Linux or Eudora mailboxes, we need to settle on an XML representation of a mailbox. We will use the following simple DTD.

CD-ROM reference=14003.txt
<!--
XMail = A simple DTD for a collection of e-mail messages

An xMail file consists of zero or more message elements.

A message has a headers element that contains fields such as
from, to, subject, and so on. The body element houses
the text of the e-mail
-->

<!ELEMENT xmail   (message)*>
<!ELEMENT message (headers,body)>
<!ELEMENT headers (field)+>
<!ELEMENT field   (name,value)>
<!ELEMENT name    (#PCDATA)>
<!ELEMENT value   (#PCDATA)>
<!ELEMENT body    (#PCDATA)>

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.