0% found this document useful (0 votes)
5 views5 pages

Ass 3

The document outlines the design of an XML structure for storing employee information, including a DTD and XML Schema for validation. It features an XML document with employee details, a DTD defining the structure, and an XML Schema specifying data types. Additionally, an XSL stylesheet is provided to display the employee data in a tabular format using CSS.

Uploaded by

sneha bose
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)
5 views5 pages

Ass 3

The document outlines the design of an XML structure for storing employee information, including a DTD and XML Schema for validation. It features an XML document with employee details, a DTD defining the structure, and an XML Schema specifying data types. Additionally, an XSL stylesheet is provided to display the employee data in a tabular format using CSS.

Uploaded by

sneha bose
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/ 5

Ass 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.

EmployeeData.xml (XML Document):


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

<!DOCTYPE employees SYSTEM "employees.dtd">

<employees>

<employee>

<id>001</id>

<name>John Doe</name>

<designation>Software Engineer</designation>

<department>IT</department>

<salary>70000</salary>

</employee>

<employee>

<id>002</id>

<name>Jane Smith</name>

<designation>Marketing Manager</designation>

<department>Marketing</department>

<salary>80000</salary>

</employee>

<!-- Add more employee entries as needed -->

</employees>

employees.dtd (DTD - Document Type Definition):


<!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)>

employees.xsd (XML Schema):


<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:string"/>

<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>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>
</xs:element>

</xs:schema>

employees.xsl (XSL - Extensible Stylesheet Language):


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

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

<style>

body {

font-family: Arial, sans-serif;

margin: 20px;

table {

border-collapse: collapse;

width: 100%;

th, td {

border: 1px solid #dddddd;

text-align: left;

padding: 8px;

th {
background-color: #f2f2f2;

</style>

<xsl:template match="/">

<html>

<head>

<title>Employee Data</title>

</head>

<body>

<h2>Employee Information</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>

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

You might also like