1.

What is the fundamental difference between XML and HTML?


Answer:


2.

Describe the difference between mixed content and element content


Answer:


3.

When is it appropriate to use attributes instead of subelements?


Answer:


4.

Produce an XML file that describes the set-up of your computer.


Answer:


5.

Write a program that can read XML files for describing a pizza.

Your pizza restaurant database from a previous exercise was so successful that you now want to use an XML file to store descriptions of your pizzas. Write a program that can read XML files such as:

<pizza>
   <name>BBQ Chicken</name>
   <description>
       <crust>thin</crust>
       <sauce>barbecue</sauce>
       <cheese>Gouda</cheese>
       <cheese>mozzarella</cheese>
       <toppings>
           <meat>chicken</meat>
           <vegetable>red onion</vegetable>
           <vegetable>cilantro</vegetable>
       </toppings>
   </description>
  </pizza>

Your program should construct a Menu object and use buttons to display various pizza descriptions.


Answer:


6.

Write a program that will read an XML document containing descriptions of "bouncing balls" and display the balls on the screen.
The file should be of the form:
<balls>
   <ball>
      <start>
          <x>30</x>
          <y>100</y>
      </start>
      <size>30</size>
      <color>red</color>
      <movement>
          <dx>2</dx>
          <dy>2</dy>
      </movement>
  </ball>
       
   . . .
</balls>


Answer:


7.

Describe a DOM parser and a SAX parser. Which parser is event-driven?


Answer:


8.

Write a program to create a pizza restaurant menu stored as an XML file.

Read in several XML files describing pizzas. A sample file appears below:

<pizza>
   <name>BBQ Chicken</name>
   <description>
       <crust>thin</crust>
       <sauce>barbecue</sauce>
       <cheese>Gouda</cheese>
       <cheese>mozzarella</cheese>
       <toppings>
           <meat>chicken</meat>
           <vegetable>red onion</vegetable>
           <vegetable>cilantro</vegetable>
       </toppings>
   </description>
</pizza>

Your program should produce an XML document with a <menu> root element containing a list of all the pizzas. The pizzas should be grouped based on the number of toppings.


Answer:


9.

Write a program that creates XML documents containing descriptions of "bouncing balls."

Use your existing program or create a new program to read the XML documents and to display the balls on the screen. The file should be of the form:

<balls>
   <ball>
       <start>
           <x>30</x>
           <y>100</y>
       </start>
       <size>30</size>
       <color>red</color>
       <movement>
           <dx>2</dx>
           <dy>2</dy>
       </movement>
   </ball>

     . . .
</balls>

Allow a user to enter the number of balls to create and the size of the viewing area in pixels. Create balls by generating random values for each element.


Answer:


10.

Design a document type definition (DTD) that describes a pizza.

Include a name and description, including crust type, toppings, and sauce.


Answer:


11.

Design a DTD that describes the output of a paint program.

You need to create an XML document that describes a user's creation in a simple paint program. A user can draw shapes such as a square, circle, or polygon, and add text to a drawing. A user can choose the size and color of a shape or text phrase before it is drawn. The user determines the location of the shape or text phrase by using the mouse. Give the DTD for the document.


Answer:


12.

Write a program that can read and validate XML files for describing a pizza.

Modify your existing program or create a new program to read an XML file and to validate the file using a DTD. The program can read a file such as:

<pizza>
   <name>BBQ Chicken</name>
   <description>
       <crust>thin</crust>
       <sauce>barbecue</sauce>
       <cheese>Gouda</cheese>
       <cheese>mozzarella</cheese>
       <toppings>
           <meat>chicken</meat>
           <vegetable>red onion</vegetable>
           <vegetable>cilantro</vegetable>
       </toppings>
   </description>
</pizza>

Your program should construct a Menu object and use buttons to display various pizza descriptions.


Answer:


13.

Create a program that parses and validates an XML document describing the output of a paint program.

In the paint program, a user can draw shapes such as a square, circle, or polygon, and add text to a drawing. A user can choose the size and color of a shape or text phrase before it is drawn. The user determines the location of the shape or text phrase. When the user chooses to save the drawing, it is stored as an XML file. Create a program that can read one of these XML files and validate it using a DTD. After the document is parsed and validated, display the images.


Answer: