student3.xml
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="student3.xsl"?>
<roster>
<student>
<number>001</number>
<name>John</name>
<Java>85</Java>
<Oracle>88</Oracle>
<VisualBasic>90</VisualBasic>
</student>
<student>
<number>002</number>
<name>Peter</name>
<Java>65</Java>
<Oracle>54</Oracle>
<VisualBasic>95</VisualBasic>
</student>
<student>
<number>003</number>
<name>Jacken</name>
<Java>95</Java>
<Oracle>82</Oracle>
<VisualBasic>67</VisualBasic>
</student>
<student>
<number>004</number>
<name>Windey</name>
<Java>76</Java>
<Oracle>87</Oracle>
<VisualBasic>75</VisualBasic>
</student>
<student>
<number>005</number>
<name>Anita</name>
<Java>88</Java>
<Oracle>65</Oracle>
<VisualBasic>99</VisualBasic>
</student>
<student>
<number>006</number>
<name>Richard</name>
<Java>87</Java>
<Oracle>78</Oracle>
<VisualBasic>90</VisualBasic>
</student>
<student>
<number>007</number>
<name>Regina</name>
<Java>90</Java>
<Oracle>76</Oracle>
<VisualBasic>59</VisualBasic>
</student>
<student>
<number>008</number>
<name>Kitty</name>
<Java>67</Java>
<Oracle>87</Oracle>
<VisualBasic>89</VisualBasic>
</student>
<student>
<number>009</number>
<name>Esmond</name>
<Java>65</Java>
<Oracle>87</Oracle>
<VisualBasic>89</VisualBasic>
</student>
<student>
<number>010</number>
<name>Dino</name>
<Java>98</Java>
<Oracle>98</Oracle>
<VisualBasic>88</VisualBasic>
</student>
</roster>
student3.xsl
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="uri:xsl">
<xsl:template match="/">
<html>
<body>
<h2 align="center">学生成绩单</h2>
<xsl:apply-templates select="roster"/>
</body>
</html>
</xsl:template>
<xsl:template match="roster">
<table boder="1" cellpadding="10" align="center">
<tr>
<th>学号</th>
<th>姓名</th>
<th>Java</th>
<th>Oracle</th>
<th>VisualBasic</th>
</tr>
<xsl:apply-templates select="student" order-by="number"/>
</table>
</xsl:template>
<xsl:template match="student">
<tr>
<td><xsl:apply-templates select="number"/></td>
<td><xsl:apply-templates select="name"/></td>
<td><xsl:apply-templates select="Java"/></td>
<td><xsl:apply-templates select="Oracle"/></td>
<td><xsl:apply-templates select="VisualBasic"/></td>
</tr>
</xsl:template>
<xsl:template match="number|name">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="Java|Oracle|VisualBasic">
<xsl:choose>
<xsl:when match=".[. $gt$ 90 or . $eq$ 90]"><font color="red"><xsl:value-of
select="."/></font></xsl:when>
<xsl:when match=".[. $lt$ 60]"><xsl:value-of select="."/></xsl:when>
<xsl:otherwise><font color="blue"><xsl:value-of select="."/></font></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>