-1

Well-formed code of XML is given below which is showing the hierarchy of different courses in Computer Science Department of University. I have convert the xml code into dtd code. Where am I wrong.

My XML Code

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

<University Name="Virtual University of Pakistan">
  <Departments>
         <Department name="Computer Science">
          <Courses>
            <Under-Graduate>
              <Course name="Introduction to Computing">CS101</Course>
              <Course name="Introduction to Programming ">CS201</Course>
              <Course name="Data Structures">CS301</Course>
              <Course name="Object Oriented Programming">CS304</Course>
              <Course name="Data Communication">CS601</Course>   
            </Under-Graduate>

            <Graduate>
              <Course name="Theory of Computation">CS701</Course>
              <Course name="Advanced Operating Systems">CS703</Course>
              <Course name="Software Quality Assurance">CS706</Course>
              <Course name="Distributed DBMS">CS712</Course>
              <Course name="Advanced Computer Networks">CS716</Course>
            </Graduate>     
          </Courses>
     </Department>
  </Departments>

My DTD Code

<!DOCTYPE University> 

<!ELEMENT Name "Virtual University of Pakistan">
    <!ELEMENT Departments>
        <!ELEMENT Department name "Computer Science">
            <!ELEMENT Courses>
                <!ELEMENT Under-Graduate>
                    <!ELEMENT name "Introduction to Computing">
                        <!ENTITY Course "CS101">
                    <!ELEMENT name "Introduction to Programming">
                        <!ENTITY Course "CS201">
                    <!ELEMENT name "Data Structures">
                        <!ENTITY Course "CS301">
                    <!ELEMENT name "Object Oriented Programming">
                        <!ENTITY Course "CS304">
                    <!ELEMENT name "Data Communication">
                        <!ENTITY Course "CS601>
                <!ELEMENT Graduate>
                    <!ELEMENT name "Theory of Computation">
                        <!ENTITY Course "CS701">
                    <!ELEMENT name "Advanced Operating Systems">
                        <!ENTITY Course "CS703">
                    <!ELEMENT name "Software Quality Assurance">
                        <!ENTITY Course "CS706">
                    <!ELEMENT name "Distributed DBMS">
                        <!ENTITY Course "CS712">
                    <!ELEMENT name "Advanced Computer Networks">
                        <!ENTITY Course "CS716">

I have created an XML code and convert that XML code into DTD code. So Where am I wrong in my DTD code.

1 Answers1

0

Your initial problem is that what you are producing is not syntactically a DTD. A related problem is that it appears not to be semantically a DTD, either. (It's hard to tell for sure, since the XML spec does not define any semantics for the character sequence you are providing.)

You should read a tutorial introduction to XML DTDs. If you are learning XML DTDs in a course (the question does sound like homework), perhaps your instructor can recommend one. Perhaps your instructor has already done so, or provided one. If you're not in a course, you can find many such tutorials on the Web. Some people are partial to "A gentle introduction to XML," which Lou Burnard and I produced, but the most recent version of that document describes Relax NG compact syntax, rather than DTDs, so you will need to find an older version. One such is available from The Cover Pages; DTDs are described in sections 1.4-1.7 of that version.

While reading the tutorial, pay attention to the following topics, which will show you some of the things going wrong in your current effort.

  • How many declarations can a conforming DTD have for a given element type?
  • What keyword is used for declaring the valid content of an element type?
  • What syntax is used to declare the valid content?
  • What keyword is used for declaring attributes for an element? What's the syntax of an attribute declaration?

Good luck.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65