-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.xsl
68 lines (56 loc) · 1.41 KB
/
sample.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
61
62
63
64
65
66
67
68
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sam="http://portavita.eu/sample">
<!-- Output as HTML -->
<xsl:output
indent="yes"
method="html"
omit-xml-declaration="yes" />
<!-- Template matching root element -->
<xsl:template match="/">
<!-- HTML Head -->
<head>
<link
rel="stylesheet"
type="text/css"
href="sample.css" />
</head>
<!-- HTML Body -->
<body>
<h1>Observations</h1>
<table>
<!-- Loop over observations -->
<xsl:for-each select="//sam:observation">
<xsl:call-template name="ObservationRow" />
</xsl:for-each>
</table>
</body>
</xsl:template>
<!-- Template to render a single observation -->
<xsl:template name="ObservationRow">
<tr>
<!-- Observation name -->
<td>
<xsl:value-of select="sam:code/@displayName" />
</td>
<!-- Observation value -->
<td>
<xsl:choose>
<!-- Coded value -->
<xsl:when test="sam:value/@displayName">
<xsl:value-of select="sam:value/@displayName" />
</xsl:when>
<!-- Physical quantity -->
<xsl:when test="sam:value/@value">
<xsl:value-of select="sam:value/@value" />
<xsl:text> </xsl:text>
<xsl:value-of select="sam:value/@unit" />
</xsl:when>
</xsl:choose>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>