`
goto0917
  • 浏览: 49209 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论
  • take: 这是POI方式,不是JXLS方式. JXLS包路径都是net ...
    jxls

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 &lt; 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 &gt; 85 or score=85) and sex='女'])"></xsl:value-of>
		</xsl:variable>
		<h3 align="center">The number of girls which score &gt;= 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 &gt; 90   or score=90 ">Excellence</xsl:when>
					<xsl:when test="score &gt; 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>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics