0% found this document useful (0 votes)
27 views6 pages

Wad Assignment

Uploaded by

Jaskirat Kaur
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)
27 views6 pages

Wad Assignment

Uploaded by

Jaskirat Kaur
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/ 6

WAD ASSIGNMENT-1

Ques-1: Create an XML file that stores student details (Name, Roll Number, Course, Marks).
Write an XSLT stylesheet that converts the XML data into an HTML table.
Use <xsl:apply-templates> to format each student entry.

XML code-

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

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

<students>

<student>

<name>Tulip</name>

<rollNumber>73</rollNumber>

<course>AIML</course>

<marks>85</marks>

</student>

<student>

<name>Prachi</name>

<rollNumber>47</rollNumber>

<course>AIML</course>

<marks>88</marks>

</student>

<student>

<name>Himanshi</name>

<rollNumber>79</rollNumber>

<course>Physics</course>

<marks>78</marks>

</student>

<student>

<name>Himanshu</name>

<rollNumber>09</rollNumber>

<course>maths</course>

<marks>68</marks>

</student>
</students>

XSLT code-

<?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>Student List</title>

</head>

<body>

<h2>Student List</h2>

<table border="1">

<tr>

<th>Name</th>

<th>Roll Number</th>

<th>Course</th>

<th>Marks</th>

</tr>

<xsl:apply-templates select="students/student"/>

</table>

</body>

</html>

</xsl:template>

<xsl:template match="student">

<tr>

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

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

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

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

</xsl:template>

</xsl:stylesheet>

The result is:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Student List</title>

</head>

<body>

<h2>Student List</h2>

<table border="1">

<tr>

<th>Name</th>

<th>Roll Number</th>

<th>Course</th>

<th>Marks</th>

</tr>

<tr>

<td>Tulip</td>

<td>73</td>

<td>AIML</td>

<td>85</td>

</tr>

<tr>

<td>Prachi</td>

<td>47</td>

<td>AIML</td>

<td>88</td>

</tr>

<tr>
<td>Himanshi</td>

<td>79</td>

<td>Physics</td>

<td>78</td>

</tr>

<tr>

<td>Himanshu</td>

<td>09</td>

<td>maths</td>

<td>68</td>

</tr>

</table>

</body>

</html>

Ques-2: Create an XML document for an online store with products. Each product should have:

• Name

• Price

• Stock (as an attribute)

• Category (e.g., Electronics, Apparel, Home)

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


• <OnlineStore>
• <Products>
• <Product Name="Smartphone" Price="599.99" Stock="100"
Category="Electronics">
• <Description>A high-performance smartphone with a 6.5-inch
display and 5G connectivity.</Description>
• </Product>
• <Product Name="Laptop" Price="999.99" Stock="50"
Category="Electronics">
• <Description>A powerful laptop with a 15.6-inch Full HD display
and the latest processor.</Description>
• </Product>
• <Product Name="T-Shirt" Price="29.99" Stock="200"
Category="Apparel">
• <Description>A comfortable cotton t-shirt available in various
colors and sizes.</Description>
• </Product>
• <Product Name="Coffee Maker" Price="149.99" Stock="75"
Category="Home">
• <Description>An automatic coffee maker with programmable
settings and a built-in grinder.</Description>
• </Product>
• <Product Name="Jeans" Price="59.99" Stock="150"
Category="Apparel">
• <Description>Durable and stylish jeans suitable for everyday
wear.</Description>
• </Product>
• <Product Name="Smartwatch" Price="299.99" Stock="80"
Category="Electronics">
• <Description>A sleek smartwatch with fitness tracking and
smartphone notifications.</Description>
• </Product>
• <Product Name="Sofa" Price="799.99" Stock="25"
Category="Home">
• <Description>A comfortable and modern sofa perfect for any
living room.</Description>
• </Product>
• <Product Name="Headphones" Price="199.99" Stock="120"
Category="Electronics">
• <Description>Noise-cancelling headphones with superior
sound quality and a comfortable fit.</Description>
• </Product>
• </Products>
• </OnlineStore>

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