Question 1: Write an XML document that contains the following information: your name. Your email address. Your student number. Your home town. Your date of birth. Choose appropriate tags. Use Attributes for the date of birth.
<class>
<personaldetails dateOfBirth=”16th August 1992”>
<name>Daniel Sammut</name>
<email>anemail@emailaddress.com</email>
<studentNumber>M001234567890</studentNumber>
<homeTown>San Gwann </homeTown>
</personaldetails>
</class>
Question 2: Have a look at the XML document below. Identify all the syntax errors:
<?xml version= “1.0” ?>
<!DOCTYPE countryCollection SYSTEM "countryList.dtd">
<CountryList>
<Nations TotalNations =”3”/>
<!--Data from CIA --Year Book -->
<Country CountryCode=”1”>
<OfficialName>United States of America</officialName>
<Label>Common Names:</label>
<CommonName>United States</commonName>
<CommonName>U.S.</commonName>
<Label>Capital:</capital>
<Capital cityNum=”1”>Washington, D.C. </label>
<2ndCity cityNum=”2”>New York </2ndCity> <Label>Major Cities:</label>
<MajorCity cityNum=”3”>Los Angeles </majorCity>
<MajorCity cityNum=”4”>Chicago </majorCity>
<MajorCity cityNum=”5’>Dallas </majorCity>
<Label>Bordering Bodies of Water:</label>
<BorderingBodyOfWater> Atlantic Ocean </borderingBodyOfWater>
<BorderingBodyOfWater> Pacific Ocean </borderingBodyOfWater>
<BorderingBodyOfWater> Gulf of Mexico </borderingBodyOfWater>
<Label>Bordering Countries:</label>
<BorderingCountry CountryCode=”1”> Canada </borderingCountry>
<BorderingCountry CountryCode =”52”> Mexico </borderingCountry>
</country>
<Country CountryCode=”81”>
<OfficialName> Japan </officialName>
<Label>Common Names:</label>
<CommonName> Japan </commonName>
<Label>Capital:</label>
<Capital>Tokyo</capital cityNum=”1”>
<2ndCity cityNum=”2”>Osaka </2ndCity>
<Label>Major Cities:</label>
<MajorCity cityNum=”3”>Nagoya </majorCity>
<MajorCity cityNum=”4”>Osaka </majorCity>
<MajorCity cityNum=”5’>Kobe </majorCity>
<Label>Bordering Bodies of Water:</label>
<BorderingBodyOfWater>Sea of Japan </borderingBodyOfWater>
<BorderingBodyOfWater>Pacific Ocean </borderingBodyOfWater>
</country>
<Country CountryCode=”254”>
<OfficialName> Republic of Kenya </officialName>
<Label>Common Names:</label>
<CommonName> Kenya </commonName>
<Label>Capital:</label>
<Capital cityNum=’1’>Nairobi </capital>
<2ndCity cityNum=’2’>Mombasa</2ndCity>
<Label>Major Cities:</label>
<MajorCity cityNum=’3’>Mombasa </majorCity>
<MajorCity cityNum=’4’>Lamu </majorCity>
<MajorCity cityNum=’5’>Malindi </majorCity>
<MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho </majorCity>
<Label>Bordering Bodies of Water:</label>
<BorderingBodyOfWater <!--Also Lake Victoria --> > Indian Ocean </borderingBodyOfWater>
</country>
Error 1: XML tags are case sensitive, most opening tags here start with uppercase letter and most closing tags start with lower case letters.
Ex: <Label>Common Names:</label>
Error 2: There are some cases that the tags are not matching well
Ex: <Label>Capital:</capital>
<Capital cityNum=”1”>Washington, D.C. </label>
Error 3: There are tags that start with a Numeric Value:
Ex: <2ndCity cityNum=”2”>New York </2ndCity>
Error 4: This Attribute must be enclosed within double quotes not single quotes:
Ex: <MajorCity cityNum=”5’>
Error 5: Attributes can only be declared within the opening tag not the closing tag like this case
Ex: <Capital>Tokyo</capital cityNum=”1”>
Error 6: The Same attribute cannot be declared twice in the same tag
Ex: <MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho </majorCity>
Error 7: A comment cannot be included in a tag
Ex: <BorderingBodyOfWater <!--Also Lake Victoria --> > Indian Ocean </borderingBodyOfWater>
Error 8: The Opening tag <CountryList> does not have a closing tag.
No comments:
Post a Comment