0% found this document useful (0 votes)
42 views24 pages

PCL - WIT - Lab Programs - Part3

The document describes creating a DTD to define the structure of a library. The DTD defines elements for books, members, staff, authors, and publishers. Each element has child elements to specify attributes like name, address, and phone number. An XML file is then created using the defined DTD.

Uploaded by

RAVI TEJA M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views24 pages

PCL - WIT - Lab Programs - Part3

The document describes creating a DTD to define the structure of a library. The DTD defines elements for books, members, staff, authors, and publishers. Each element has child elements to specify attributes like name, address, and phone number. An XML file is then created using the defined DTD.

Uploaded by

RAVI TEJA M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Web & Internet Technology

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:

The DTD program has created successfully.

RESULT:

The DTD program has created successfully.

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 3


WEEK-14
Create a DTD to describe a computer. A computer has following details,
 Type of computer (this is an attribute), Which can be Desktop PC, Laptop, Palm Top,
Server, Minicomputer or mainframe)
 A Monitor with Serial Number (Attribute), Make, Model, Year of manufacture, Size,
Type (which is either color or monochrome)
 A keyboard with Serial Number (Attribute), Make, Model, Year of manufacture, no of
keys, Type (which is either Standard or Enhanced or Multimedia)
 A mouse with Serial Number (Attribute), Make, Model, Year of manufacture, no of
buttons, scroll wheel (which is yes or no), Type (Which is Ball or Optical)
 A Mother board with Serial Number (Attribute), Make, Model, Year of manufacture,
No of USB ports, No of IDE slots, No of SATA hubs, No of PCI slots, Display Type
(Which is VGA or HDMI), Number of Processor slots, Type of Processors supported
(must be a list), Type of RAM supported (Which is either SD or DDR1 or DDR2 or
RD), Maximum Capacity of RAM, Form Factor (which is either AT or Baby AT), On
Board sound card (Which is yes or no)
 A Microprocessor with Serial Number (Attribute), Make, Model, Year of manufacture,
speed (inGHz), No of Cores (Single, Dual, Quad)
 A power supply with Serial Number (Attribute), Make, Model, Year of manufacture,
Type (AT, ATX), Wattage
 One or more hard disks, each Hard disk must have Serial Number (Attribute), Make,
Model, Year of manufacture, capacity and type (Which is IDE or SATAI or SATAII,
SCSI)
 One or more RAM SIMM, with Serial Number (Attribute), Make, Model, Year of
manufacture, Type (which must be SD, DDRI, DDRII, RD), capacity, operating
frequency. Use it in a XML document.

AIM: To create a DTD to describe 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.
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)>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 5


<!ATTLIST motherboard serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>
<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT nup(#PCDATA)>
<!ELEMENT nIDES(#PCDATA)>
<!ELEMENT nsh(#PCDTA)>
<!ELEMENT nPCIS(#CDATA)>
<!ELEMENT displaytype(#PCDATA|VGA|HDMI)>
<!ELEMENT nps(#CDATA)>
<!ELEMENT TOPS(#PCDATA)>
<!ELEMENT mcRAM(#PCDATA)>
<!ELEMENT TRS(#PCDATA|SD|DDR1|DDR2|RD)>
<!ELEMENT FormFactor(#CDATA|AT|BabyAT)>
<!ELEMENT OBSC(#PCDATA)>
<!ELEMENT microprocessor(make,model,YOM,speed,noc)>
<!ATTLIST microprocessor serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>
<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT speed(#PCDATA)>
<!ELEMENT noc(#PCDATA)>
<!ELEMENT powersupply(make,model,YOM,type,wattage)>
<!ATTLIST powersupply serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>
<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT Type(#PCDTA|AT|ATX)>
<!ELEMENT wattage(#PCDATA)>
<!ELEMENT RAM(make,model,YOM,capacity,,Type)>
<!ATTLIST RAM serialno #REQUIRED>
<!ELEMENT make(#PCDATA)>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 6


<!ELEMENT model(#PCDATA)>
<!ELEMENT YOM(#CDATA)>
<!ELEMENT capacity(#PCDATA)>
<!ELEMENT Type(#PCDTA|IDE|SATA|SATAII|SCSI)>
]>
<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>
<model>P67A-UD3</model>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 7


<yearof_manufacture>2012</yearof_manufacture>
<no_ofUSBports>5|6|7</no_ofUSBports>
<no_ofIDE_slots>4</no_ofIDE_slots>
<no_ofSATA_hubs>1-6</no_ofSATA_hubs>
<no_ofPCI_slots>4</no_ofPCI_slots>
<Display_Type>SOCKET TYPE</Display_Type>
<no_of_processor_slots>CPU SLOT</no_of_processor_slots>
<Type_of_processors_supported>ASUS </Type_of_processors_supported>
<Type_of_RAM_supported>DDR6 and DDR7</Type_of_RAM_supported>
<maximum_capacity_of_RAM>128 GB</maximum_capacity_of_RAM>
<form_factor>ATX</form_factor>
<on_board_sound_card>ALC892,887 and 1220</on_board_sound_card>
</motherboard>
<Microprocessor serial_no='5'>
<make>AMD</make>
<model>Core i8</model>
<yearof_manufacture>2013</yearof_manufacture>
<speed>3.5 GHZ</speed>
<no_of_cores>MULTIPLE</no_of_cores>
</Microprocessor>
<powerssupply serial_no='6'>
<make>MS-03</make>
<model>Eapl</model>
<yearof_manufacture>2014</yearof_manufacture>
<Type>ATX-2 Power Supply</Type>
<Wattage>670 walts</Wattage>
</powerssupply>
<harddisk serial_no='7'>
<make>X300</make>
<model>samsung</model>
<yearof_manufacture>2015</yearof_manufacture>
<capacity>512 bytes</capacity>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 8


<Type>seagate 2TB 7500 RPM</Type>
</harddisk>
<RAM serial_no='8'>
<make>paperclip</make>
<model>axon 10</model>
<yearof_manufacture>2016</yearof_manufacture>
<Type>aluminum</Type>
<capacity>64kb</capacity>
<operating_frequency>2400MHZ</operating_frequency>
</RAM>
</computer>
</computers>

OUTPUT:

The DTD program has created successfully.

RESULT:

The DTD program has created successfully.

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 9


WEEK-15
Create a Schema to describe a computer. Use the previous question’s details and show an
instance XML document.

AIM: To create a schema 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="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"/>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 11


<xs:element type="xs:string" name="no_ofSATA_hubs"/>
<xs:element type="xs:byte" name="no_ofPCI_slots"/>
<xs:element type="xs:string" name="Display_Type"/>
<xs:element type="xs:string" name="no_of_processor_slots"/>
<xs:element type="xs:string" name="Type_of_processors_supported"/>
<xs:element type="xs:string" name="Type_of_RAM_supported"/>
<xs:element type="xs:string" name="maximum_capacity_of_RAM"/>
<xs:element type="xs:string" name="form_factor"/>
<xs:element type="xs:string" name="on_board_sound_card"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="Microprocessor">
<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="speed"/>
<xs:element type="xs:string" name="no_of_cores"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="powerssupply">
<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="Type"/>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 12


<xs:element type="xs:string" name="Wattage"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="harddisk">
<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="capacity"/>
<xs:element type="xs:string" name="Type"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
<xs:element name="RAM">
<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="Type"/>
<xs:element type="xs:string" name="capacity"/>
<xs:element type="xs:string" name="operating_frequency"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="serial_no"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 13


</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

<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>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 14


<model>P67A-UD3</model>
<yearof_manufacture>2012</yearof_manufacture>
<no_ofUSBports>5|6|7</no_ofUSBports>
<no_ofIDE_slots>4</no_ofIDE_slots>
<no_ofSATA_hubs>1-6</no_ofSATA_hubs>
<no_ofPCI_slots>4</no_ofPCI_slots>
<Display_Type>SOCKET TYPE</Display_Type>
<no_of_processor_slots>CPU SLOT</no_of_processor_slots>
<Type_of_processors_supported>ASUS </Type_of_processors_supported>
<Type_of_RAM_supported>DDR6 and DDR7</Type_of_RAM_supported>
<maximum_capacity_of_RAM>128 GB</maximum_capacity_of_RAM>
<form_factor>ATX</form_factor>
<on_board_sound_card>ALC892,887 and 1220</on_board_sound_card>
</motherboard>
<Microprocessor serial_no='5'>
<make>AMD</make>
<model>Core i8</model>
<yearof_manufacture>2013</yearof_manufacture>
<speed>3.5 GHZ</speed>
<no_of_cores>MULTIPLE</no_of_cores>
</Microprocessor>
<powerssupply serial_no='6'>
<make>MS-03</make>
<model>Eapl</model>
<yearof_manufacture>2014</yearof_manufacture>
<Type>ATX-2 Power Supply</Type>
<Wattage>670 walts</Wattage>
</powerssupply>
<harddisk serial_no='7'>
<make>X300</make>
<model>samsung</model>
<yearof_manufacture>2015</yearof_manufacture>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 15


<capacity>512 bytes</capacity>
<Type>seagate 2TB 7500 RPM</Type>
</harddisk>
<RAM serial_no='8'>
<make>paperclip</make>
<model>axon 10</model>
<yearof_manufacture>2016</yearof_manufacture>
<Type>aluminum</Type>
<capacity>64kb</capacity>
<operating_frequency>2400MHZ</operating_frequency>
</RAM>
</computer>
</computers>
OUTPUT:
The Schema is successfully created for a computer.

RESULT:
The Schema is successfully created for a computer.

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 16


WEEK-16
Create a Schema to describe a library. Library has one or more - books, members
 Each Staff has StaffID (Attribute), Name, Address, Phone
 Each Member has MemeberID (Attribute), Name, Address, Phone number.
 Each book has BookID (Attribute), Title, one or more Authors, Publisher Year of
Publication, ISBN and Price.
 Each Author has AuthorID (Attribute), Name, Address, Phone number
 Each Publisher has PublisherID (Attribute), Name, Address, Phone number.
 Use the above DTD in a sample XML document.

AIM: To create a schema to describe a library.

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"/>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 17


</xs:sequence>
<xs:attribute type="xs:short" name="MemeberID"/>
</xs:complexType>
</xs:element>
<xs:element name="Staff">
<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"/>
</xs:sequence>
<xs:attribute type="xs:short" name="StaffID"/>
</xs:complexType>
</xs:element>
<xs:element name="Authors">
<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"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="AuthorID"/>
</xs:complexType>
</xs:element>
<xs:element name="Publishers">
<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"/>
</xs:sequence>
<xs:attribute type="xs:int" name="PublisherID"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

OUTPUT:
The Schema is successfully created for a library.
RESULT:
The Schema is successfully created for a library.

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 18


WEEK-17
Create a DTD to describe a bank that has one or more customers, accounts or Employee.
 Each Customerhas a Customer ID, Name and address.
 Each account has an account ID, BranchID, CustomerID, AccountType and Balance.
 Each Employee has aEmpID, Name, Designation, DOJ, Salary and Address.
 Use this DTD in a XML file.

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

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


<!DOCTYPE Bank [
<!ELEMENT Bank (Customer, account, Employee)>
<!ATTLIST Bank
xmlns CDATA #FIXED ''>

<!ELEMENT Customer (Name, Address)>


<!ATTLIST Customer
xmlns CDATA #FIXED ''
CustomerID CDATA #REQUIRED>

<!ELEMENT account (BranchID,CustomerID,AccountType,Balance)>


<!ATTLIST account
xmlns CDATA #FIXED ''
accountID CDATA #REQUIRED>

<!ELEMENT Employee (Name,Designation,DOJ,Salary,Address)>


<!ATTLIST Employee
xmlns CDATA #FIXED ''
EmpID CDATA #REQUIRED>

<!ELEMENT BranchID (#PCDATA)>


<!ATTLIST BranchID
xmlns CDATA #FIXED ''>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 19


<!ELEMENT CustomerID (#PCDATA)>
<!ATTLIST CustomerID
xmlns CDATA #FIXED ''>

<!ELEMENT AccountType (#PCDATA)>


<!ATTLIST AccountType
xmlns CDATA #FIXED ''>

<!ELEMENT Balance (#PCDATA)>


<!ATTLIST Balance
xmlns CDATA #FIXED ''>

<!ELEMENT Designation (#PCDATA)>


<!ATTLIST Designation
xmlns CDATA #FIXED ''>

<!ELEMENT DOJ (#PCDATA)>


<!ATTLIST DOJ
xmlns CDATA #FIXED ''>

<!ELEMENT Salary (#PCDATA)>


<!ATTLIST Salary
xmlns CDATA #FIXED ''>

<!ELEMENT Name (#PCDATA)>


<!ATTLIST Name
xmlns CDATA #FIXED ''>

<!ELEMENT Address (#PCDATA)>


<!ATTLIST Address
xmlns CDATA #FIXED ''>
]>
<Bank>
<Customer CustomerID="502">
<Name>Vikram Nivas</Name>
<Address>Anantapur</Address>
</Customer>
<account accountID="30487672">
<BranchID>960</BranchID>
<CustomerID>505</CustomerID>
<AccountType>savings</AccountType>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 20


<Balance>200000</Balance>
</account>
<Employee EmpID="771">
<Name>GaaMa</Name>
<Designation>BTECH</Designation>
<DOJ>22-06-2019</DOJ>
<Salary>20000</Salary>
<Address>25/578</Address>
</Employee>
</Bank>

OUTPUT:

The DTD program has created successfully.

RESULT:

The DTD program has created successfully.

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 21


WEEK-18
Crete a schema describes a bank that has one or more customers, accounts or depositors. Use
the previous question details. Also show a sample instance XML document

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:

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


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Bank">
<xs:complexType>
<xs:sequence>
<xs:element ref="Customer"/>
<xs:element ref="account"/>
<xs:element ref="Employee"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element ref="Name"/>
<xs:element ref="Address"/>
</xs:sequence>
<xs:attribute name="CustomerID" use="required" type="xs:integer"/>
</xs:complexType>
</xs:element>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 22


<xs:element name="account">
<xs:complexType>
<xs:sequence>
<xs:element ref="BranchID"/>
<xs:element ref="CustomerID"/>
<xs:element ref="AccountType"/>
<xs:element ref="Balance"/>
</xs:sequence>
<xs:attribute name="accountID" use="required" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="BranchID" type="xs:integer"/>
<xs:element name="CustomerID" type="xs:integer"/>
<xs:element name="AccountType" type="xs:NCName"/>
<xs:element name="Balance" type="xs:integer"/>
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element ref="Name"/>
<xs:element ref="Designation"/>
<xs:element ref="DOJ"/>
<xs:element ref="Salary"/>
<xs:element ref="Address"/>
</xs:sequence>
<xs:attribute name="EmpID" use="required" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="Designation" type="xs:NCName"/>
<xs:element name="DOJ" type="xs:NMTOKEN"/>
<xs:element name="Salary" type="xs:integer"/>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Address" type="xs:string"/>

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 23


</xs:schema>
<Bank>
<Customer CustomerID="502">
<Name>Vikram Nivas</Name>
<Address>Anantapur</Address>
</Customer>
<account accountID="30487672">
<BranchID>960</BranchID>
<CustomerID>505</CustomerID>
<AccountType>savings</AccountType>
<Balance>200000</Balance>
</account>
<Employee EmpID="771">
<Name>GaaMa</Name>
<Designation>BTECH</Designation>
<DOJ>22-06-2019</DOJ>
<Salary>20000</Salary>
<Address>25/578</Address>
</Employee>
</Bank>

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/

Dr. P. CHITRALINGAPPA III BTECH-II SEM Page 24

You might also like