xsl


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<html>
<head>
<title>Student Score Summary</title>
</head>
<body>
<h1 align="center">Student Score Summary</h1>
<table border="1" align="center" width="80%">
<tr>
<th>序号</th>
<th>编号</th>
<th>姓名</th>
<th>性别</th>
<th>生日</th>
<th>成绩</th>
<th>评价</th>
<th>skill</th>
</tr>
<xsl:apply-templates select="students/student">
<xsl:sort select="score" order="descending"></xsl:sort>
</xsl:apply-templates>
<xsl:variable name="sumScore">
<xsl:value-of select="sum(students/student/score)">
</xsl:value-of>
</xsl:variable>
<xsl:variable name="countStudent">
<xsl:value-of select="count(students/student)">
</xsl:value-of>
</xsl:variable>
<tr>
<td colspan="4">总分</td>
<td colspan="4"><xsl:value-of select="$sumScore"></xsl:value-of></td>

</tr>
<tr>
<td colspan="4">人数</td>
<td colspan="4"><xsl:value-of select="$countStudent"></xsl:value-of></td>

</tr>
<tr>
<td colspan="4">平均分</td>
<td colspan="4"><xsl:value-of select="round($sumScore div $countStudent*10) div 10"></xsl:value-of></td>

</tr>

</table>
<hr/>
<xsl:variable name="below60">
<xsl:value-of select="count(students/student[score < 60])"></xsl:value-of>
</xsl:variable>
<h3 align="center">The number of students which score below 60 is <xsl:value-of select="$below60"></xsl:value-of></h3>

<xsl:variable name="above85">
<xsl:value-of select="count(students/student[(score > 85 or score=85) and sex='女'])"></xsl:value-of>
</xsl:variable>
<h3 align="center">The number of girls which score >= 85 is <xsl:value-of select="$above85"></xsl:value-of></h3>
</body>
</html>
</xsl:template>
<xsl:template match="students/student">
<tr>
<xsl:if test="position() mod 2=0">
<xsl:attribute name="bgcolor">red</xsl:attribute>
</xsl:if>
<td><xsl:value-of select="position()"></xsl:value-of></td>
<td><xsl:value-of select="@ID"></xsl:value-of></td>
<td><xsl:value-of select="name"></xsl:value-of></td>
<td><xsl:value-of select="sex"></xsl:value-of></td>
<td><xsl:value-of select="birthday"></xsl:value-of></td>
<td><xsl:value-of select="score"></xsl:value-of></td>
<td>
<xsl:choose>
<xsl:when test="score > 90 or score=90 ">Excellence</xsl:when>
<xsl:when test="score > 60 or score=60 ">Good</xsl:when>
<xsl:otherwise>
Failed
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:for-each select="skill">
<xsl:value-of select="."></xsl:value-of>
</xsl:for-each>
</td>

</tr>
</xsl:template>
</xsl:stylesheet>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值