You are on page 1of 3

Experiment no: 6

Aim:- Develop XML web page using DTD, XSL


Learning Objective: Students should be able understand and implement XML webpage using DTD,
XSL
Tools: Any browser, Sublime, Notepad++, VSCode
Theory:
XML is a software- and hardware-independent tool for storing and transporting data.
What is XML?
XML stands for eXtensible Markup Language
XML is a markup language much like HTML
XML was designed to store and transport data
XML is designed for self-descriptive.
The Difference Between XML and HTML
XML and HTML were designed with different goals
XML was designed to carry data - with focus on what data is
HTML was designed to display data - with focus on how data looks
XML tags are not predefined like HTML tags are
XML using DTD
An XML document with correct syntax is called "Well Formed".
An XML document validated against a DTD is both "Well Formed" and "Valid".
What is a DTD?
DTD stands for Document Type Definition.
A DTD defines the structure and the legal elements and attributes of an XML document.
XML DTD
The purpose of a DTD is to define the structure and the legal elements and attributes of an XML
document:
Note.dtd:
<!DOCTYPE note
[ <!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)> ]>
Using DTD for Entity Declaration
When to Use a DTD?
With a DTD, independent groups of people can agree to use a standard DTD for interchanging data.
With a DTD, you can verify that the data you receive from the outside world is valid.
You can also use a DTD to verify your own data.
DTD Examples
Newspaper Article DTD
<
What is XSL
XSL stands for EXtensible Stylesheet Language.
XSL(T) Languages
XSLT is a language for transforming XML documents.
XPath is a language for navigating in XML documents.
XQuery is a language for querying XML documents.
What do you mean by XSLT <xsl: choose> element?
XSLT <xsl: choose> element is used to specify a multiple conditional test against the content of nodes. It
is used with <xsl:otherwise> and <xsl:when> elements.
Syntax:
<xsl:choose>
<xsl:when test="expression">
...some output...
</xsl:when>
<xsl:otherwise>
...some output...
</xsl:otherwise>
</xsl:choose>
Result and discussion: From this experiment we understood the concept of what is XML and
XML using DTD . We got to know the purpose of DTD and use and syntax of XSL . We will be
able understand and implement XML webpage using DTD, XSL .
Program:-
Create a breakfast menu for a cafe using XML. And use XSLT to transform the XML to
HTML before displayed in a browser.
Code:-
<?xml version="1.0" encoding="UTF- <description>Light Belgian waffles covered
8"?> with an assortment of fresh berries and
<breakfast_menu> whipped cream</description>
<food> <calories>900</calories>
<name>Belgian Waffles</name> </food>
<price>$5.95</price> <food>
<description>Two of our famous Belgian <name>French Toast</name>
Waffles with plenty of real maple <price>$4.50</price>
syrup</description> <description>Thick slices made from our
<calories>650</calories> homemade sourdough
</food> bread</description>
<food> <calories>600</calories>
<name>Strawberry Belgian Waffles</name> </food>
<price>$7.95</price> <food>
<description>Light Belgian waffles covered <name>Homestyle Breakfast</name>
with strawberries and whipped <price>$6.95</price>
cream</description> <description>Two eggs, bacon or sausage,
<calories>900</calories> toast, and our ever-popular hash
</food> browns</description>
<food> <calories>950</calories>
<name>Berry-Berry Belgian Waffles</name> </food>
<price>$8.95</price> </breakfast_menu>
Output:-
Learning Outcomes: Students should have the ability to
LO1: Understand basic DTD and XSL
LO2: Implement multiple tags into their code
Course Outcomes: Upon completion of the course students will be able to understand how to use XML
web page using DTD, XSL and also use various different tags.
Conclusion:
In this experiment we successfully understood the concept XML using DTD and XSL and also
implemented a website for the same .

For Faculty Use


Correction Formative Timely Attendance
Parameters Assessm completion / Learning
ent of Practical Attitude

Marks
Obtained

You might also like