0% found this document useful (0 votes)
8 views4 pages

WT Assignment No3

The document outlines an assignment to design a static web page using XML, DTD, and XML Schema, focusing on employee information storage. It details the use of XML for data structure, DTD for validation, and XSL for transforming XML into HTML format. The document includes example code for an XML file, a DTD file, and an XSL stylesheet to display employee data in a tabular format.

Uploaded by

yashshinde9273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

WT Assignment No3

The document outlines an assignment to design a static web page using XML, DTD, and XML Schema, focusing on employee information storage. It details the use of XML for data structure, DTD for validation, and XSL for transforming XML into HTML format. The document includes example code for an XML file, a DTD file, and an XSL stylesheet to display employee data in a tabular format.

Uploaded by

yashshinde9273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment no.

3
Title:Design a static web page using XML, DTD, XML Schema.

Objectives:
1. Design static webpage using XML document
2. Apply DTD to XML pages.
3. Apply CSS/XLS to XML pages

Problem Statement:
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.

Theory:

XML (eXtensible Markup Language):

XML is a markup language used to define and structure data in a human-readable format.

It consists of elements enclosed in tags, with attributes and text content.

XML is widely used for data storage, exchange, and representation in various applications and
industries.

Syntax:

<?xml-stylesheet type="text/xsl" href="style.xsl"?>

DTD (Document Type Definition):

DTD is a formal definition or schema used to validate the structure and content of an XML
document.

It defines the rules, elements, attributes, and their relationships within an XML document.

DTDs use a set of declarations to specify the structure and constraints of valid XML documents.
While DTDs are still widely used, XML Schema (XSD) has largely replaced them due to its
more advanced features.

XSL (eXtensibleStylesheet Language):

XSL is a language for transforming XML documents into other formats, such as HTML, text, or
XML itself.

XSL consists of two parts: XSLT (XSL Transformations) and XPath.

XSLT is a language for transforming XML documents based on a set of rules defined in XSL
stylesheets.

XPath is a language for navigating and selecting specific elements and data within an XML
document.

XSLT stylesheets contain templates and rules for matching and transforming XML elements into
the desired output format.

XSLT Declaration: XSLT documents start with an XML declaration that specifies the version of
XML and the character encoding, followed by an optional XSLT declaration.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- XSLT content goes here -->

</xsl:stylesheet>

Template Rules: XSLT operates based on template rules, which define how to transform specific
elements in the XML document.

<xsl:template match="elementName">

<!-- Transformation instructions for matching elements -->

</xsl:template>

Conclusion:
Hence we designed the static web page using XML and XSL.
Program Code:

employee.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="employee.xsl" type="text/xsl"?>
<employees>
<employee>
<id>001</id>
<name>John Doe</name>
<position>Software Engineer</position>
<department>Engineering</department>
<salary>70000</salary>
</employee>
<employee>
<id>002</id>
<name>Jane Smith</name>
<position>Marketing Manager</position>
<department>Marketing</department>
<salary>80000</salary>
</employee>
</employees>

employee.dtd
<!ELEMENT employees (employee+)>
<!ELEMENT employee (id, name, position, department, salary)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT position (#PCDATA)>
<!ELEMENT department (#PCDATA)>
<!ELEMENT salary (#PCDATA)>

employee.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>
<head>
<title>Employee Information</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h2>Employee Information</h2>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Position</th>
<th>Department</th>
<th>Salary</th>
</tr>
<xsl:for-each select="employees/employee">
<tr>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="position"/></td>
<td><xsl:value-of select="department"/></td>
<td><xsl:value-of select="salary"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output:

Paste the output here.

You might also like