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.
<xml version=”1.0″?><student><name>Marcel Mizzi</name><dob= “15.06.1965″><studentid>MM12345</studentid><email>marcelmizzi@gmail.com</email><town>San Gwann</town></student>
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>
Errors noted as follows :
- <CountryList> does not have a corresponding closing tag
- The "Case consistency" rule is not being respected such as in the <MajorCity></majorcity> elements.
- Some elements are not nested correctly such as <Label>Capital:</capital>
- The rule that a number cannot be used as the first character when naming and element is not being adhered to in <2ndCity cityNum=’2’>Mombasa</2ndCity> for example.
- <BorderingBodyOfWater <!–Also Lake Victoria –> > Indian Ocean is illegal because comments should not be made inside elements.
- <MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho breaks the rule that an attribute name cannot include words that are already used in the element name.

0 comments:
Post a Comment