Difference between revisions of "Introduction to Databases with Stanford University : DTD Exercises"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | + | Introduction to Databases by Standford University http://db-class.org | |
+ | Additional materials: http://openclassroom.stanford.edu/MainFolder/CoursePage.php?course=IntroToDatabases | ||
Use xmllint ([[XML_Validation]]) to validate the result. | Use xmllint ([[XML_Validation]]) to validate the result. |
Revision as of 17:46, 16 November 2011
Introduction to Databases by Standford University http://db-class.org Additional materials: http://openclassroom.stanford.edu/MainFolder/CoursePage.php?course=IntroToDatabases
Use xmllint (XML_Validation) to validate the result.
1. Create a DTD for XML data at http://s3.amazonaws.com/dbclass-resources/docs/courses-noID.xml (Alternate link:Courses-noID.xml)
<!ELEMENT Course_Catalog (Department*)> <!ELEMENT Department (Title, Chair, Course+)> <!ATTLIST Department Code CDATA #REQUIRED> <!ELEMENT Chair (Professor)> <!ELEMENT Course (Title, Description*, Instructors, Prerequisites*)> <!ATTLIST Course Number CDATA #REQUIRED Enrollment CDATA #IMPLIED> <!ELEMENT Instructors (Lecturer|Professor)+> <!ELEMENT Prerequisites (Prereq*)> <!ELEMENT Lecturer (First_Name,Middle_Initial*,Last_Name)+> <!ELEMENT Professor (First_Name,Middle_Initial*,Last_Name)+> <!ELEMENT Title (#PCDATA)> <!ELEMENT Description (#PCDATA)> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)> <!ELEMENT Middle_Initial (#PCDATA)> <!ELEMENT Prereq (#PCDATA)>
2. Create a DTD for XML data at http://s3.amazonaws.com/dbclass-resources/docs/courses-ID.xml (Alternate link: Courses-ID.xml)
<!ELEMENT Course_Catalog (Department*)> <!ELEMENT Department (Title, Course+,(Professor|Lecturer)*)> <!ATTLIST Department Code CDATA #REQUIRED Chair IDREF #IMPLIED> <!ELEMENT Course (Title, Description*)> <!ATTLIST Course Number ID #REQUIRED Prerequisites CDATA #IMPLIED Instructors IDREFS #REQUIRED Enrollment CDATA #IMPLIED> <!ELEMENT Courseref EMPTY> <!ATTLIST Courseref Number IDREF #REQUIRED> <!ELEMENT Lecturer (First_Name,Middle_Initial*,Last_Name)> <!ELEMENT Professor (First_Name,Middle_Initial*,Last_Name)> <!ATTLIST Lecturer InstrID ID #REQUIRED> <!ATTLIST Professor InstrID ID #REQUIRED> <!ELEMENT Title (#PCDATA)> <!ELEMENT Description (#PCDATA|Courseref)*> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)> <!ELEMENT Middle_Initial (#PCDATA)>
3. Create a DTD for XML data at http://s3.amazonaws.com/dbclass-resources/docs/countries.xml (Alternate link: Countries.xml)
<!ELEMENT countries (country*)> <!ATTLIST country name CDATA #REQUIRED population CDATA #REQUIRED area CDATA #REQUIRED> <!ELEMENT country ((language|city)*)> <!ELEMENT city (name,population)> <!ELEMENT language (#PCDATA)> <!ATTLIST language percentage CDATA #REQUIRED> <!ELEMENT name (#PCDATA)> <!ELEMENT population (#PCDATA)>