PCL - WIT - Lab Programs - Part3
PCL - WIT - Lab Programs - Part3
Lab Programs
WEEK-13
Create a DTD to describe a library. Library has one or more books, members and staffs.
Each book has BookID (Attribute), Title, one or more Authors, Publisher Year of
Publication, ISBN and Price.
Each Members has MemeberID (Attribute), Name, Address, Phone number.
Each Staff has StaffID (Attribute), Name, Address, Phone number.
Each Author has AuthorID (Attribute), Name, Address, Phone number.
Each Publisher has PublisherID (Attribute), Name, Address, Phone number.
Use it in a XML document.
AIM: To create a DTD to describe a library application.
DESCRIPTION:
Differences between an XML Schema Definition (XSD) and Document Type Definition
(DTD) include: XML schemas are written in XML while DTD are derived from SGML syntax.
XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes.
XML schemas are extensible while DTD is not extensible.
PROGRAM
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library[
<!ELEMENT library(Books, Members, Staff, Authors, Publishers)>
<!ELEMENT Books(Title, Author, Publisher, Yop, ISBN, Price)>
<!ATTLIST Books BookID #REQUIRED>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Author (#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>
<!ELEMENT Yop (#CDATA)>
<!ELEMENT ISBN (#CDATA)>
<!ELEMENT Price (#CDATA)>
<!ELEMENT Members (Name, Address, Phone_number)>
<!ATTLIST Members MemberID #REQUIRED>
Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 1
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Address (#CDATA)>
<!ELEMENT Phone_number (#CDATA)>
<!ELEMENT Staff (Name, Address, Phone_number)>
<!ATTLIST Staff StaffID #REQUIRED>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Address (#CDATA)>
<!ELEMENT Phone_number (#PCDATA)>
<!ELEMENT Authors (Name, Address, Phone_number)>
<!ATTLIST Authors AuthorID #REQUIRED>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Address (#CDATA)>
<!ELEMENT Phone_number(#CDATA)>
<!ELEMENT Publishers (Name, Address, Phone_number)>
<!ATTLIST Publishers PublisherID #REQUIRED>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Address (#CDATA)>
<!ELEMENT Phone_number (#CDATA)>
]>
<library>
<Books BookID='502'>
<Title>How to program HTML</Title>
<Author>Vikram Nivas</Author>
<Publisher>PEARSON</Publisher>
<Yop>2005</Yop>
<ISBN>182-420-994</ISBN>
<Price>2000</Price>
</Books>
<Members MemeberID='2206'>
<Name>GaaMa</Name>
<Address>Anantapur</Address>
<Phone_number>9849913200</Phone_number>
</Members>
<Staff StaffID='771'>
<Name>Dr. P. Chitralingappa</Name>
<Address>4/553,Anantapur</Address>
Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 2
<Phone_number>9849913200</Phone_number>
</Staff>
<Authors AuthorID='101'>
<Name>T. Murali Krishna</Name>
<Address>2/44,Banglore</Address>
<Phone_number>9849913200</Phone_number>
</Authors>
<Publishers PublisherID='241994'>
<Name>BUUCKS</Name>
<Address>Chennai</Address>
<Phone_number>9849913200</Phone_number>
</Publishers>
</library>
OUTPUT:
RESULT:
DESCRIPTION:
Differences between an XML Schema Definition (XSD) and Document Type
Definition (DTD) include: XML schemas are written in XML while DTD are derived from
SGML syntax. XML schemas define datatypes for elements and attributes while DTD doesn't
support datatypes. XML schemas are extensible while DTD is not extensible.
Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 4
PROGRAM:
<?xml version="1.0"?>
<!DOCTYPE Computers[
<!ELEMENT computers(computers+)>
<!ELEMENT
computers(monitor,keyboard,mouse,motherboard,power,harddisk+,RAM+)>
<!ATTRLIST Computer Type (Desktop PC|Laptop|Palmtop|Server
|Minicomputer|Mainframe) #REQUIRED>
<!ELEMENT monitor(make,model,YOM,size,Type)>
<!ATTLIST monitor serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>
<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT size(#PCDATA)>
<!ELEMENT Type(#PCDTA|color|monochrome)>
<!ELEMENT keyboard (make, model, YOM, nok, Type)>
<!ATTLIST keyboard serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>
<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT nok(#PCDATA)>
<!ELEMENT Type(#PCDTA|standard|enhanced|multimedia)>
<!ELEMENT mouse(make,model,YOM,nob,scrollwheel,Type)>
<!ATTLIST mouse serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>
<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT nod(#PCDATA)>
<!ELEMENT scrollwheel(#PCDATA|yes|no)>
<!ELEMENT Type(#PCDTA|ball|optical)>
<!ELEMENT motherboard (make, model, YOM, nup, nIDES, nsh, nPCIS, displaytype,
nps, TOPS, TRS, mcRAM, FormFactor, OBSC)>
OUTPUT:
RESULT:
DESCRIPTION:
Differences between an XML Schema Definition (XSD) and Document Type Definition
(DTD) include: XML schemas are written in XML while DTD are derived from SGML syntax.
XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes.
XML schemas are extensible while DTD is not extensible.
PROGRAM
<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="computers">
<xs:complexType>
<xs:sequence>
<xs:element name="computer">
<xs:complexType>
<xs:sequence>
<xs:element name="monitor">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="make"/>
<xs:element type="xs:string" name="model"/>
<xs:element type="xs:short" name="yearof_manufacture"/>
<xs:element type="xs:string" name="size"/>
<xs:element type="xs:string" name="Type"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="keyboard">
Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 10
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="make"/>
<xs:element type="xs:string" name="model"/>
<xs:element type="xs:short" name="yearof_manufacture"/>
<xs:element type="xs:byte" name="no_ofkeys"/>
<xs:element type="xs:string" name="Type"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="mouse">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="make"/>
<xs:element type="xs:string" name="model"/>
<xs:element type="xs:short" name="yearof_manufacture"/>
<xs:element type="xs:byte" name="no_ofbuttons"/>
<xs:element type="xs:string" name="scroll_wheel"/>
<xs:element type="xs:string" name="Type"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="motherboard">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="make"/>
<xs:element type="xs:string" name="model"/>
<xs:element type="xs:short" name="yearof_manufacture"/>
<xs:element type="xs:string" name="no_ofUSBports"/>
<xs:element type="xs:byte" name="no_ofIDE_slots"/>
<computers>
<computer>
<monitor serial_no='1'>
<make>DELL</make>
<model>corei5</model>
<yearof_manufacture>2009</yearof_manufacture>
<size>32 inch</size>
<Type>pc</Type>
</monitor>
<keyboard serial_no='2'>
<make>keyboard</make>
<model> lenovo</model>
<yearof_manufacture>2010</yearof_manufacture>
<no_ofkeys>101</no_ofkeys>
<Type>Virtual Keyboard</Type>
</keyboard>
<mouse serial_no='3'>
<make>plastic</make>
<model>DELL</model>
<yearof_manufacture>2011</yearof_manufacture>
<no_ofbuttons>2</no_ofbuttons>
<scroll_wheel>hard plastic</scroll_wheel>
<Type>Optical Mouse</Type>
</mouse>
<motherboard serial_no='4'>
<make>GIGA BYTE TECHNOLOGY</make>
RESULT:
The Schema is successfully created for a computer.
DESCRIPTION:
Differences between an XML Schema Definition (XSD) and Document Type Definition
(DTD) include: XML schemas are written in XML while DTD are derived from SGML syntax.
XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes.
XML schemas are extensible while DTD is not extensible.
PROGRAM:
<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="Books">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="Title"/>
<xs:element type="xs:string" name="Author"/>
<xs:element type="xs:string" name="Publisher"/>
<xs:element type="xs:short" name="Yop"/>
<xs:element type="xs:string" name="ISBN"/>
<xs:element type="xs:short" name="Price"/>
</xs:sequence>
<xs:attribute type="xs:short" name="BookID"/>
</xs:complexType>
</xs:element>
<xs:element name="Members">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="Name"/>
<xs:element type="xs:string" name="Address"/>
<xs:element type="xs:long" name="Phone_number"/>
OUTPUT:
The Schema is successfully created for a library.
RESULT:
The Schema is successfully created for a library.
AIM: To create a DTD to describe a bank that has one or more customers, accounts, or employee.
DESCRIPTION:
Differences between an XML Schema Definition (XSD) and Document Type Definition
(DTD) include: XML schemas are written in XML while DTD are derived from SGML syntax.
XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes.
XML schemas are extensible while DTD is not extensible.
PROGRAM
OUTPUT:
RESULT:
AIM: To create a schema for a bank has one or more customers, accounts or developers.
DESCRIPTION:
Differences between an XML Schema Definition (XSD) and Document Type Definition
(DTD) include: XML schemas are written in XML while DTD are derived from SGML syntax.
XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes.
XML schemas are extensible while DTD is not extensible.
PROGRAM:
OUTPUT:
The Schema is successfully created for bank.
RESULT:
The Schema is successfully created for bank.
Note:
Online Editors:
https://www.freeformatter.com/xsd-generator.html
Above XML Program use XMLBlueprint Editor.
Download and install using Below link:
https://www.xmlblueprint.com/