forked from christianhujer/expensereport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExpenseReport.xslt
46 lines (43 loc) · 1.57 KB
/
ExpenseReport.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output
method="text"
/>
<xsl:template match="expenses">
<xsl:text>Expenses:
</xsl:text>
<xsl:for-each select="expense">
<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>
<xsl:text>	</xsl:text>
<xsl:value-of select="@amount"/>
<xsl:text>	</xsl:text>
<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>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>Meal Expenses: </xsl:text>
<xsl:value-of select="sum(expense[@type = 'DINNER' or @type = 'BREAKFAST']/@amount)"/>
<xsl:text>
</xsl:text>
<xsl:text>Total: </xsl:text>
<xsl:value-of select="sum(expense/@amount)"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:transform>