2.4. The XML Document Type Definition (DTD)

2.4.1. Introduction

The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. A DTD can be declared inline in the XML document, or as an external reference.

XML provides an application independent way of sharing data. With a DTD, the application can use a standard DTD to verify that data that the user supplies is valid. A "Valid" XML document is a "Well Formed" XML document which conforms to the rules of a Document Type Definition (DTD).

In AutoYaST, a DTD should is available to allow users to validate the control files before the installation process is initiated. The DTD can be also used with XML editors while editing the control file to avoid later errors.

2.4.2. Example DTD

Below is the XML for an example node view profile for the above tree which includes a DTD which validates it.

Example 2-5. Example DTD


<?xml version="1.0"?> 
<!DOCTYPE profile [ 
<!ELEMENT profile (install)>
<!ELEMENT install (partitioning)> 
<!ELEMENT partitioning (drive+)> 
<!ELEMENT drive (device,partitions)> 
<!ELEMENT device (#PCDATA)> 
<!ELEMENT partitions (partition*)> 
<!ELEMENT partition (size,mount)> 
<!ELEMENT size (#PCDATA)> 
<!ELEMENT mount (#PCDATA)>
]> 
<profile> 
.....
  <install>
    <partitioning config:type="list">
      <drive> 
        <device>
           /dev/hda
        </device> 
        <partitions> 
          <partition> 
            <size>1000mb</size> 
            <mount>/</mount> 
          </partition> 
          <partition> 
            <size>250mb</size> 
            <mount>/tmp</mount> 
          </partition> 
        </partitions>
      </drive> 
    </partitioning>
  </install>
.....
</profile>