WT Practical 6


Practical : 6
Subject : Web Technology

Aim : Make an application using XML that display book information like title, author, publication, ISBN, edition, price, etc


Source Code :
//book.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="book.xsl"?>

<bookstore>
            <book>
                        <title>web technology</title>
                        <author>Uttam K. Roy</author>
                        <ISBN>9788120350069</ISBN>
                        <publisher>technical</publisher>
                        <edition>3rd</edition>
                        <price>650</price>
            </book>
            <book>
                        <title>Advance java</title>
                        <author> Kanika Lakhani</author>
                        <ISBN>9789350388150</ISBN>
                        <publisher> Oxford University</publisher>
                        <edition>2013</edition>
                        <price>450</price>
            </book>
              <book>
                        <title>Software engineering</title>
                        <author> Roger Pressman</author>
                        <ISBN>9339212088</ISBN>
                        <publisher>McGraw Hill </publisher>
                        <edition>7th</edition>
                        <price>340</price>
            </book>
              <book>
                        <title>dot net</title>
                        <author> Matthew MacDonald </author>
                        <ISBN>9780070495364</ISBN>
                        <publisher> Mcgrawhill HED</publisher>
                        <edition> 1st </edition>
                        <price>756</price>
            </book>
              <book>
                        <title>Theory of computation</title>
                        <author>Vivek Kulkarni</author>
                        <ISBN> 9780198084587</ISBN>
                        <publisher> Oxford University</publisher>
                        <edition>2013</edition>
                        <price>390</price>
            </book>
</bookstore>

//book.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2> My Books collection</h2>
<table border="1">
<tr bgcolor="#00ffff">
<th align="left">title</th>
<th align="left">author</th>
<th align="left">ISBN</th>
<th align="left">publisher</th>
<th align="left">edition</th>
<th align="left">price</th>
</tr>
<xsl:for-each select="bookstore/book">
<tr>
<td bgcolor="#00e6e6"><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="price &gt; 30">
<td bgcolor="#ccffff"><xsl:value-of select="author"/></td>
 <td bgcolor="#ccffff"><xsl:value-of select="ISBN"/></td>
  <td bgcolor="#ccffff"><xsl:value-of select="publisher"/></td>
 <td bgcolor="#ccffff"><xsl:value-of select="edition"/></td>
 <td bgcolor="#ccffff"><xsl:value-of select="price"/></td>

</xsl:when>
<xsl:when test="price &gt; 10">
<td bgcolor="lightgreen"><xsl:value-of select="author"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="author"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output :


Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment