WT Lab Manual
WT Lab Manual
Objectives:
To introduce client side scripting with Javascript and DHTML
To introduce server side programming with Java servlets, JSP and PHP.
To learn the basic web concepts and Internet protocols
List of Experiments/Tasks
1. To create a simple student bio-data form using html5 . it should contain the following
name (text box), address (multiline text box),gender (radio button male, female),skill sets
known (check boxes – , c++, java, C# etc), extra- curricular
activities (text box), nationality (combo box) ,submit and reset button.
2. To create an html page with different types of frames such as floating frame, navigation
frame & mixed frame.
3. Design the webpage by applying the different styles using inline, external & internal style
sheets.
4. Write a java script program to read .XML file and display data in a neat format.
5. To write a Javascript program to define a user defined function for sorting the values in an
array. Use HTML5 for user interface.
6. To create an html page to demonstrate exception handling in javascript Create an html page
named as ―exception.html‖ and do the following.
i. within the script tag write code to handle exception
a) define a method RunTest() to get any string values(str) from the user and call the
method Areletters(str).
b) In Areletters(str) method check whether str contain only alphabets (a-z, A- Z), if not
throw exception.
c) Define a exception method Input Exception(str) to handle the exception thrown by the
above method.
ii. Within the body tag define a script tag to call Runtest() method define.
7. Write a jsp servlet program to implement the single text field calculator.
8. Write a jsp servlet program to demonstrate session handling using
– url rewriting
--hidden formfield
--cookies
--sessions
9. To create a php program to demonstrate the different predefined function in array, Math,
Data & Regular Expression.
Procedure:
Create php file named as Regularexpression.php
for demonstrating the method for handling various strings with regular
expression Array.php
XML document.
16. Create a Schema 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 Member 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 the above
DTD in a sample XML document.
17. Create a DTD to describe a bank that has one or more customers, accounts or Employee.
• Each Customer has a Customer ID, Name and address.
• Each account has an account ID, BranchID, CustomerID, Account Type and Balance.
• Each Employee has aEmpID, Name, Designation, DOJ, Salary and Address. Use this DTD
in a XML file.
18. Create Schema describe a bank that has one or more customers, accounts or depositors. Use
the previous questions details. Also show a sample instance XML document.
Outcomes:
Ability to create dynamic and interactive web sites.
Gain knowledge of client side scripting using java sript and DHTML.
Demonstrate understanding of what is XML and how to parse and use XML data
Able to do server side programming with Java Servelets, JSP and PHP
1. To create a simple student bio-data form using html5 . it should contain the following
name (text box), address (multiline text box),gender (radio button male,female),skill sets
known (check boxes – c,c++,java,C#etc), extra curricular activities (text box), nationality
(combobox) ,submit and reset button.
<html>
<head>
<script type="text/javascript" src="validate.js"></script>
</head>
<body>
<form action="#" name="StudentRegistration" onsubmit="return(validate());">
<tr>
<td colspan=2>
<center><font size=4><b>Student Bio-Data Form</b></font></center>
</td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="textnames" id="textname" size="30"></td>
</tr>
<tr>
<td>Address</td>
<td>
<textarea name="address" cols="30" rows="5"></textarea>
</td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="sex" value="male" size="10">Male
<input type="radio" name="sex" value="Female" size="10">Female</td>
</tr>
<tr>
<tr>
<td><label>skill sets known</label></td></tr>
<tr>
<tr><td><input type="checkbox" name="lang" value="c">C</td>
<td><input type="checkbox" name="lang" value="cpp">C++</td>
</tr>
<tr>
<td><input type="checkbox" name="lang" value="java">Java</td>
<td><input type="checkbox" name="lang" value="csharp">C#</td>
</tr>
<tr>
<td>Extra Curriculam Activities</td>
<td><input type="text" name="pincode" id="pincode" size="30"></td>
</tr>
<tr>
<td>Nationality</td>
<td><select Name="State">
<option value="-1" selected>select..</option>
<option value="New Del34edxhi">Indian</option>
<option value="Mumbai">German</option>
<option value="Goa">Italian </option>
</select></td>
</tr>
<tr>
<td><input type="reset"></td>
<td colspan="2"><input type="submit" value="Submit Form" /></td>
</tr>
</table>
</form>
</body>
</html>
Validate.js
//<script type="text/javascript">
function validate()
{
if( document.StudentRegistration.textnames.value == "" )
{
alert( "Please provide your Name!" );
document.StudentRegistration.textnames.focus() ;
return false;
}
var a = document.StudentRegistration.address.value;
if(a=="")
{
alert("please Enter the Address details");
document.form.address.focus();
return false;
}
return( true );
}
//</script>
Output:
2. To create an html page with different types of frames such as floating frame, navigation frame &
mixed frame
Mainpage.html
<html>
<body>
<a href="frames.html" target="two">navigation frame</a><br>
<a href="floatingframe.html" target="two">floating frame</a><br>
<a href="Noframe.html" target="two">no frame</a><br>
<a href="mixedframe.html" target="two">mixed frame</a><br>
</body>
</html>
Frame.html
<html>
<frameset cols="20%,35%,*" scrolling="no" noresize>
<frame name="one" src="MainPage.html"></frame>
<frame src="aa.gif"></frame>
<frame name="two" src="hulk.gif"></frame>
</frameset>
</html>
Floatingframe.html
<html>
<body>
<p> Explanation: There is a problem with the page you are trying to reach and it
cannot be displayed.
Try the following: * Refresh page: Search for the page again by clicking the Refresh
button. The timeout may have occurred due to Internet congestion.
* Check spelling: Check that you typed the Web page address correctly. The
address may have been mistyped.
* Access from a link: If there is a link to the page you are looking for, try accessing
the page from that link.
If you are still not able to view the requested page, try contacting you
<iframe src="bb.gif" height="225" width="500">
</iframe>
<iframe src="MainPage.html" height="50%" width="50%">
</iframe>
</body>
</html>
Mixedframe.html
<html>
<frameset cols="30%,*">
<frame src="pic.html"></frame>
<frameset rows="50%,*">
<frame src="video.html" autostart="true">
<frame src="Q3.html" >
</frameset>
</frameset>
</html>
navigationframe.html
<html>
<frameset cols="25%,*" scrolling="no" noresize>
<frame name="one" src="MainPage.html">
</frame>
<frame name="two" ></frame>
<frameset rows="30%,*">
<frame src="hulk.gif">
</frame>
</frameset>
</html>
Output:
3. Design the webpage by applying the different styles using inline, external & internal style sheets.
Inline:
<html>
<head> Inline Web Page </head>
<body>
<h1 style="color:blue;">This is a Blue Heading</h1>
</body>
</html>
Internal:
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
External:-
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output:
4. Write a java script program to read .XML file and display data in a neat format.
Xml.xml
<?xml version="1.0"?>
<company>
<employee>
<name>King</name>
<age>30</age>
<salary>30000</salary>
</employee>
</company>
</xml>
Xml.html
<html>
<head>
<title>Reading HTML File</title>
<script type="text/javascript">
function readXML()
{
var xml=new XMLHttpRequest();
xml.open('GET','xml.xml',false);
xml.send();
var xmlData=xml.responseXML;
if(!xmlData)
{
xmlData=(new DOMParser()).parseFromString
(xml.responseText,'text/xml');
var emp=xmlData.getElementsByTagName("employee");
var name=emp[0].getElementsByTagName("name")
[0].firstChild.data;
var name=emp[0].getElementsByTagName("age")
[0].firstChild.data;
var name=emp[0].getElementsByTagName("salary")
[0].firstChild.data;
document.write("Name="+name+"<br>");
document.write("Age="+age+"<br>");
document.write("Salary="+salary+"<br>");
}
}
</script>
</head>
<body>
<h1>XML File</h1>
<button onclick="readXML()">Read XML File</button>
</body>
</html>
Output:
5. To write a Javascript program to define a user defined function for sorting the values in an array.
Use HTML5 for user interface.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Array Sort</h2>
<p>Click the button to sort the array in ascending order.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
var points = [40, 100, 1, 5, 25, 10];
document.getElementById("demo").innerHTML = points;
function myFunction() {
points.sort(function(a, b){return a - b});
document.getElementById("demo").innerHTML = points;
}
</script>
</body>
</html>
Output:
<html>
<head>
<script type="text/javascript" language="javascript">
function InputException(msg)
{
this.val = msg;
this.toString = function()
{
return "Input Exception in = "+this.val;
}
}
function AreLetters(msg)
{
var input = msg;
var re = new RegExp("[^a-zA-Z]");
if(input.match(re))
{
oops = new InputException(input);
throw oops;
}
else
{
document.write("<br>"+input);
}
}
function RunTest()
{
var input = prompt("type something","");
try
{
AreLetters(input);
}
catch(e)
{
document.write("<br>exception occured and caught"+e.toString());
}
document.write("<h1>Exception Handling</h1>");
}
</script>
</head>
<body>
<script language="javascript" type="text/javascript">
RunTest();
</script>
</body>
</html>
Output:
7. Write a jsp servlet program to implement the single text field calculator.
Calculator.html
<html>
<title>calculator</title>
<head><h1><center>Basic Calculator</center></h1></head>
<body>
<center>
<form action="calculator.jsp" method="get">
</body>
</html>
Calculator.jsp
<html>
<title>calculator</title>
<head></head>
<body>
<%@page language="java"%>
<%
int num1 = Integer.parseInt(request.getParameter("num1"));
int num2 = Integer.parseInt(request.getParameter("num2"));
if(operation.equals("Add")){
int add=num1+num2;
out.println("Addition is: "+add);
}
else if(operation.equals("Sub")){
int sub=num1-num2;
out.println("Substraction is: "+sub);
}
else if(operation.equals("mul")){
int mul=num1*num2;
out.println("multiplication is: "+mul);
}
else if(operation.equals("div"))
{ int div = num1/num2;
if(num1>=num2)
out.println("division is: "+div);
else
out.println("The division cannot be performed");
}
%>
</body>
</html>
Output:
Index.html
<form action="servlet1">
Name:<input type="text" name="userName"/><br/>
<input type="submit" value="go"/>
</form>
FirstServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
session.setAttribute("name",n);
}catch(Exception e){System.out.println(e);}
}
SecondServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SecondServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
try{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Cookie ck[]=request.getCookies();
out.print(“Hello”+ck[0].getValue());
HttpSession session=request.getSession(false);
String n=(String)session.getAttribute(“uname”);
out.print(“Session”+n);
out.close();
}catch(Exception e){System.out.println(e);}
}
}
web.xml
<web-app>
<servlet>
<servlet-name>s1</servlet-name>
<servlet-class>FirstServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s1</servlet-name>
<url-pattern>/servlet1</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>s2</servlet-name>
<servlet-class>SecondServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s2</servlet-name>
<url-pattern>/servlet2</url-pattern>
</servlet-mapping>
</web-app>
Output:
9. To create a php program to demonstrate the different predefined function in array, Math, Data &
Regular Expression.
<!DOCTYPE html>
<html>
<body>
<?php
//math functions
echo(abs(6.7) . "<br>");
echo(floor(0.60) . "<br>");
echo(pow(2,4) . "<br>");
echo(round(0.60) . "<br>");
//add date
$date=date_create("2013-03-15");
date_add($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
//array values
$cars=array("Volvo","BMW","Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
</body>
</html>
Output:
10. Write a program in PHP for a simple email processing with attachment using forms
<?php
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject,
$message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
+ng(1)+"password is"+rs.getString(2)+"</h1>"); }
con.close();
else if(ch==2)
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","hrushi");
PreparedStatement pt=con.prepareStatement(sql);
int i=pt.executeUpdate();
out.println("<h1>insertion succeeded");
Statement st=con.createStatement();
while(rs.next())
con.close(); }
else if(ch==3)
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","hrushi");
PreparedStatement pt=con.prepareStatement(sql);
int i=pt.executeUpdate();
if(i!=-1)
out.println("<h1>deletion succeeded");
Statement st=con.createStatement();
while(rs.next())
con.close();
Else {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","hrushi");
Statement st=con.createStatement();
while(rs.next())
f=1;
else
f=0;
if(f==1)
else
con.close(); } }
catch(Exception e) { e.printStackTrace(); }
} } }
Web.xml:
<web-app >
<servlet>
<servlet-name>week13pgm</servlet-name>
<servlet-class>week13pgm</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>week13pgm</servlet-name>
<url-pattern>/thetwo</url-pattern>
</servlet-mapping>
</web-app>
Result:
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 Member 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.
Code:
lib.xml: It contains five elements named book, member, staff, author and publisher.
<Library>
<Book>
<b_id>1001</b_id>
<b_author>Bill Gates</b_author>
<b_publisher>Tata</b_publisher>
<b_year>2000</b_year>
<b_isbn>2234</b_isbn>
<b_price>800</b_price>
</Book>
<Member>
<m_id>1</m_id>
<m_name>Rajesh</m_name>
<m_address>Khadi Colony</m_address>
<m_phone>9900990099</m_phone>
</Member>
<Staff>
<s_id>2</s_id>
<s_name>Rakul</s_name>
<s_address>Puttur</s_address>
<s_phone>8899009900</s_phone>
</Staff>
<Author>
<a_id>3</a_id>
<a_name>Bill Gates</a_name>
<a_address>USA</a_address>
<a_phone>4177990099</a_phone>
</Author>
<Publisher>
<p_id>4</p_id>
<p_name>Tata</p_name>
<p_address>Delhi</p_address>
<p_phone>9966996699</p_phone>
</Publisher>
<Book>
<b_id>1002</b_id>
<b_author>Herbert Schildt</b_author>
<b_publisher>Tata</b_publisher>
<b_year>2004</b_year>
<b_isbn>24</b_isbn>89
<b_price>600</b_price>
</Book>
<Member>
<m_id>5</m_id>
<m_name>Kanna</m_name>
<m_address>Tirupathi</m_address>
<m_phone>9966778999</m_phone>
</Member>
<Staff>
<s_id>6</s_id>
<s_name>Robert</s_name>
<s_address>Nagari</s_address>
<s_phone>8899008877</s_phone>
</Staff>
<Author>
<a_id>6</a_id>
<a_name>Herbert Schildt</a_name>
<a_address>London</a_address>
<a_phone>4177996677</a_phone>
</Author>
<Publisher>
<p_id>8</p_id>
<p_name>Tata</p_name>
<p_address>Delhi</p_address>
<p_phone>9966996699</p_phone>
</Publisher>
</Library>
<!ELEMENT b_id(#PCDATA)>
<!ELEMENT m_id(#PCDATA)>
<!ELEMENT s_id(#PCDATA)>
<!ELEMENT Author(a_id,a_name,a_address,a_phone)>
<!ELEMENT a_id(#PCDATA)>
<!ELEMENT Publisher(p_id,p_name,p_address,p_phone)>
<!ELEMENT p_id(#PCDATA)>
Output:
Comp.xml: It contains type, monitor, keyboard, mouse, microprocessor, powersupply, HDD, RAM
elements.
<Computer>
<Type>Desktop</Type>
<Monitor>
<m_sno>2341</m_sno>
<m_make>Dell</m_make>
<m_model>LED</m_model>
<m_year>2015</m_year>
<m_size>17</m_size>
<m_type>Color</m_type>
</Monitor>
<Keyboard>
<k_sno>7890</k_sno>
<k_make>Samsung</k_make>
<k_model>USB</k_model>
<k_year>2015</k_year>
<k_keynos>128<\k_keynos>
<k_type>Multimedia</k_type>
</<Keyboard>
<Mouse>
<mo_sno>5678</mo_sno>
<mo_make>logitech</mo_make>
<mo_model>USB</mo_model>
<mo_year>2015</mo_year>
<mo_nobuttons>2<\mo_nobuttons>
<mo_scroll>yes</mo_scroll>
<mo_type>ball</mo_type>
</Mouse>
<MicroProcessor>
<mp_sno>1234</mp_sno>
<mp_make>intel</mp_make>
<mp_model>Chip</mp_model>
<mp_year>2015</mp_year>
<mp_speed>2GHZ</mp_speed>
<mp_noofcores>dual</mp_noofcores>
</MicroProcessor>
<Powersupply>
<p_sno>1207</p_sno>
<p_make>intel</p_make>
<p_model>WATTS</p_model>
<p_year>2015</p_year>
<p_type>ATX</p_type>
<p_wattage>300</p_wattage>
</Powersupply>
<HDD>
<h_sno>1206</h_sno>
<h_make>intel</h_make>
<h_model>Disk</h_model>
<h_year>2015</h_year>
<h_capacity>500GB</h_capacity>
<h_type>IDE</h_type>
</HDD>
<RAM>
<r_sno>1205</r_sno>
<r_make>intel</r_make>
<r_model>GB</r_model>
<r_year>2015</r_year>
<r_type>DDRI</r_type>
<r_capacity>4GB</r_capacity>
<r_of>5240</r_of>
</RAM>
</Computer>
<!ELEMENT
Computer(Type+,Monitor+,Keyboard+,Mouse+,MicroProcessor+,Powersupply+,HDD+,RAM+)>
<!ELEMENT m_make(#PCDATA)>
<!ELEMENT m_model(#PCDATA)>
<!ELEMENT MicroProcessor(mp_sno,mp_make,mp_model,mp_year,mp_speed,mp_noofcores)>
<!ELEMENT Powersupply(p_sno,p_make,p_model,p_year,p_type,p_wattage)>
<!ELEMENT p_sno(#PCDATA)>
<!ELEMENT p_model(#PCDATA)>
<!ELEMENT p_type(#PCDATA)>
<!ELEMENT p_wattage(#PCDATA)>
<!ELEMENT HDD(h_sno,h_make,h_model,h_year,h_capacity,h_type)>
<!ELEMENT h_capacity(#PCDATA)>
<!ELEMENT RAM(r_sno,r_make,r_model,r_year,r_type,r_capacity,r_of)>
<!ELEMENT (#PCDATA)>
Output:
15. Create a Schema to describe a Computer. Use the previous question’s details and show an instance
XML document.
Code:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Monitor">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Keyboard">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Mouse">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Microprocessor">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Powersupply">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="HDD">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="RAM">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Output:
16. Create a Schema 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 Member 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 the above DTD in a sample XML document.
Code:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Book">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Member">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Staff">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Author">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publisher">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Output:
17. Create a DTD to describe a bank that has one or more customers, accounts or Employee.
Each Customer has a Customer ID, Name and address.
Each account has an account ID, BranchID, CustomerID, AccountType and Balance.
Each Employee has an EmpID, Name, Designation, DOJ, Salary and Address.
Use this DTD in a XML file.
Code:
<BankDetails>
<Bank>
<Customer>
<c_id>1001</c_id>
<c_name>Bill Gates</c_author>
<c_address>USA</c_title>
</Customer>
<Account>
<a_id>1</m_id>
<br_id>2803</br_id>
<c_id>1001</c_id>
<a_type>savings</a_type>
<a_bal>20000</a_bal>
</Account>
<Employee>
<e_id>2</e_id>
<e_name>Rakul</e_name>
<e_desingation>cashier</e_desingation>
<e_doj>23-10-2010</s_doj>
<e_salary>80000</e_salary>
<e_address>Puttur</e_address>
</Employee>
</Bank>
<Bank>
<Customer>
<c_id>1002</c_id>
<c_name>Modi</c_author>
<c_address>Delhi</c_title>
</Customer>
<Account>
<a_id>2</m_id>
<br_id>2803</br_id>
<c_id>1002</c_id>
<a_type>savings</a_type>
<a_bal>50000</a_bal>
</Account>
<Employee>
<e_id>3</e_id>
<e_name>sekhar</e_name>
<e_desingation>cashier</e_desingation>
<e_doj>23-08-2008</s_doj>
<e_salary>100000</e_salary>
<e_address>Tirupathi</e_address>
</Employee>
</Bank>
</BankDetails>
<!ELEMENT Customer(c_id,c_name,c_address)>
<!ELEMENT Employee(e_id,e_name,e_designation,e_doj,e_salary,e_address)>
Output:
18. Create Schema describe a bank that has one or more customers, accounts or depositors. Use the
previous questions details. Also show a sample instance XML document.
Code:
bank.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Account">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Output: