Sunday, October 12, 2008

XSL stylesheet for database of cricket players

save this as a .xsl file, & it will highligh the indian players in blue, Aussies in yellow & pakistan players in green & add few more colors to various attributes...

< ?xml version="1.0" encoding="ISO-8859-1"? >
< xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >




< xsl:template match="/" >
< html >
< body >
< h2 > List < /h2 >
< table border="1" >
< tr > < th > name < /th >
< th > age < /th >
< th > Matches < /th > < /tr >

< xsl:for-each select="Team/player" >

< xsl:choose > < xsl:when test= "country='india'" >
< tr >
< td style="color:blue" > < xsl:value-of select="name"/ > < /td >
< td style="color:red" > < xsl:value-of select="age"/ > < /td >
< xsl:value-of select="matches"/ > < /td > < /tr >
< /xsl :choose >


< xsl:choose > < xsl:when test= "country='australia'" >
< tr >
< td style="color:yellow" > < xsl:value-of select="name"/ > < /td >
< td style="color:red" > < xsl:value-of select="age"/ > < /td >
< td style="color:orange" > < xsl:value-of select="matches"/ > < /td > < /tr >
< /xsl:choose >


< xsl:choose > < xsl:when test= "country='pakistan'" >
< tr >
< td style="color:green" > < xsl:value-of select="name"/ > < /td >
< td style="color:red" > < xsl:value-of select="age"/ > < /td >
< td style="color:orange" > < xsl:value-of select="matches"/ > < /xsl:when > < /xsl:choose >



< /xsl:for-each >


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

0 comments: