3 XML DTD and XSLT
3 XML DTD and XSLT
Assignment No. : 3
Design the XML document to store the information of the employees of any business
organization and demonstrate the use of:
a) DTD
b) XML Schema
And display the content in (e.g., tabular format) by using CSS/XSL
Software Requirements:
1. Operating System: Windows 7/8/10/Ubuntu
2. Browser: Firefox/Google Chrome/ Microsoft Edge etc.
3. Software : Sublime Text editor/ Notepad/ Notepad++, Eclipse (for DTD)
Hardware Requirements:
1. Processor: Minimum 1 GHz.
2. Ethernet connection (LAN) OR a wireless adapter (Wi-Fi)
3. Hard Drive: Minimum 32 GB.
4. Memory (RAM): Minimum 1 GB
5. Sound card-speakers/camera/microphone (Depending upon website selection)
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
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.
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 −
<a href = "http://www.google.com/">XMLTutorial</a>
Here href is the attribute name and http://www.google.com/ is attribute value.
A DTD is a Document Type Definition. A DTD defines the structure and the legal
elements and attributes of an XML document. With a DTD, independent groups of
people can agree on a standard DTD for interchanging data. An application can use a
DTD to verify that XML data is valid.
An Internal DTD Declaration
If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE>
definition:
XML document with an internal DTD
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!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"
!ELEMENT to defines the to element to be of type "#PCDATA"
!ELEMENT from defines the from element to be of type "#PCDATA"
!ELEMENT heading defines the heading element to be of type "#PCDATA"
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
</note>
Recommendation is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Link the XSL Style Sheet to the XML Document
Add the XSL style sheet reference to your XML document ("student.xml"):
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="stud.xsl"?>
If you have an XSLT compliant browser it will nicely transform your XML into
XHTML.
Hence, we have designed static web pages using XML, XSLT/CSS and DTD