Updated XML PRACTICAL LIST With Manual w-24
Updated XML PRACTICAL LIST With Manual w-24
3 Create a XML document which contains details of cars car like: id, company
name, model, engine and mileage and display the same as a table by using
<xsl:for-each> element by using XSLT.
4 Create a XML document Which contains details of book store information like:
Book ID, Book, Name Author, Name, Publisher, Price and Edition and display
the same as a table by using <xsl:value-of> element by using XSLT.
5 Create a XML document Which contains details of foodtype information like:
Name, carbs_per_serving, fiber_per_serving, fat_per_serving, kj_per_serving
and display the same as a table by using xsl:if element by using XSLT.
6 Create a XML document Which contains details of Student information like:
Rollno, firstname,, lastname, nickname, marks and display the same as a
table by using xsl:sort element by using XSLT.
7 Create a XML document Which contains details of Employee information like:
empid, firstname,, lastname, designation, salary and display the same as a table
by using xsl:choose element by using XSLT.
8 Create a XML document Which contains details of Employee information like:
empid, firstname,, lastname, designation, salary and display the same as a table
by using xsl:apply-templates element by using XSLT.
9 Create a XML document Which contains details of Bank information like:
customer id, customername, accountnumber , accounttype , bankname
branchname IFSCcode Address and display the same as a table by using
xsl:import element by using XSLT.
10 Create a XML document Which contains details of matrimony registration
information like:
id, firstname,, lastname, DOB,
Height,complexion,Education,job_description,address,mobile no and display
the same as a table by using xsl:key element by using XSLT.
11 Create a valid XML document containing details of a car like: id, company
name, model, engine and mileage by using XML Schema.
12 Create a valid Internal DTD document containing details of a car like: id,
company name, model, engine and mileage using DTD validate with php file.
13 Create a valid DTD document for Newspaper Article by using
Element,Attribute and Entity building blocks validate with php file.
14 Create a XML document to parse an XML string into an XML DOM object and
then extract the information of important note.
17 Write a program to create a valid XML document for A simple address book to
store the following information: The person name, Home address,
state,pincode, Telephone number, FAX number, Mobile number E-mail address
by using XML schema.
18 Create a valid xml document to show the information about subject topics by
using css
PROGRAM NO1:
Create a well-formed XML document containing details of a car like: id, company name, model,
engine and mileage.
car.xml
<?xml version="1.0" encoding="UTF-8"?>
<cars>
<car id="c101">
<company>Maruthi</company>
<model>Swift</model>
<engine>1248cc</engine>
<mileage>20</mileage>
</car>
<car id="c102">
<company>Hyundai</company>
<model>i20</model>
<engine>1000cc</engine>
<mileage>15</mileage>
</car>
<car id="c103">
<company>Honda</company>
<model>kia</model>
<engine>1200cc</engine>
<mileage>20</mileage>
</car>
</cars>
output:
PROGRAM NO 2:
student.xml:
<?xml version="1.0" encoding="utf-8"?>
<college>
<student>
<firstname>Tamanna</firstname>
<lastname>Bhatia</lastname>
<contact>09990449935</contact>
<email>[email protected]</email>
<address>
<city>Ghaziabad</city>
<state>Uttar Pradesh</state>
<pin>201007</pin>
</address>
</student>
<student>
<firstname>Radhika </firstname>
<lastname>Batra</lastname>
<contact>09876456777</contact>
<email>[email protected]</email>
<address>
<city>nagpur</city>
<state>Maharatra</state>
<pin>440001</pin>
</address>
</student>
<student>
<firstname>Aditya</firstname>
<lastname>Bhandari</lastname>
<contact>09990449945</contact>
<email>[email protected]</email>
<address>
<city>Aurangabad</city>
<state>Maharatra</state>
<pin>431001</pin>
</address>
</student>
<student>
<firstname>Rahul</firstname>
<lastname>Vaidya</lastname>
<contact>09890445936</contact>
<email>[email protected]</email>
<address>
<city>Jalgaon</city>
<state>Maharastra</state>
<pin>412005</pin>
</address>
</student>
<student>
<firstname>Ram</firstname>
<lastname>Sharma</lastname>
<contact>09490645937</contact>
<email>[email protected]</email>
<address>
<city>nagpur</city>
<state>Mararastra</state>
<pin>440001</pin>
</address>
</student>
<student>
<firstname>shyam</firstname>
<lastname>Thakur</lastname>
<contact>09960449945</contact>
<email>[email protected]</email>
<address>
<city>Ghaziabad</city>
<state>Uttar Pradesh</state>
<pin>201008</pin>
</address>
</student>
</college>
PROGRAM NO 3
Create a XML document which contains details of cars car like: id, company name, model, engine
and mileage and display the same as a table by using <xsl:for-each> element by using XSLT.
maruti.xml
ex4.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns = "http://www.w3.org/1999/xhtml">
<xsl:template match="cars">
<html>
<body>
<h1>Car Details</h1>
<table border="1" cellpadding="10">
<tr>
<th>Company Name</th>
<th>Model Name</th>
<th>Engine</th>
<th>Mileage</th>
</tr>
<xsl:for-each select="car">
<tr>
<td><xsl:value-of select="company" /></td>
<td><xsl:value-of select="model" /></td>
<td><xsl:value-of select="engine" /></td>
<td><xsl:value-of select="mileage" /> km</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
PROGRAM NO 4
Create a XML document Which contains details of book store information like:
Book ID, Book, Name Author, Name, Publisher, Price and Edition and display the same as a table
by using <xsl:value-of> element by using XSLT.
Books.xml:
Books.xsl:
<th>Book ID</th>
<th>Book Name</th>
<th>Author Name</th>
<th>Publisher</th>
<th>Price</th>
<th>Edition</th>
</tr>
<xsl:for-each select="store/book">
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
PROGRAM NO 5
Create a XML document Which contains details of foodtype information like:
Name, carbs_per_serving, fiber_per_serving, fat_per_serving, kj_per_serving and display
the same as a table by using xsl:if element by using XSLT.
menu1.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="menu.xsl"?>
<food_list>
<food_item type="vegetable">
<name>Cabbage</name>
<carbs_per_serving>0</carbs_per_serving>
<fiber_per_serving>1</fiber_per_serving>
<fat_per_serving>0</fat_per_serving>
<kj_per_serving>14</kj_per_serving>
</food_item>
<food_item type="vegetable">
<name>Potato</name>
<carbs_per_serving>21.5</carbs_per_serving>
<fiber_per_serving>2</fiber_per_serving>
<fat_per_serving>1</fat_per_serving>
<kj_per_serving>460</kj_per_serving>
</food_item>
<food_item type="vegetable">
<name>Pumpkin</name>
<carbs_per_serving>6</carbs_per_serving>
<fiber_per_serving>1</fiber_per_serving>
<fat_per_serving>0.5</fat_per_serving>
<kj_per_serving>150</kj_per_serving>
</food_item>
<food_item type="vegetable">
<name>Yam</name>
<carbs_per_serving>30.5</carbs_per_serving>
<fiber_per_serving>2</fiber_per_serving>
<fat_per_serving>0.5</fat_per_serving>
<kj_per_serving>550</kj_per_serving>
</food_item>
<food_item type="vegetable">
<name>Zucchini</name>
<carbs_per_serving>1.5</carbs_per_serving>
<fiber_per_serving>1.5</fiber_per_serving>
<fat_per_serving>0.5</fat_per_serving>
<kj_per_serving>55</kj_per_serving>
</food_item>
<food_item type="seafood">
<name>Abalone</name>
<carbs_per_serving>0</carbs_per_serving>
<fiber_per_serving>0</fiber_per_serving>
<fat_per_serving>1</fat_per_serving>
<kj_per_serving>400</kj_per_serving>
</food_item>
<food_item type="seafood">
<name>Barramundi</name>
<carbs_per_serving>0</carbs_per_serving>
<fiber_per_serving>0</fiber_per_serving>
<fat_per_serving>2</fat_per_serving>
kj_per_serving>390</kj_per_serving>
</food_item>
<food_item type="fruit">
<name>Apple</name>
<carbs_per_serving>15</carbs_per_serving>
<fiber_per_serving>2.5</fiber_per_serving>
<fat_per_serving>0</fat_per_serving>
<kj_per_serving>250</kj_per_serving>
</food_item>
<food_item type="fruit">
<name>Kiwi Fruit</name>
<carbs_per_serving>7.5</carbs_per_serving>
<fiber_per_serving>2.5</fiber_per_serving>
<fat_per_serving>0</fat_per_serving>
<kj_per_serving>150</kj_per_serving>
</food_item>
<food_item type="grain">
<name>Oatbran</name>
<carbs_per_serving>62</carbs_per_serving>
<fiber_per_serving>14</fiber_per_serving>
<fat_per_serving>7</fat_per_serving>
<kj_per_serving>1400</kj_per_serving>
</food_item>
<food_item type="grain">
<name>Wheatgrain</name>
<carbs_per_serving>1.5</carbs_per_serving>
<fiber_per_serving>1</fiber_per_serving>
<fat_per_serving>0.5</fat_per_serving>
<kj_per_serving>70</kj_per_serving>
</food_item>
</food_list>
menu.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="food_list">
<table>
<tr style="background-color:#ccff00">
<th>Food Item</th>
<th>Carbs (g)</th>
<th>Fiber (g)</th>
<th>Fat (g)</th>
<th>Energy (kj)</th>
</tr>
<xsl:for-each select="food_item">
<xsl:if test="@type = 'vegetable'">
<tr style="background-color:#00cc00">
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="carbs_per_serving"/></td>
<td><xsl:value-of select="fiber_per_serving"/></td>
<td><xsl:value-of select="fat_per_serving"/></td>
<td><xsl:value-of select="kj_per_serving"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
BEFORE IF CONDITION:
AFTER IF CONDITION:
PROGRAM NO 6
Create a XML document Which contains details of Student information like:
Rollno, firstname,, lastname, nickname, marks and display the same as a table by using xsl:sort
element by using XSLT.
sort.xml:
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "sort.xsl"?>
<class>
<student rollno = "393">
<firstname>Dinkar</firstname>
<lastname>Kad</lastname>
<nickname>Dinkar</nickname>
<marks>85</marks>
</student>
<student rollno = "493">
<firstname>Vaneet</firstname>
<lastname>Gupta</lastname>
<nickname>Vinni</nickname>
<marks>95</marks>
</student>
<student rollno = "593">
<firstname>Jasvir</firstname>
<lastname>Singh</lastname>
<nickname>Jazz</nickname>
<marks>90</marks>
</student>
</class>
sort.xsl:
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
<html>
<body>
<h2>Students</h2>
<table border = "1">
<tr bgcolor = "#9acd32">
<th>Roll No</th>
<th>First Name</th>
<th>Last Name</th>
<th>Nick Name</th>
<th>Marks</th>
</tr>
Before sort:
After sort:
PROGRAM NO 7
Create a XML document Which contains details of Patient information like:
patient ID, patient name, gender, address , birth date, mobile no, blood group, disease type and BP
display the same as a table by using xsl:choose element by using XSLT.
patient.xml:
patient.xsl:
<tr>
<td><xsl:value-of select = "@ID"/></td>
<td><xsl:value-of select = "patientname"/></td>
<td><xsl:value-of select = "gender"/></td>
<td><xsl:value-of select = "address"/></td>
<td><xsl:value-of select = "birthdate"/></td>
<td><xsl:value-of select = "mobile_no"/></td>
<td><xsl:value-of select = "blood_group"/></td>
<td><xsl:value-of select = "disease_type"/></td>
<td><xsl:value-of select = "BP"/></td>
<td>
<xsl:choose>
<xsl:when test = "BP > 120">
High
</xsl:when>
<xsl:otherwise>
Low
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
PROGRAM NO 8
Create a XML document Which contains details of Employee information like:
empid, firstname,, lastname, designation, salary and display the same as a table by using xsl:apply-
templates element by using XSLT.
employee.xml:
employee.xsl:
<xsl:template match="/">
<html>
<body>
<h2>Employee details</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="employeedetail/employee">
<p>
<xsl:apply-templates select="employee_name"/>
<xsl:apply-templates select="address"/>
<xsl:apply-templates select="mobile_no"/>
<xsl:apply-templates select="designation"/>
<xsl:apply-templates select="salary"/>
</p>
</xsl:template>
<xsl:template match="empid">
Employee id: <span style="color:#ff0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="employee_name">
employee name: <span style="color:red">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="address">
Address: <span style="color:pink">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="mobile_no">
mobile no: <span
style="color:green">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="designation">
Designation: <span style="color:red">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="salary">
OUTPUT:
PROGRAM NO 9
Create a XML document Which contains details of Bank information like:
customer id, customername, accountnumber , accounttype , bankname branchname IFSCcode
Address and display the same as a table by using xsl:import element by using XSLT.
bank.xml
bank.xsl:
<th>IFSCcode</th>
<th>Address</th>
</tr>
<tr>
<td><xsl:value-of select = "@id"/></td>
<td><xsl:value-of select = "customername"/></td>
<td><xsl:value-of select = "accountnumber"/></td>
<td><xsl:value-of select = "accounttype"/></td>
<td><xsl:value-of select = "bankname"/></td>
<td><xsl:value-of select = "branchname"/></td>
<td><xsl:value-of select = "IFSCcode"/></td>
<td><xsl:value-of select = "Address"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
bank_import:
output:
PROGRAM NO 10:
Create a XML document Which contains details of matrimony registration information like:
id, firstname,, lastname, DOB, Height, complexion, Education, job, description, address, mobile no
and display the same as a table by using xsl:key element by using XSLT.
marraige.xml:
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "marraige.xsl"?>
<Registration_details>
<information id = "001">
<firstname>Jay </firstname>
<lastname>Bhatiya</lastname>
<DOB>15/11/1993</DOB>
<Height>5"10</Height>
<complexion>Fair</complexion>
<Education>BE,MTech</Education>
<job_description>Mechanical Engineer</job_description>
<address>Dighori,nagpur</address>
<mobileno>9823567149</mobileno>
</information>
<information id = "024">
<firstname>Sonam</firstname>
<lastname>Verma</lastname>
<DOB>25/09/1992</DOB>
<Height>5"6</Height>
<complexion>Fair</complexion>
<Education>MBA</Education>
<job_description>Assistant Professor</job_description>
<address>sadar,nagpur</address>
<mobileno>9923567159</mobileno>
</information>
<information id = "005">
<firstname>Ankit </firstname>
<lastname>Tamankar</lastname>
<DOB>26/05/1993</DOB>
<Height>5"9</Height>
<complexion>Fair</complexion>
<Education>MSc(computer science)</Education>
<job_description>Asociate Professor</job_description>
<address>ramna maruti,nagpur</address>
<mobileno>7723567149</mobileno>
</information>
</Registration_details>
marraige.xsl:
<xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:key name = "lastname-search" match = "information" use = "lastname"/>
<xsl:template match = "/">
<html>
<body>
<h1> Marraige Registration Details</h1>
<table border = "1">
<tr bgcolor = "pink">
<th> ID</th>
<th> First Name</th>
<th> Last Name</th>
<th> DOB</th>
<th> Height</th>
<th>complexion</th>
<th>Education</th>
<th>Job Description</th>
<th>address</th>
<th>Mobile no</th>
</tr>
<xsl:for-each select = "key('lastname-search', 'Bhatiya')">
<tr>
<td> <xsl:value-of select = "@id"/> </td>
<td> <xsl:value-of select = "firstname"/> </td>
<td> <xsl:value-of select = "lastname"/> </td>
<td> <xsl:value-of select = "DOB"/> </td>
<td> <xsl:value-of select = "Height"/> </td>
<td> <xsl:value-of select = "complexion"/> </td>
<td> <xsl:value-of select = "Education"/> </td>
<td> <xsl:value-of select = "job_description"/> </td>
<td> <xsl:value-of select = "address"/> </td>
<td> <xsl:value-of select = "mobileno"/> </td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
PROGRAM NO 11:
Create a valid XML document containing details of a car like: id, company name, model, engine and
mileage by using XML Schema.
car.xml:
<?xml version="1.0" encoding="utf-8"?>
<cars
xmlns = "http://www.startertutorials.com/studentSchema"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.startertutorials.com/studentSchema
car.xsd">
<car id="c101">
<company>Maruthi</company>
<model>Swift</model>
<engine>1248cc</engine>
<mileage>20</mileage>
</car>
<car id="c102">
<company>Hyundai</company>
<model>i20</model>
<engine>1000cc</engine>
<mileage>15</mileage>
</car>
</cars>
car.xsd:
OUTPUT:
PROGRAM NO 12:
Create a valid Enternal DTD document containing details of Stock market like:
sname,branch,contact validate with php file.
vision.xml
<?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<!DOCTYPE Stockmarket SYSTEM "vision.dtd">
<Stockmarket>
<sname>Bluechip tech</sname>
<branch>nine</branch>
<contact>(022) 245-8597</contact>
<sname>BSE</sname>
<branch>SEVEN</branch>
<contact>(022) 235-8545</contact>
<sname>NSE</sname>
<branch>FIVE</branch>
<contact>(022) 225-5497</contact>
</Stockmarket>
vision.dtd:
<?xml version="1.0"?>
<!ELEMENT Stockmarket (sname,branch,contact)>
<!ELEMENT sname (#PCDATA)>
<!ELEMENT branch (#PCDATA)>
<!ELEMENT contact (#PCDATA)>
prg5.php
<?php
$xml=new DOMDocument;
$xml-
>load('vision.xml');
if($xml->validate())
{
echo"It's a valid document";
}
else
{
echo"It's a not valid document";
}
?>
OUTPUT:
PROGRAM NO 13:
Create a valid Internal DTD document containing details of a car like: id, company name, model,
engine and mileage validate with php file.
car.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE cars[
<!ELEMENT cars (car+)>
<!ELEMENT car (company, model, engine, mileage)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT model (#PCDATA)>
<!ELEMENT engine (#PCDATA)>
<!ELEMENT mileage (#PCDATA)>
<!ATTLIST car id CDATA #REQUIRED>
]>
<cars>
<car id="c101">
<company>Maruthi</company>
<model>Swift</model>
<engine>1248cc</engine>
<mileage>20</mileage>
</car>
<car id="c102">
<company>Hyundai</company>
<model>i20</model>
<engine>1000cc</engine>
<mileage>15</mileage>
</car>
</cars>
prg2.php:
<?php
$xml=new DOMDocument;
$xml-
>load('car.xml');
if($xml->validate())
{
echo"It's a valid document";
}
else
{
echo"It's a not valid document";
}
?>
OUTPUT:
PROGRAM NO 14:
Create a valid DTD document for Newspaper Article by using Element, Attribute and Entity
building blocks validate with php file.
news.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NEWSPAPER [
]>
<NEWSPAPER>
<ARTICLE AUTHOR="Ravi" EDITOR="Tom" DATE="5/2/11" EDITION="vol32">
<HEADLINE>INDIA WINS THE MATCH</HEADLINE>
<BYLINE>&PUBLISHER;</BYLINE>
<LEAD>ANUJ &NEWSPAPER;</LEAD>
<BODY>INDIA BEAT DUTCH</BODY>
<NOTES>©RIGHT;</NOTES>
</ARTICLE>
<ARTICLE AUTHOR="Eric" EDITOR="Robert" DATE="8/2/11" EDITION="vol39">
<HEADLINE>ARSNEL Beat MANU</HEADLINE>
<BYLINE>&PUBLISHER; </BYLINE>
<LEAD>ANUJ &NEWSPAPER;Eric Donald</LEAD>
<BODY>INDIA BEAT DUTCH</BODY>
<NOTES>©RIGHT;</NOTES>
</ARTICLE>
<ARTICLE AUTHOR="ROss" DATE="24/2/11">
<HEADLINE>Nickel back new album </HEADLINE>
<BYLINE>&PUBLISHER; </BYLINE>
<LEAD>ANUJ &NEWSPAPER;Kyra Jhonson</LEAD>
<BODY>Someday Hit song</BODY>
<NOTES>©RIGHT;</NOTES>
</ARTICLE>
</NEWSPAPER>
prg3.php:
<?php
$xml=new DOMDocument;
$xml-
>load('news.xml');
if($xml->validate())
{
echo"It's a valid document";
}
else
{
echo"It's a not valid document";
}
?>
OUTPUT:
PROGRAM NO-15
Create a XML document to parse an XML string into an XML DOM object and then
extract the information of important note.
<!DOCTYPE html>
<html>
<body>
<h1><font color="red">Important Note</font></h1>
<div>
<b>To:</b> <span id="to"></span><br>
<b>From:</b> <span id="from"></span><br>
<b>Message:</b> <span id="message"></span>
</div>
<script>
txt1="<note>";
txt2="<to>Sania Mirza</to>";
txt3="<from>Serena William</from>";
txt4="<body>Don't forget me this weekend!</body>";
txt5="</note>";
txt=txt1+txt2+txt3+txt4+txt5;
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(txt,"text/xml");
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(txt);
}
document.getElementById("to").innerHTML= xmlDoc.getElementsByTagName("to")
[0].childNodes[0].nodeValue; document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML= xmlDoc.getElementsByTagName("body")
[0].childNodes[0].nodeValue;
</script>
</body>
</html>
Output:
PROGRAM NO-16
Create a valid XML document congaing details of Breakfast menu like:name,price,
Description,calories food by using XML Schema.
breakfast.xml:
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu xsi:noNamespaceSchemaLocation="breakfast.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty of real maple syrup
</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
Light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>
Belgian waffles covered with assorted fresh berries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>
Thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
<food>
</breakfast_menu>
breakfast.xsd:
OUTPUT:
changes in calaries:
PROGRAM NO-17
Create a valid XML document of train information like:train title,train type ,name, number, source and
destination by using DTD and CSS.
train_info.xml :
<?xml version="1.0" encoding="UTF-8"?>
<train_info>
<title1>Information about the trains</title1>
<train>
<type>SuperFast</type>
<name>GaribRath</name>
<no>12495</no>
<source>Delhi</source>
<dest>Patna</dest>
</train>
</train_info>
<station_info>
title2>Information about the station</title2>
<station>
<name>Patna</name>
<code>A01</code>
<zone>North East</zone>
<no_train_stop>50</no_train_stop>
<no_train_pass>50</no_train_pass>
</station>
</station_info>
<zone_info>
<title2>Information about the zone</title2>
<zone>
<name>North East</name>
<code>A02</code>
<no_of_st>100</no_of_st>
</zone>
</zone_info>
</rail_info>
rail_info.dtd:
train_info.css:
rail_info
{
background-color: yellow;
width: 100%;
}
train_info,station_info,zone_info,train,station,zone
{
display: block;
margin-bottom:
30pt; margin-left: 0;
}
title1,title2,title3
{
color: green;
font-size:
20pt;
}
type,name
{
color: blue;
font-size:
20pt;
}
code,no,source,dest,zone,no_train_stop,no_train_pass,code,no_of_st
{
display: block;
color: pink;
margin-left:
20pt;
}
OUTPUT:
PROGRAM NO-18
Create a valid xml document to encode TV Program Schedules by using External DTD
validate with php file.
tv.xml:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE TVSCHEDULE SYSTEM "tv.dtd">
<DAY>
<DATE>Tuesday, April 27th, 2022</DATE>
<PROGRAMSLOT>
<TIME>12:00 PM</TIME>
<TITLE>Salem City Council Meeting</TITLE>
<DESCRIPTION>Meeting of 4/21/22</DESCRIPTION>
</PROGRAMSLOT>
<PROGRAMSLOT>
<TIME>6:30 PM</TIME>
<TITLE>A Conversation With Congressman Tierney</TITLE>
</PROGRAMSLOT>
<PROGRAMSLOT>
<TIME>7:00 PM</TIME>
<TITLE>Salem School Committee Meeting</TITLE>
<DESCRIPTION>4/26/2022</DESCRIPTION>
</PROGRAMSLOT>
</DAY>
</CHANNEL>
</TVSCHEDULE>
tv.dtd:
<!ELEMENT TVSCHEDULE (CHANNEL+)>
<!ATTLIST TVSCHEDULE NAME CDATA #REQUIRED>
<!ELEMENT CHANNEL (BANNER, DAY+)>
<!ATTLIST CHANNEL CHAN CDATA #REQUIRED>
<!ELEMENT BANNER (#PCDATA)>
<!ELEMENT DAY ((DATE, HOLIDAY) | (DATE, PROGRAMSLOT+))+>
<!ELEMENT HOLIDAY (#PCDATA)>
<!ELEMENT DATE (#PCDATA)>
<!ELEMENT PROGRAMSLOT (TIME, TITLE, DESCRIPTION?)>
<!ATTLIST PROGRAMSLOT VTR CDATA #IMPLIED>
<!ELEMENT TIME (#PCDATA)>
<!ELEMENT TITLE (#PCDATA)>
<!ATTLIST TITLE RATING CDATA #IMPLIED LANGUAGE CDATA #IMPLIED>
<!ELEMENT DESCRIPTION (#PCDATA)>
OUTPUT:
PROGRAM NO-19
Write a program to create a valid XML document for A simple address book to store the following
information: The person name, Home address, state,pincode, Telephone number, FAX number, Mobile
number E-mail address by using XML schema.
address.xml:
<?xml version="1.0" encoding="UTF-8"?>
<address_book xsi:noNamespaceSchemaLocation="address.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name> Rajesh tripathi</name>
<home_address>Dattawadi,nagpur</home_address>
<state>Maharastra</state>
<pincode>4400023</pincode>
<Telephone_no>(0712-224578)</Telephone_no>
<fax_no>555-123-4567</fax_no>
<mobile_no>9875462312</mobile_no>
<Email_ID>[email protected]</Email_ID>
</address_book>
address.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="address_book">
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="name" type="xs:string" />
<xs:element name="home_address" type="xs:string" />
<xs:element name="state" type="xs:string" />
<xs:element name="pincode" type="xs:unsignedInt" />
<xs:element name="Telephone_no" type="xs:string" />
<xs:element name="fax_no" type="xs:string" />
<xs:element name="mobile_no" type="xs:unsignedLong" />
<xs:element name="Email_ID" type="xs:string" />
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
OUTPUT:
changes in pincode:
PROGRAM NO-20
Create a valid xml document to show the information about subject topics by using css
topic.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="topic.css"?>
<topics>
<title>Hello Everyone! </title>
<topic_section>
<name>Algorithm</name>
<topic1> Recursive Algorithm</topic1>
<topic2>Randomised Algorithm</topic2>
<topic3>Searching Algorithm</topic3>
<topic4>Sorting Algorithm</topic4>
</topic_section>
<topic_section>
<name>Data Structures</name>
<topic1>Array</topic1>
<topic2>Stack</topic2>
<topic3>Queue</topic3>
<topic4>Linked List</topic4>
</topic_section>
<topic_section>
<name>Web Technology</name>
<topic1>HTML</topic1>
<topic2>CSS</topic2>
<topic3>Java Script</topic3>
<topic4>Php</topic4>
</topic_section>
<topic_section>
<name>Languages</name>
<topic1>C/C++</topic1>
<topic2>Java</topic2>
<topic3>Python</topic3>
<topic4>Ruby</topic4>
</topic_section>
<topic_section>
<name>DBMS</name>
<topic1>Basics</topic1>
<topic2>ER Diagram</topic2>
<topic3>Normalization</topic3>
<topic4>Transaction Concepts</topic4>
</topic_section>
</topics>
topic.css
topic
{
font-size:80%;
margin:0.5em;
font-family: Verdana;
display:block;
}
topic_section {
display:block
;
border: 1px solid silver;
margin:0.5em;
padding:0.5em;
background-color:whitesmoke;
}
title {
display:block;
font-
weight:bolder;
text-align:center;
font-size:30px;
background-color: green;
color: white;
}
name, topic1, topic2, topic3, topic4 {
display:block;
text-align:center;
}
name {
color:green;
text-decoration:
underline ; font-
weight:bolder;
font-size:20px;
}
topic1 {
color:green
}
topic2 {
color:brown
}
topic3 {
color:blue
}
topic4 {
color:orange
}
output: