Practical No- 3
Code
employees.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="employees.xsl"?>
<!DOCTYPE employees [
<!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)>
]>
<employees>
<employee>
<id>1</id>
<name>John Doe</name>
<position>Software Engineer</position>
<department>IT</department>
<salary>70000.00</salary>
</employee>
<employee>
<id>2</id>
<name>Jane Smith</name>
<position>Project Manager</position>
<department>Management</department>
<salary>85000.00</salary>
</employee>
<employee>
<id>3</id>
<name>Emily Johnson</name>
<position>Data Analyst</position>
<department>IT</department>
<salary>60000.00</salary>
</employee>
</employees>
employees.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 List</title>
<style>
table {
width: 100%;
border-collapse: collapse;
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
th {
background-color: #f2f2f2;
</style>
</head>
<body>
<h2>Employee List</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:if test="id"><xsl:value-of select="id"/></xsl:if></td>
<td><xsl:if test="name"><xsl:value-of select="name"/></xsl:if></td>
<td><xsl:if test="position"><xsl:value-of
select="position"/></xsl:if></td>
<td><xsl:if test="department"><xsl:value-of
select="department"/></xsl:if></td>
<td><xsl:if test="salary"><xsl:value-of select="salary"/></xsl:if></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT