3 XML DTD and XSLT Assignment No 31
3 XML DTD and XSLT Assignment No 31
Assignment No. : 3
TITLE
Title: XML,DTD and XSLT.
PROBLEM STATEMENT
Write a program to design XML page for student and validate the structure using DTD and show
The output using in HTML format using XSLT.
OUTCOMES
THEORY-CONCEPT
XML stands for Extensible Markup Language. It is nothing but the text-based markup language
which is derived from Standard Generalized Markup Language(SGML).
XML tags identify the data and are used to store and organize the data, rather than specifying
how to display it like HTML tags, which are used to display the data. XML is not going to
replace HTML in the near future, but it introduces new possibilities by adopting many
successful features of HTML.
There are three important characteristics of XML that make it useful in a variety of systems and
solutions −
Web Technology Lab Manual
XML is extensible − XML allows you to create your own self-descriptive tags, or
language, that suits your application.
XML carries the data, does not present it − XML allows you to store the data irrespective
of how it will be presented.
XML is a public standard − XML was developed by an organization called the World Wide
Web Consortium (W3C) and is available as an open standard.
TECHNOLOGY/TOOL
The XML document have an XML declaration, but it is optional, and it is written as−
<? xml version = "1.0" encoding = "UTF-8"?>
Where version is nothing but the version of an XML document and UTF specifies the character-
encoding used in the document.
Each XML-element needs to be closed either with start or with end elements as shown below −
<element>………</element>
An XML document can have only one root element.
<root>
<x>...</x>
<y>...</y>
</root>
XML Attributes:
Using a name/value pair, an attribute specifies a single property for an element. An XML-
element can have one or more attributes. For example −
DTD
A DTD defines the structure and the legal elements and attributes of an XML document.
Web Technology Lab Manual
With a DTD, independent groups of people can agree on a standard DTD for interchanging data.
If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition:
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT to (#PCDATA)>
]>
<note>
<to>Neha</to>
<from>Amit</from>
<heading>Reminder</heading>
</note>
!DOCTYPE note defines that the root element of this document is note
!ELEMENT note defines that the note element must contain four elements: "to,from,heading"
If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference
to the DTD file:
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
</note>
XSLT
Note: <xsl:stylesheet> and <xsl:transform> are completely synonymous and either can be used!
The correct way to declare an XSL style sheet according to the W3C XSLT Recommendation is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Then you create an XSL Style Sheet ("stud.xsl") with a transformation template:
<h2>Student</h2>
<table border="1">
<tr> <th>RollNo</th>
<th>Name </th>
</tr>
<xsl:for-each select="Student/stud">
<tr>
<td><xsl:value-of select="rno"/></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Add the XSL style sheet reference to your XML document ("student.xml"):
If you have an XSLT compliant browser it will nicely transform your XML into XHTML.
DESIGN/EXECUTION STEPS
TEST CASES
CONCLUSION/ANALYSIS
Hence, we have designed static web pages using XML ,XSLT and DTD
ORAL QUESTIONS