XMLProg
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="students.xsl"?>
<students>
<student>
<name>Aswath S</name>
<age>21</age>
<dob>09/08/2000</dob>
<mobile>9812989444</mobile>
<address>CBE</address>
</student>
<student>
<name>Surya M</name>
<age>21</age>
<dob>04/08/2000</dob>
<mobile>9585593999</mobile>
<address>CBE</address>
</student>
</students>
<?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>
<body>
<h2>Students Personal Details</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Age</th>
<th>DOB</th>
<th>Mobile</th>
<th>Address</th>
</tr>
<xsl:for-each select="students/student">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="dob"/></td>
<td><xsl:value-of select="mobile"/></td>
<td><xsl:value-of select="address"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
================customer.xsl==================
<?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>
<body>
<h2>customer details</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Branch</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="branch"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="city"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
=====================customers.xml======================
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="customer.xsl"?>
<customers>
<customer>
<name>Aswath</name>
<branch>MCA</branch>
<age>21</age>
<city>CBE</city>
</customer>
<customer>
<name>Indru</name>
<branch>MCA</branch>
<age>21</age>
<city>CBE</city>
</customer>
<customer>
<name>Raja</name>
<branch>MCA</branch>
<age>21</age>
<city>CBE</city>
</customer>
<customer>
<name>Jai</name>
<branch>MCA</branch>
<age>21</age>
<city>CBE</city>
</customer>
</customers>
======================demo.xml========================
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<bookname>HARRY POTTER</bookname>
<author> J K ROWLING</author>
</book>
<book>
<bookname>THE HOBBIT</bookname>
<author> JRR TOLKIEN</author>
</book>
<book>
<bookname>PONNIYIN SELVAM</bookname>
<author>KALKI</author>
</book>
<book>
<bookname>THIRUKURAL</bookname>
<author> THIRUVALLUVAR</author>
</book>
</books>
======================demo.xml========================
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<bookname>HARRY POTTER</bookname>
<author> J K ROWLING</author>
</book>
<book>
<bookname>THE HOBBIT</bookname>
<author> JRR TOLKIEN</author>
</book>
<book>
<bookname>PONNIYIN SELVAM</bookname>
<author>KALKI</author>
</book>
<book>
<bookname>THIRUKURAL</bookname>
<author> THIRUVALLUVAR</author>
</book>
</books>
Comments
Post a Comment