-
Notifications
You must be signed in to change notification settings - Fork 9
/
cv.xslt
156 lines (156 loc) · 5.43 KB
/
cv.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="//cv/me/@name"/></title>
<link rel="stylesheet" type="text/css" href="cv.css" />
<link rel="stylesheet" type="text/css" href="cvedit.css" />
<!-- link to cvedit.js is last element in body tag -->
</head>
<body>
<div id="container">
<div id="me">
<h1><xsl:value-of select="//cv/me/@name"/></h1>
<ul id="contactdetails">
<li>Address: <xsl:value-of select="//cv/me/@address"/></li>
<li>Telephone: <xsl:value-of select="//cv/me/@telephone"/></li>
<li>Email: <xsl:value-of select="//cv/me/@email"/></li>
</ul>
</div>
<div id="content">
<div id="statement">
<p><xsl:copy-of select="//cv/me"/></p>
</div>
<div id="sxscontainer">
<div id="education">
<h2>Education</h2>
<xsl:call-template name="showEducation"/>
</div>
<div id="employment">
<h2>Employment</h2>
<xsl:call-template name="showEmployment"/>
</div>
</div>
<div class="page-break"/>
<div id="hobbiesandinterests">
<h2>Hobbies and Interests</h2>
<xsl:copy-of select="//cv/hobandint"/>
</div>
<div id="references">
<h2>References</h2>
<xsl:call-template name="showReferences"/>
</div>
</div>
</div>
<script type="text/javascript" src="cvedit.js"></script>
</body>
</html>
</xsl:template>
<!-- useThisElseThat: if the value passed is null, return the 'That' value -->
<xsl:template name="useThisElseThat">
<xsl:param name="this"/>
<xsl:param name="that"/>
<xsl:choose>
<xsl:when test="$this!=''">
<xsl:value-of select="$this"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$that"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- showDateRange: standardise the way date ranges are shown across the document -->
<xsl:template name="showDateRange">
<xsl:param name="fromDate"/>
<xsl:param name="toDate"/>
<xsl:param name="noToDate"/>
(<xsl:value-of select="$fromDate"/> -
<xsl:call-template name="useThisElseThat">
<xsl:with-param name="this" select="$toDate"/>
<xsl:with-param name="that" select="$noToDate"/>
</xsl:call-template>)
</xsl:template>
<!-- niceQual: what an individual qual looks like -->
<xsl:template name="showQual">
<xsl:param name="currentQual"/>
<div class="qual">
<p class="qualcontent"><xsl:copy-of select="."/></p>
<p class="qualestablishment"><xsl:value-of select="@establishment"/>
<xsl:call-template name="showDateRange">
<xsl:with-param name="fromDate" select="@from"/>
<xsl:with-param name="toDate" select="@to"/>
<xsl:with-param name="noToDate" select="'Ongoing'"/>
</xsl:call-template>
</p>
</div>
</xsl:template>
<!-- showEducation: the education section of the document -->
<xsl:template name="showEducation">
<h3 class="qualtype"><xsl:value-of select="//cv/education/qualification[1]/@type"/></h3>
<xsl:for-each select="//cv/education/qualification">
<xsl:if test="@type != preceding-sibling::qualification[1]/@type">
<h3 class="qualtype"><xsl:value-of select="@type"/></h3>
</xsl:if>
<xsl:call-template name="showQual">
<xsl:with-param name="currentQual" select="."/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- showEmployment: the employment section of the document -->
<xsl:template name="showEmployment">
<xsl:for-each select="//cv//employment/experience">
<h3 class="jobtitle">
<strong><xsl:value-of select="@job_title"/></strong>, <xsl:value-of select="@establishment"/>
<span>
<xsl:call-template name="showDateRange">
<xsl:with-param name="fromDate" select="@from"/>
<xsl:with-param name="toDate" select="@to"/>
<xsl:with-param name="noToDate" select="'Ongoing'"/>
</xsl:call-template>
</span>
</h3>
<p class="jobdescription"><xsl:value-of select="./description[1]"/></p>
<ul class="jobachievementlist">
<xsl:for-each select="achievement">
<li class="jobachievementitem"><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</xsl:for-each>
</xsl:template>
<!-- showReferences: the references section of the document -->
<xsl:template name="showReferences">
<xsl:choose>
<xsl:when test="not(//cv/references)"><p>References are available on request</p></xsl:when>
<xsl:otherwise>
<xsl:for-each select="//cv/references/contact">
<div class="contact">
<h3><xsl:value-of select="."/></h3>
<ul>
<li><xsl:value-of select="@relationship"/></li>
<li><xsl:value-of select="@email"/></li>
<li><xsl:value-of select="@telephone"/></li>
</ul>
</div>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- text: shows paragraphs where <br/> tag is used,
@source http://http://www.velocityreviews.com/forums/t169843-br-tag-in-xml-content.html -->
<xsl:template name="text" match="text()">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '
')">
<xsl:value-of select="substring-before($text, '
')"/>
<br/>
<xsl:call-template name="text">
<xsl:with-param name="text" select="substring-after($text,'
')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>