In: Computer Science
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 possible.
2. Write a DTD for this XML document such that the corrected version of the example is
a valid XML document.
1)
for <person age=55 id="p29432" manager="p48221">
age value 55 should be in double quotes that's the only change.. after that it is valid.
valid xml:
<?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>
2)
dtd:
<?xml encoding="UTF-8"?>
<!ELEMENT company (person)+>
<!ATTLIST company
xmlns CDATA #FIXED ''>
<!ELEMENT person (ssn,name,office,phone?)>
<!ATTLIST person
xmlns CDATA #FIXED ''
age CDATA #REQUIRED
id NMTOKEN #REQUIRED
manager NMTOKEN #REQUIRED>
<!ELEMENT ssn (#PCDATA)>
<!ATTLIST ssn
xmlns CDATA #FIXED ''>
<!ELEMENT name (#PCDATA)>
<!ATTLIST name
xmlns CDATA #FIXED ''>
<!ELEMENT office (#PCDATA)>
<!ATTLIST office
xmlns CDATA #FIXED ''>
<!ELEMENT phone (#PCDATA)>
<!ATTLIST phone
xmlns CDATA #FIXED ''>