Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Implementation of XML, DTD and XSLT

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Implementation of XML,DTD and XSLT:

bookstore.xml:

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


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

<bookstore>
<book>
<title>Fundamentals of DB Systems</title>
<author>S. B. Navathe</author>
<language>English</language>
<price>Rs.540</price>
<publication>Pearson</publication>
</book>

<book>
<title>Twilight</title>
<author>Stephnie Meyer</author>
<language>English</language>
<price>Rs.230</price>
<publication>Little,Brown and Co.</publication>
</book>

<book>
<title>Shakuntala</title>
<author>Kalidas</author>
<language>Sanskrit</language>
<price>Rs.429</price>
<publication>Sahitya Co.</publication>
</book>

<book>
<title>Shyamchi Aayee</title>
<author>Sane Guruji</author>
<language>Marathi</language>
<price>Rs.290</price>
<publication>Grantha Pub.</publication>
</book>

<book>
<title>Si Senor</title>
<author>De Franklin</author>
<language>Spanish</language>
<price>Rs.690</price>
<publication>Le Fang Pub.</publication>
</book>
<book>
<title>Shomar Bangla</title>
<author>R. V. Banarjee</author>
<language>Bengali</language>
<price>Rs.274</price>
<publication>B.R.Co.</publication>
</book>

</bookstore>

bookstore.dtd:

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

<!DOCTYPE bookstore[
<!ELEMENT bookstore (book)*>
<!ELEMENT book (publication|price|language|author|title)*>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT language (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT publication (#PCDATA)>
]>

bookstore.xsl:

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


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

<xsl:template match="/">
<html>
<head>
<title>bookstore.xsl</title>
</head>
<body>

<table border="1" bordercolor="brown" bgcolor="lightcyan" cellspacing="1">


<caption><h2>Bookstore Database:</h2></caption>
<tr>
<th bgcolor="ffccaa">Title</th>
<th bgcolor="ffccaa">Author</th>
<th bgcolor="ffccaa">Language</th>
<th bgcolor="ffccaa">Price</th>
<th bgcolor="ffccaa">Publication</th>
</tr>
<xsl:for-each select="bookstore/book">
<tr>
<td><xsl:value-of select="title"/></td>

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

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

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

<td><xsl:value-of select="publication"/></td>
</tr>
</xsl:for-each>

</table>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

OUTPUT:

You might also like