Question

In: Computer Science

Write a DTD for this XML document such that the corrected version of the example is...

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>

Solutions

Expert Solution

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 :


Related Solutions

Create a XSD Schema to validate and provide structure for the XML document below: <?xml version="1.0"...
Create a XSD Schema to validate and provide structure for the XML document below: <?xml version="1.0" encoding="UTF-8" ?> <forecast qTime="28/10/20 10:00 PM" qLocation="Singapore"> <weather yyyymmdd="20200430"> <year>2020</year>   <month>04</month> <date>30</date> <comment>Plenty of sunshine</comment> <code>sunny</code> <highest>32.6</highest> <lowest>28.4</lowest> </weather> <weather yyyymmdd="20200218"> <year>2020</year>   <month>02</month> <date>18</date> <comment>Plenty of sunshine</comment> <code>sunny</code> <highest>34.6</highest> <lowest>30.5</lowest> </weather> <weather yyyymmdd="20200710"> <year>2020</year>   <month>07</month> <date>10</date> <comment>Partly sunny</comment> <code>partlySunny</code> <highest>33.1</highest> <lowest>29.2</lowest> </weather> <weather yyyymmdd="20200616"> <year>2020</year>   <month>06</month> <date>16</date> <comment>Considerable clouds</comment> <code>cloudy</code> <highest>30.5</highest> <lowest>25.4</lowest> </weather> <weather yyyymmdd="20200612"> <year>2020</year>   <month>06</month> <date>12</date> <comment>Cloudy with a thunderstorm</comment> <code>thunderstorm</code> <highest>29.1</highest>...
1. The following XML document describes some employees of a company. <?xml version="1.0" encoding="UTF-8"?> <company> <person...
1. The following XML document describes some employees of a company. <?xml version="1.0" encoding="UTF-8"?> <company> <person age="25" id="p29432" manager="p48293"> <ssn>123456789</ssn> <name> John Davis</name> <office>B432</office> <phone>1234</phone> </person> <person age="27" id="p29333" manager="p48222"> <ssn>987654321</ssn> <name>Jim Handler</name> <office>B123</office> </person> <person age=55 id="p29432" manager="p48221"> <ssn>123456789</ssn> <name> Christo Dichev</name> <office>A4210</office> <phone>2477</phone> </person> <person age="57" id="p29333" manager="p4832"> <ssn>987654321</ssn> <name>Elva Jones</name> <office>A4211</office> </person> </company> 1. Check if the XML document is well-formed. If it is not, change it so that it becomes wellformed, making as little changes as...
Consider the XML DTD definition below. Write a well-formed and valid XML Document that conforms to...
Consider the XML DTD definition below. Write a well-formed and valid XML Document that conforms to this definition. <!ELEMENT wine-catalog (wine+)> <!ELEMENT wine (properties,origin,price,year,tasting-note?)> <!ATTLIST wine    code   ID #REQUIRED name   #PCDATA #REQUIRED    classification #PCDATA #REQUIRED format (375ml|750ml) “750ml”> <!ELEMENT properties (color,alcohol-content)> <!ELEMENT color (#PCDATA)> <!ELEMENT alcohol-content (#PCDATA)> <!ELEMENT origin (country, region, producer)> <!ELEMENT country (#PCDATA)> <!ELEMENT region (#PCDATA)> <!ELEMENT producer (#PCDATA)> <!ELEMENT price (#PCDATA)> <!ELEMENT year (#PCDATA)> <!ELEMENT tasting-note (#PCDATA)>
What is the well formatted XML document
What is the well formatted XML document
3.1. Create an XML schema to validate the following XML file. <?xml version="1.0" encoding="utf-8"?> <root> <whats>Everything</whats>...
3.1. Create an XML schema to validate the following XML file. <?xml version="1.0" encoding="utf-8"?> <root> <whats>Everything</whats> <up>Is</up> <doc>Fine</doc> </root> Schema starter: <xsd:schema xmlns:xsd=""> <xsd:element name="root" type="rootType" /> <xsd:complexType name="rootType">     <xsd:sequence>       <xsd:element name="" type="" minOccurs="1" />       <xsd:element name="” type="" minOccurs="1" />       <xsd:element name="" type="" minOccurs="1" />     </xsd:sequence> </xsd:complexType> </xsd:schema> 3.2. Use your schema to validate the XML file.                     3.2.1. You can use Visual Studio or online utilities to apply the schema to the XML file....
What are two ways in which namespaces can be represented within an XML document?
What are two ways in which namespaces can be represented within an XML document? How is the scope of a particular XML element within a document determined based on these two namespace types?
What is the syntax of a typical DOCTYPE declaration you would find in an XML document...
What is the syntax of a typical DOCTYPE declaration you would find in an XML document if its DTD is located in the same directory as the XML document itself?
you will develop a small XML. XML is used for storing and exchanging information. XML is...
you will develop a small XML. XML is used for storing and exchanging information. XML is the most commonly used file format for e-business. It is important to have a grasp of XML. In XML, you can choose your own tag names. For example, for representing name of a product, you can use <pname>, <prodName> or <productname> as you like. XML has to follow certain syntax rules.  Gentle Introduction to XML (External Link) provides more information about XML. Do the following:...
Write a modified version of the program below. In this version, you will dynamically allocate memory...
Write a modified version of the program below. In this version, you will dynamically allocate memory for the new C-string and old C-string, using the new keyword. Your program should ask the user for the size of the C-string to be entered, and ask the user for the C-string, then use new to create the two pointers (C-strings).   Then, call Reverse, as before. Don’t forget to use delete at the end of your program to free the memory! #include <iostream>...
write an essay. compare a traditional version of a fairy tale with a contemporary written version...
write an essay. compare a traditional version of a fairy tale with a contemporary written version and a recent film. please also mention references from where you take the data
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT