Element that can only have one of two text values?

Solution 1:

when defining an element in a DTD, there is no way to restrict the text inside the element. you can only tell what other element (child elements) it might contain and their order, or you can tell that the element contains text, or a mixture of the 2.

so, basically you have 2 options for restricting the <fuel-system>: either declare it as an attribute (<fuel-system type="fuel-injected"/>), or declare children elements <fuel-injected> and <carburated>. the choice between those 2 options depends on what you are trying to describe and what will change depending on the type of fuel-system.

(the grammar for the declaration of an element is defined here)

examples: first option, attributes

<!ELEMENT fuel-system EMPTY>
<!ATTLIST fuel-system (fuel-injected|carburated) #REQUIRED>

second option, child elements

<!ELEMENT fuel-system (fuel-injected|carburated)>
<!ELEMENT fuel-injected ...>
<!ELEMENT carburated ...>

Solution 2:

Does it have to be a DTD? Is XML Schema an option?

Using XML Schema you can restrict element text to an enumerated list of values:

<xs:element name="fuel-system">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="fuel-injected"/>
      <xs:enumeration value="carbourated"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>