Project Index | Documentation | Relax NG | Sample XML File
<!-- ============================================================================ --> <!-- Author: Marie Taylor-Harper --> <!-- Lab #: Midterm (Relax NG) --> <!-- Due : June 4, 2002 --> <!-- Associated Files: --> <!-- taylorharper_m_midterm.xml --> <!-- ============================================================================ --> <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <start> <element name="roster"> <ref name="def-school-info" /> <ref name="def-course-info" /> <ref name="def-instructor-info" /> <element name="students"> <ref name="def-students" /> </element> </element> </start> <!-- ============================================================================ --> <!-- School Information Definition --> <!-- ============================================================================ --> <define name="def-school-info"> <element name="school-info"> <element name="school-name"> <choice> <value type="string">Foothill</value> <value type="string">De Anza</value> </choice> </element> <element name="school-address"> <ref name="def-address" /> </element> <element name="school-phone"> <ref name="def-phone" /> </element> </element> </define> <!-- ============================================================================ --> <!-- Course Information Definition --> <!-- ============================================================================ --> <define name="def-course-info"> <element name="course-info"> <element name="course-code"> <data type="string"> <param name="pattern">[A-Z]{3}\d{3}[a-z]?</param> </data> </element> <element name="course-section"> <data type="string"> <param name="pattern">\d{2}[A-Z]?</param> </data> </element> <element name="course-desc"> <ref name="def-MixedText" /> </element> <element name="term"> <choice> <value type="string">Fall</value> <value type="string">Winter</value> <value type="string">Spring</value> <value type="string">Summer</value> </choice> </element> <element name="term-length"> <choice> <value type="string">6</value> <value type="string">8</value> <value type="string">11</value> <value type="string">15</value> </choice> </element> <element name="year"> <data type="string"> <param name="pattern">\d{4}</param> </data> </element> </element> </define> <!-- ============================================================================ --> <!-- Instructor Information Definition --> <!-- ============================================================================ --> <define name="def-instructor-info"> <element name="instructor-info"> <element name="instructor-name"> <ref name="def-name" /> </element> <element name="instructor-address"> <ref name="def-address" /> </element> <element name="instructor-phone"> <ref name="def-phone" /> </element> <element name="instructor-ssn"> <data type="string"> <param name="pattern">\d{3}-\d{2}-\d{4}</param> </data> </element> </element> </define> <!-- ============================================================================ --> <!-- Student Information Definition --> <!-- ============================================================================ --> <define name="def-students"> <oneOrMore> <element name="student-info"> <element name="student-name"> <ref name="def-name" /> </element> <element name="student-id"> <data type="string"> <param name="pattern">\d{9}</param> </data> </element> <oneOrMore> <element name="student-phone"> <ref name="def-phone" /> <attribute name="type"> <choice> <value type="string">Home</value> <value type="string">Work</value> <value type="string">Mobile</value> </choice> </attribute> </element> </oneOrMore> <oneOrMore> <element name="email"> <data type="string"> <param name="pattern">[-._A-Za-z0-9]+@([-A-Za-z0-9]+\.)+(com|org|net|edu|[a-z]{1,3})</param> </data> </element> </oneOrMore> <optional> <element name="nt-username"> <data type="string"> <param name="pattern">\S*</param> </data> </element> </optional> <element name="unix-username"> <data type="string"> <param name="pattern">\S*</param> </data> </element> <element name="password-info"> <element name="class-id"> <data type="string"> <param name="pattern">\d{4}</param> </data> </element> <element name="password"> <data type="string"> <param name="pattern">\S*</param> </data> </element> <element name="mothers-maiden-name"> <data type="string"> <param name="pattern">[A-Z][-a-z]*</param> </data> </element> </element> <element name="attendance"> <ref name="def-attendance" /> </element> <element name="grades"> <ref name="def-grades" /> </element> </element> </oneOrMore> </define> <!-- ============================================================================ --> <!-- Attendance Definition --> <!-- ============================================================================ --> <define name="def-attendance"> <oneOrMore> <element name="period"> <ref name="def-date" /> <element name="tardiness"> <choice> <value type="string">Present</value> <value type="string">Late</value> <value type="string">Absent</value> <value type="string">Excused</value> </choice> </element> </element> </oneOrMore> </define> <!-- ============================================================================ --> <!-- Grades Definition --> <!-- ============================================================================ --> <define name="def-grades"> <interleave> <text /> <zeroOrMore> <element name="assignment"> <ref name="def-assignment" /> </element> </zeroOrMore> <zeroOrMore> <element name="midterm"> <ref name="def-exam" /> </element> </zeroOrMore> <optional> <element name="final"> <ref name="def-exam" /> </element> </optional> </interleave> </define> <define name="def-assignment"> <ref name="def-date" /> <element name="assignment-num"> <data type="string"> <param name="pattern">(1)?[0-9]</param> </data> </element> <element name="description"> <ref name="def-MixedText" /> </element> <element name="summary"> <ref name="def-MixedText" /> </element> <ref name="def-grade" /> </define> <define name="def-exam"> <ref name="def-date" /> <element name="start-time"> <ref name="def-time" /> </element> <element name="end-time"> <ref name="def-time" /> </element> <ref name="def-grade" /> </define> <define name="def-grade"> <element name="grade"> <element name="percentage"> <data type="string"> <param name="pattern">\d{1,3}</param> </data> </element> <choice> <element name="letter-grade"> <choice> <value type="string">A</value> <value type="string">B</value> <value type="string">C</value> <value type="string">D</value> <value type="string">F</value> </choice> </element> <element name="passfail-grade"> <choice> <value type="string">P</value> <value type="string">NP</value> </choice> </element> </choice> </element> </define> <!-- ============================================================================ --> <!-- Reuseable Definitions --> <!-- ============================================================================ --> <define name="def-address"> <element name="address"> <text /> </element> <element name="city"> <text /> </element> <element name="state"> <data type="string"> <param name="pattern">[A-Z]{2}</param> </data> </element> <element name="zipcode"> <data type="string" /> </element> <optional> <element name="country"> <text /> </element> </optional> </define> <define name="def-date"> <element name="date"> <data type="string"> <param name="pattern">([1-9]|1[012])-([1-9]|[12][0-9]|3[01])-\d{4}</param> </data> <optional> <attribute name="late"> <choice> <value type="string">Yes</value> <value type="string">No</value> </choice> </attribute> </optional> </element> </define> <define name="def-name"> <element name="first-name"> <data type="string"> <param name="pattern">[A-Z][a-z]*(-[A-Z][a-z]*)*</param> </data> </element> <optional> <element name="initial"> <data type="string"> <param name="pattern">[A-Z]</param> </data> </element> </optional> <element name="last-name"> <data type="string"> <param name="pattern">[A-Z][a-z]*(-[A-Z][a-z]*)*</param> </data> </element> </define> <define name="def-phone"> <data type="string"> <param name="pattern">\d{3}\.\d{3}\.\d{4}</param> </data> </define> <define name="def-time"> <data type="string"> <param name="pattern">(2[0-3]|[01]?[0-9]):[0-5][0-9]:[0-5][0-9]</param> </data> </define> <!-- ============================================================================ --> <!-- MixedText Definition --> <!-- ============================================================================ --> <define name="def-MixedText"> <interleave> <text /> <zeroOrMore> <ref name="Inline" /> </zeroOrMore> </interleave> </define> <!-- ========================================================================== --> <!-- The following is the Relax NG definition for Inline elements which include --> <!-- the Emphasis element and the Strong element. These elements may also --> <!-- contain text or other Inline elements. --> <!-- ========================================================================== --> <define name="Inline" ns="http://www.w3.org/1999/xhtml"> <choice> <element name="em"> <!-- Emphasis Element --> <interleave> <text /> <zeroOrMore> <ref name="Inline" /> </zeroOrMore> </interleave> </element> <element name="strong"> <!-- Strong Emphasis Element --> <interleave> <text /> <zeroOrMore> <ref name="Inline" /> </zeroOrMore> </interleave> </element> </choice> </define> </grammar>