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

Wtexp 3

The document outlines an assignment to design an XML document for storing employee information, demonstrating the use of DTD and XML Schema. It includes sample XML data for employees, an XSL stylesheet for displaying the data in a tabular format, and a DTD and XML Schema for validation. The provided code allows for the structured representation and presentation of employee details such as ID, name, position, department, salary, and joining date.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Wtexp 3

The document outlines an assignment to design an XML document for storing employee information, demonstrating the use of DTD and XML Schema. It includes sample XML data for employees, an XSL stylesheet for displaying the data in a tabular format, and a DTD and XML Schema for validation. The provided code allows for the structured representation and presentation of employee details such as ID, name, position, department, salary, and joining date.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment No: 3

Aim: Design the XMI. 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

Code:

employees.xml

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

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

<!DOCTYPE employees SYSTEM "employees.dtd">

<employees>

<employee>

<id>101</id>

<name>John Doe</name>

<position>Software Engineer</position>

<department>IT</department>

<salary>70000</salary>

<joiningDate>2020-01-15</joiningDate>

</employee>

<employee>

<id>102</id>

<name>Jane Smith</name>

<position>Project Manager</position>

<department>Operations</department>

<salary>95000</salary>

<joiningDate>2018-05-25</joiningDate>

</employee>
<employee>

<id>103</id>

<name>Tom Brown</name>

<position>HR Executive</position>

<department>Human Resources</department>

<salary>50000</salary>

<joiningDate>2021-03-10</joiningDate>

</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:output method="html" indent="yes"/>

<xsl:template match="/">

<html>

<head>

<title>Employee Information</title>

<style>

table { width: 100%; border-collapse: collapse; }

th, td { padding: 8px; text-align: left; border: 1px solid #ddd; }

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>

<th>Joining Date</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>

<td><xsl:value-of select="joiningDate"/></td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

-----------------------------------------------------------------------------------------------------

employees.dtd

<!ELEMENT employees (employee+)>

<!ELEMENT employee (id, name, position, department, salary, joiningDate)>


<!ELEMENT id (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT position (#PCDATA)>

<!ELEMENT department (#PCDATA)>

<!ELEMENT salary (#PCDATA)>

<!ELEMENT joiningDate (#PCDATA)>

------------------------------------------------------------------------------------------------------

employees.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:int"/>

<xs:element name="name" type="xs:string"/>

<xs:element name="position" type="xs:string"/>

<xs:element name="department" type="xs:string"/>

<xs:element name="salary" type="xs:decimal"/>

<xs:element name="joiningDate" type="xs:date"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>
</xs:schema>

-----------------------------------------------------------------------------------------------------------------

Output:

You might also like