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

Practical No-3: Code Employees - XML

The document contains an XML file defining employee data with attributes such as id, name, position, department, and salary. It also includes an XSL stylesheet that transforms the XML data into an HTML table format for displaying the employee list. The stylesheet ensures proper formatting and styling of the output table.

Uploaded by

pratikanarse577
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)
52 views4 pages

Practical No-3: Code Employees - XML

The document contains an XML file defining employee data with attributes such as id, name, position, department, and salary. It also includes an XSL stylesheet that transforms the XML data into an HTML table format for displaying the employee list. The stylesheet ensures proper formatting and styling of the output table.

Uploaded by

pratikanarse577
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

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

You might also like