-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathExpenseReport_html.xslt
59 lines (56 loc) · 2.51 KB
/
ExpenseReport_html.xslt
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output
method="html"
/>
<xsl:template match="expenses">
<html lang="en">
<head>
<title>Expense Report</title>
</head>
<body>
<h1>Expense Report</h1>
<table>
<thead>
<tr><th scope="col">Type</th><th scope="col">Amount</th><th scope="col">Over Limit</th></tr>
</thead>
<tbody>
<xsl:for-each select="expense">
<tr>
<td>
<xsl:choose>
<xsl:when test="@type = 'DINNER'">
<xsl:text>Dinner</xsl:text>
</xsl:when>
<xsl:when test="@type = 'BREAKFAST'">
<xsl:text>Breakfast</xsl:text>
</xsl:when>
<xsl:when test="@type = 'CAR_RENTAL'">
<xsl:text>Car Rental</xsl:text>
</xsl:when>
</xsl:choose>
</td>
<td><xsl:value-of select="@amount"/></td>
<td>
<xsl:choose>
<xsl:when test="@type = 'DINNER' and @amount > 5000 or @type = 'BREAKFAST' and @amount > 1000">
<xsl:text>X</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
<p>Meal Expenses: <xsl:value-of select="sum(expense[@type = 'DINNER' or @type = 'BREAKFAST']/@amount)"/></p>
<p>Total Expenses: <xsl:value-of select="sum(expense/@amount)"/></p>
</body>
</html>
</xsl:template>
</xsl:transform>