0% found this document useful (0 votes)
45 views2 pages

Employee XML Assignment

The document contains an XML representation of employee data, including details such as ID, name, designation, department, and salary. It also includes a Document Type Definition (DTD) and an XML Schema (XSD) to define the structure and data types of the XML elements. Additionally, an XSL stylesheet is provided for transforming the XML data into a tabular HTML format for display.

Uploaded by

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

Employee XML Assignment

The document contains an XML representation of employee data, including details such as ID, name, designation, department, and salary. It also includes a Document Type Definition (DTD) and an XML Schema (XSD) to define the structure and data types of the XML elements. Additionally, an XSL stylesheet is provided for transforming the XML data into a tabular HTML format for display.

Uploaded by

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

Employee Data - XML, DTD, XSD, XSL Assignment

1. XML Document

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


<?xml-stylesheet type="text/xsl" href="employees.xsl"?>
<employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="employees.xsd">
<employee>
<id>101</id>
<name>John Doe</name>
<designation>Manager</designation>
<department>HR</department>
<salary>60000</salary>
</employee>
<employee>
<id>102</id>
<name>Jane Smith</name>
<designation>Developer</designation>
<department>IT</department>
<salary>50000</salary>
</employee>
</employees>

2. DTD Document

<!ELEMENT employees (employee+)>


<!ELEMENT employee (id, name, designation, department, salary)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT designation (#PCDATA)>
<!ELEMENT department (#PCDATA)>
<!ELEMENT salary (#PCDATA)>

3. XML Schema (XSD)

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


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="employees">
<xs:complexType>
<xs:sequence>
<xs:element name="employee" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:integer"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="designation" type="xs:string"/>
<xs:element name="department" type="xs:string"/>
<xs:element name="salary" type="xs:decimal"/>
</xs:sequence>
Employee Data - XML, DTD, XSD, XSL Assignment

</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

4. XSL for Tabular Display

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


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
<title>Employee List</title>
<style>
table { width: 70%; border-collapse: collapse; margin: 20px auto; }
th, td { border: 1px solid #333; padding: 10px; text-align: center; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h2 style="text-align:center;">Employee Details</h2>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Designation</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="designation"/></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>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy