Displaying book details using XML and XSLT
DISPLAYING BOOK DETAILS USING XML AND XSLT
Aim:
To write XML program to display book details with XSL
Algorithm:
1. Create an XSL page
2. Set styles for an XML file and save the file with extension .xsl
3. Create another file and include XML tags
4. Write code to link the XSL file
5. Save the file with extension .xml
6. Run the XML file
7. Verify the result
Simple.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<books_menu>
<book>
<name>
Computer Architecture </name>
<price> 234.56
</price>
<description>
Computer Is an electronic device
</description>
<pages>456
</pages>
</book>
<book>
<name>
Computer Organisation </name>
<price> 234.56
</price>
<description>
Computer has input and output devices
</description>
<pages>456
</pages>
</book>
</books_menu>
simple.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xlmns="http://www.w3.org/1999/xhtml">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="books_menu/book">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold">
<xsl:value-of select="name"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1cm;font-size:10pt">
<xsl:value-of select="description"/>
<span style="font-style:italic">
<xsl:value-of select="pages"/>
(pages in book)
</span>
</div>
</xsl:for-each>
</body>
</html>
OUTPUT SCREENSHOTS
No comments:
Post a Comment
Leave the comments