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

Webtech 5

Uploaded by

aayush2310008-d
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)
13 views5 pages

Webtech 5

Uploaded by

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

EXPERIMENT 5

NAME: Anurag
Dhruv Jangid
Upadhyay
ROLL NO. :2200271690019
2200270100040
OBJECTIVE: Write a program in XML for creation of DTD, which specifies set of rules. Create a style
sheet in CSS/ XSL & display the document in internet explorer

CODE:

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

<!DOCTYPE books [

<!ELEMENT books (book+)>

<!ELEMENT book (title, author, year, price)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT year (#PCDATA)>

<!ELEMENT price (#PCDATA)>

]>

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

<xsl:template match="/">

<html>

<head>

<title>Book List</title>

<style>

body {

font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

background-color: #f9f9f9;

color: #333;

margin: 0;

padding: 20px;

h1 {

color: #2c3e50;

text-align: center;
margin-bottom: 20px;

table {

width: 100%;

border-collapse: collapse;

margin: 0 auto;

box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

th, td {

border: 1px solid #ddd;

padding: 12px;

text-align: left;

th {

background-color: #3498db;

color: white;

tr:nth-child(even) {

background-color: #f2f2f2;

tr:hover {

background-color: #d1e7dd;

@media (max-width: 600px) {

table, thead, tbody, th, td, tr {

display: block;

th {

position: absolute;

left: -9999px;

}
tr {

margin-bottom: 10px;

td {

text-align: right;

padding-left: 50%;

position: relative;

td:before {

content: attr(data-label);

position: absolute;

left: 0; /* Align to the left */

width: 50%; /* Half width */

padding-left: 10px;

font-weight: bold;

text-align: left;

</style>

</head>

<body>

<h1>Book List</h1>

<table>

<tr>

<th>Title</th>

<th>Author</th>

<th>Year</th>

<th>Price</th>

</tr>

<xsl:for-each select="books/book">

<tr>
<td data-label="Title"><xsl:value-of select="title"/></td>

<td data-label="Author"><xsl:value-of select="author"/></td>

<td data-label="Year"><xsl:value-of select="year"/></td>

<td data-label="Price"><xsl:value-of select="price"/></td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

<books>

<book>

<title>XML for Beginners</title>

<author>John Doe</author>

<year>2023</year>

<price>29.99</price>

</book>

<book>

<title>Advanced XML</title>

<author>Jane </author>

<year>2022</year>

<price>39.99</price>

</book>

</books>
OUTPUT

You might also like