DISPLAYING PLAYER RANKING USING
XML AND XSLT
AIM:
To write the programs using XML and XSLT for displaying player ranking
details.
ALGORITHM:
Step
1: Create an XML document (rank.xml) that contains the markup tags such as
<rank>, <name>, and <country>.
Step
2: Create an XSL document (rank.xsl) that defines the style to display an XML
document.
Step
3: Associate style sheet (XSL) with XML using the markup
<?xml-stylesheet>
Step
4: Load the XML document (rank.xml) in the browser
PROGRAM:
rank.xml
<?xml
version="1.0" encoding="UTF-8"?>
<?xml-stylesheet
type="text/xsl" href="rank.xsl"?>
<rankInfo>
<player>
<rank>1</rank>
<name>H.M.Amla</name>
<country>SA</country>
</player>
<player>
<rank>2</rank>
<name>A.B.De
Villiers</name>
<country>SA</country>
</player>
<player>
<rank>3</rank>
<name>V.Kohli</name>
<country>IND</country>
</player>
<player>
<rank>4</rank>
<name>K.C.Sangakkara</name>
<country>SL</country>
</player>
<player>
<rank>5</rank>
<name>M.S.Dhoni</name>
<country>IND</country>
</player>
</rankInfo>
rank.xsl
<?xml
version="1.0" encoding="UTF-8"?>
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template
match="/">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Student
Details - Transformation</title>
</head>
<body>
<table
border="1">
<caption>ICC
Player Rankings</caption>
<tr>
<th>Rank</th><th>Name</th><th>Country</th>
</tr>
<xsl:for-each
select="/rankInfo/player">
<tr>
<td><xsl:value-of
select="rank"/></td>
<td><xsl:value-of
select="name"/></td>
<td><xsl:value-of
select="country"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:transform>
RESULT:
|
Tuesday, January 29, 2013
DISPLAYING PLAYER RANKING USING XML AND XSLT
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Leave the comments