forked from smurav/test1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.xsl
60 lines (56 loc) · 1.86 KB
/
results.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="test">
<html>
<body>
<h2>Результаты выполнения контрольной работы №1</h2>
<table border="1" style="width:50%">
<tr>
<th style="width:10%">№</th>
<th style="width:80%">Студент</th>
<th>Результат</th>
</tr>
<xsl:apply-templates select="//group"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="group">
<tr>
<td colspan="3" align="center" bgcolor="#9acd32"><xsl:value-of select="@id"/></td>
<xsl:apply-templates select="student"/>
</tr>
</xsl:template>
<xsl:template match="student">
<xsl:variable name="result" select="sum(task)"/>
<xsl:variable name="bonus" select="sum(bonus)"/>
<tr>
<td align="center"><xsl:value-of select="position()"/></td>
<td><xsl:value-of select="@name"/></td>
<xsl:choose>
<xsl:when test="$result+$bonus<'16'">
<td bgcolor="#ff0000"><xsl:value-of select="$result"/>
<xsl:if test="bonus>0">
<xsl:text>+</xsl:text><xsl:value-of select="$bonus"/>
</xsl:if>
</td>
</xsl:when>
<xsl:when test="$result+$bonus>'19'">
<td bgcolor="#00ff00"><xsl:value-of select="$result"/>
<xsl:if test="bonus>0">
<xsl:text>+</xsl:text><xsl:value-of select="$bonus"/>
</xsl:if>
</td>
</xsl:when>
<xsl:otherwise>
<td bgcolor="#ffff00"><xsl:value-of select="$result"/>
<xsl:if test="bonus>0">
<xsl:text>+</xsl:text><xsl:value-of select="$bonus"/>
</xsl:if>
</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:template>
</xsl:stylesheet>