In: Computer Science
Write a DTD for this XML document such that the corrected version of the example is a valid XML document
<?xml version="1.0"?>
<computers>
<item type = "Laptop" code = "Dell437">
<make>
<brand>Dell Inspiration</Brand>
<supplier id = "Dell"/>
</make>
<spec>
<cpu speed = "900"/>
<harddisk size = "12" units = "GB"/>
</Spec>
<price n = "950" units = "USD"/>
</item>
<item type = "Desktop" code = "Apple1679">
<make>
<brand>Apple iMac</brand>
<supplier id = "Apple"/>
<make>
<spec>
<cpu speed = "1100"/>
<harddisk size = "16" units = "GB"/>
</spec>
<price n = "790" units = "USD"/>
</item>
</computers>
Given XML code has errors, below is the updated code.
<?xml version="1.0"?>
<computers>
<item type = "Laptop" code = "Dell437">
<make>
<brand>Dell Inspiration</brand>
<supplier id = "Dell"/>
</make>
<spec>
<cpu speed = "900"/>
<harddisk size = "12" units = "GB"/>
</spec>
<price n = "950" units = "USD"/>
</item>
<item type = "Desktop" code = "Apple1679">
<make>
<brand>Apple iMac</brand>
<supplier id = "Apple"/>
</make>
<spec>
<cpu speed = "1100"/>
<harddisk size = "16" units = "GB"/>
</spec>
<price n = "790" units = "USD"/>
</item>
</computers>
DTD :
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="computers">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="make">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="brand"/>
<xs:element name="supplier">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="spec">
<xs:complexType>
<xs:sequence>
<xs:element name="cpu">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:short" name="speed" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="harddisk">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:byte" name="size" use="optional"/>
<xs:attribute type="xs:string" name="units" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="price">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:short" name="n" use="optional"/>
<xs:attribute type="xs:string" name="units" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="code" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Screenshots :