Generate DTD 2

Question:

Create DTD for the below XML document

<?xml version=”1.0″ encoding=”UTF-8″?>

<student id=”12C042″>

<fName>John</fName>

<lName>Nelson</lName>

<plan>

<courses year=”3″>

<course>

<name> Extensible Markup Language</name>

<shortName>XML</shortName>

<record>

<grade>30</grade>

<date>12-Jan-2017</date>

</record>

</course>

<course>

<name>Object Oriented Concepts and Unified Modeling Language</name>

<shortName><![CDATA[OOP & UML]]></shortName>

</course>

</courses>

</plan>

</student>

Code:

studentdtd.dtd

<?xml version="1.0" encoding="utf-8"?>

<!ELEMENT student (fName,lName,plan)>
<!ELEMENT fName (#PCDATA)>
<!ELEMENT lName (#PCDATA)>
<!ELEMENT plan (courses)>
<!ELEMENT courses (course)*>
<!ELEMENT course (name*, shortName*, record*)>
<!ELEMENT name ANY>
<!ELEMENT shortName ANY>
<!ELEMENT record (grade, date)>
<!ELEMENT grade ANY>
<!ELEMENT date (#PCDATA)>
<!ATTLIST student id NMTOKEN #REQUIRED>
<!ATTLIST courses year CDATA #IMPLIED>

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *

x