Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 1: Write an XML document describing the exercises in this document: the

ID: 3918171 • Letter: E

Question

Exercise 1:

Write an XML document describing the exercises in this document: the root element is <exercises>. The root has an attribute number that has value 1. The root element has three child elements; <date> that contains as text the date of the exercise, and two <item> elements for the first two exercises (1--2). Write some text in the <item> elements.

Part B:

Write an XML document describing a person: name, occupation, address and hobbies. Please do not use your own information, you can use fake data. Decide on suitable element names and nesting. Check your document for well-formedness.

Answer:

<?xml version="1.0" encoding="iso-8859-1"?>
<person>

<name><gname>Oskari</gname><fname>Heinonen</fname></name>
<occup>assistant</occup>
<address>

<affil>Univ. of Helsinki, Dept. of Computer Science</affil>
<pbox>P.O. Box 68</pbox><street>Gustaf Hällströmin katu 2b</street>
<pcode>FI-00014</pcode><plocale>University of Helsinki</plocale>

</address>
<hobbies><hobby>eating</hobby><hobby>sleeping</hobby></hobbies>

</person>

Part C:

Draw a tree that represents the XML document you created in task 2.

Part D:

This is the books.xml file

<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>

<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">

<title>The Autobiography of Benjamin Franklin</title>
<author>

<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>

</author>

<price>8.99</price>

</book>

<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">

<title>The Confidence Man</title>

<author>

<first-name>Herman</first-name>
<last-name>Melville</last-name>

</author>

<price>11.99</price>

</book>

<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">

<title>The Gorgias</title>
<author>

<name>Plato</name>

</author>

<price>9.99</price>

</book>

</bookstore>

Using books.xml as a model, create a small xml file for a student's program of study form called programOfStudy.xml. It should capture the following data:

In the Fall 2008 semester the student plans to take two classes to satisfy her General Education requirements, PHIL 101 to satisfy Goal 8 and ECON 201 to satisfy Goal 11. She also has to take one core course, MGT 217, and two major courses, CIS 120 and CIS 403.

In the Spring 2009 semester she plans to take two additional core courses, MGT 261 and MKTG 325, as well as three major courses, CIS 220, CIS 407, and CIS 490.

Explanation / Answer

<!-- This is the programOfStudy.xml file -->

<?xml version='1.0'?>

<programOfStudy id="p1">

<name>Porgrams of Study</name>

<Programs season="fall" year="2008">

<title>Philosophy Goal</title>

<PHIL 101>08.00</PHIL 101>

<title>Economy Goal</title>

<ECON 201>11.00</ECON 201>

<Required>"MGT 217, and two major courses, CIS 120 and CIS 403"</Required>

</Programs>

</programOfStudy>

<programOfStudy id="p2">

<name>Porgrams of Study</name>

<Porgrams season="spring" year="2009">

<title>Additional 01</title>

<MGT 261>08.00</MGT 261>

<title>Additional 02</title>

<MKTG 325>11.00</MKTG 325>

<Required>"three major courses, CIS 220, CIS 407, and CIS 490"</Required>

</Programs>

</programOfStudy>