Exp 7th WT-1
Exp 7th WT-1
ALGORITHM:
1. Start the program.
2. Create XML Data File:
3. Define an XML file named library.xml with a root element <library>.
4. Link library.xml to an XSLT file (Book.xsl) using an XML stylesheet directive:
5. Define XSLT File for Transformation
6. Iterate through XML Data
7. Deploy XML and XSLT Files
8. The browser will apply the XSLT transformation, rendering the XML data as an HTML table.
9. Verify that the browser displays the book information correctly in a table format.
10. Stop the program.
File Structure
/LibraryProject
PROGRAM:
library.xml
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book>
<author>John Doe</author>
<price>44.95</price>
<publish_year>2000</publish_year>
</book>
<book>
<title>Learning XML</title>
<author>Jane Smith</author>
<price>39.95</price>
<publish_year>2003</publish_year>
</book>
</library>
Book.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:template match="/">
<html>
<head>
<title>Library Books</title>
</head>
<body>
<h2>Library Books</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Author</th>
<th>Price</th>
<th>Publish Year</th>
</tr>
<xsl:for-each select="library/book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="price"/></td>
<td><xsl:value-of select="publish_year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Books.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:complexType>
<xs:sequence>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>