0
4.8kviews
Write DTD rules and Create an XML schema for XML documents.

Subject: Distributed Database

Topic: XML

Difficulty: Medium


University database contains information about the course and the professors who teach the courses in each semester. Each course must also have information about the no. of student enrolled, room no, date and time (when and where the course is conducted)

i) Write DTD rules for above XML documents.

ii) Create an XML schema for above XML documents.

1 Answer
0
241views
<! DOCTYPE UNIVERSITY [
<!ELEMENT UNIVERSITY(course*,professors*)>
<!ELEMENT course(no_of_student_enrolled,room_no,date,time)>
<!ELEMENT professor(cname,sem)>
<!ELEMENT no_of_student_enrolled(#PCDATA)>
<!ELEMENT room_no(#PCDATA)>
<!ELEMENT date(#PCDATA)>
<!ELEMENT time(#PCDATA)>
<!ELEMENT cname(#PCDATA)>
<!ELEMENT sem(#PCDATA)>
]>

XML Schema

<? xml version=”1.0”? encoding=”UTF-8”?>
<xsd:schema xmlns:xsd=https://www.w3.org/2001/XMLSchema>
<xsd:annotation>
    <xsd:documentation xml:lang=”en”>
        University Schema
    </xsd:documentation>
<xsd:element name=”University”>
<xsd:complexType>
    <xsd:sequence>
        <xsd:element name=”course” minOccurs=”0” maxOccurs=”unbounded”>
            <xsd:complexType>
                  <xsd:sequence>
                <xsd:element name=”no_of_student_enrolled” type=”xsd:string”/>
                <xsd:element name=”room_no” type=”xsd:string”/>
                <xsd:element name=”date ” type=”xsd:string”/>
                <xsd:element name=”time” type=”xsd:string”/>
                 </xsd:sequence>
                    </xsd:complexType>
        </xsd:element>
        <xsd:element name=”professor” minOccurs=”0” maxOccurs=”unbounded”>
            <xsd:complexType>
                  <xsd:sequence>
                <xsd:element name=”cname” type=”xsd:string”/>
                <xsd:element name=”sem” type=”xsd:string”/>
                  </xsd:sequence>
                    </xsd:complexType>
        </xsd:element>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Please log in to add an answer.