Project

General

Profile

« Previous | Next » 

Revision 5965

Added by berkley almost 14 years ago

stylesheet/skins for mets data

View differences:

lib/style/skins/mets/mets.xml
1
<?xml version="1.0"?>
2
<style-set name="mets">
3
<!-- general login & search -->
4
  <default-style>/style/common/ascii-treeview.xsl</default-style>
5

  
6
  <doctype publicid="-//NCEAS//resultset//EN">
7
    <target publicid="-//W3C//HTML//EN">/style/skins/nceas/nceas.xsl</target>
8
  </doctype>
9
  
10
  <doctype publicid="http://www.loc.gov/METS/">
11
    <target publicid="-//W3C//HTML//EN">/style/skins/mets/dryad.xsl</target>
12
  </doctype>
13

  
14
</style-set>
0 15

  
lib/style/skins/mets/dryad.xsl
1
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
2
	xmlns:dri="http://di.tamu.edu/DRI/1.0/" xmlns:mets="http://www.loc.gov/METS/"
3
	xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
4
	xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/TR/xlink/"
5
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan"
6
	xmlns:datetime="http://exslt.org/dates-and-times" xmlns:encoder="xalan://java.net.URLEncoder"
7
	exclude-result-prefixes="xalan strings encoder datetime" version="1.0"
8
	xmlns:strings="http://exslt.org/strings">
9

  
10
	<xsl:import href="DryadUtils.xsl"/>
11

  
12
	<xsl:variable name="meta" select="/dri:document/dri:meta/dri:pageMeta/dri:metadata"/>
13
	<xsl:variable name="localize" select="$meta[@element='dryad'][@qualifier='localize'][.='true']"/>
14

  
15
	<xsl:template match="/">
16
		<xsl:variable name="datafiles" select=".//dim:field[@element='relation'][@qualifier='haspart']"/>
17

  
18
		<!-- my_doi and my_uri go together; there is a my_uri if no my_doi -->
19
		<xsl:variable name="my_doi"
20
			select=".//dim:field[@element='identifier'][not(@qualifier)][starts-with(., 'doi:')]"/>
21
		<xsl:variable name="my_uri"
22
			select=".//dim:field[@element='identifier'][@qualifier='uri'][not(starts-with(., 'doi'))]"/>
23

  
24
		<!-- Obtain an identifier if the item is harvested from KNB.
25
			   But we have to munge the URL to link to LTER instead of the raw XML. -->
26
		<xsl:variable name="knb_url_raw"
27
			select=".//dim:field[@element='identifier'][starts-with(.,'http://metacat')]"/>
28
		<xsl:variable name="knb_url">
29
			<xsl:if test="$knb_url_raw!=''">
30
				<xsl:value-of select="substring($knb_url_raw,0,string-length($knb_url_raw)-2)"/>lter
31
			</xsl:if>
32
		</xsl:variable>
33
		
34
		<!-- Obtain an identifier if the item is harvested from TreeBASE.
35
		But we have to munge the URL to link to TreeBASE instead of raw XML. -->
36
		<xsl:variable name="treebase_url_raw"
37
			select=".//dim:field[@element='identifier'][contains(., 'purl.org/phylo/treebase/')]"/>
38
		<xsl:variable name="treebase_url">
39
			<xsl:if test="$treebase_url_raw != ''">
40
				<xsl:choose>
41
					<xsl:when test="starts-with(., 'http:')">
42
						<xsl:value-of select="concat($treebase_url_raw, '?format=html')"/>
43
					</xsl:when>
44
					<xsl:otherwise>
45
						<xsl:value-of select="concat('http://', $treebase_url_raw, '?format=html')"/>
46
					</xsl:otherwise>
47
				</xsl:choose>
48
			</xsl:if>
49
		</xsl:variable>
50

  
51
		<!-- CITATION FOR DATA FILE -->
52
		<xsl:if
53
			test="$meta[@element='xhtml_head_item'][contains(., 'DCTERMS.isPartOf')]
54
				and $meta[@element='request'][@qualifier='queryString'][not(contains(., 'show=full'))]
55
				and $meta[@element='authors'][@qualifier='package']">
56

  
57
			<xsl:variable name="article_doi"
58
				select="$meta[@element='identifier'][@qualifier='article'][. != '']"/>
59

  
60
			<div class="citation-view">
61
				<p class="ds-paragraph">When using this data, please cite the original article:</p>
62
				<blockquote>
63
					<xsl:variable name="citation" select="$meta[@element='citation'][@qualifier='article']"/>
64
					<xsl:choose>
65
						<xsl:when test="$citation != ''">
66
							<xsl:choose>
67
								<xsl:when test="$article_doi and not(contains($citation, $article_doi))">
68
									<xsl:copy-of select="$citation"/>
69
									<a>
70
										<xsl:attribute name="href">
71
											<xsl:choose>
72
												<xsl:when test="starts-with($article_doi, 'http')">
73
													<xsl:value-of select="$article_doi"/>
74
												</xsl:when>
75
												<xsl:when test="starts-with($article_doi, 'doi:')">
76
													<xsl:value-of
77
														select="concat('http://dx.doi.org/', substring-after($article_doi, 'doi:'))"
78
													/>
79
												</xsl:when>
80
											</xsl:choose>
81
										</xsl:attribute>
82
										<xsl:value-of select="$article_doi"/>
83
									</a>
84
								</xsl:when>
85
								<xsl:when test="$article_doi">
86
									<xsl:copy-of select="substring-before($citation, $article_doi)"/>
87
									<a>
88
										<xsl:attribute name="href">
89
											<xsl:value-of
90
												select="concat('http://dx.doi.org/', substring-after($article_doi, 'doi:'))"
91
											/>
92
										</xsl:attribute>
93
										<xsl:value-of select="$article_doi"/>
94
									</a>
95
								</xsl:when>
96
								<xsl:otherwise>
97
									<xsl:value-of select="$citation"/>
98
								</xsl:otherwise>
99
							</xsl:choose>
100
						</xsl:when>
101
						<xsl:otherwise>
102
							<xsl:variable name="journal" select="$meta[@element='publicationName']"/>
103
							<xsl:choose>
104
								<xsl:when test="$journal">
105
									<span style="font-style: italic;">Citation is not yet available for this article
106
										from <xsl:value-of select="$journal"/>. It will become available shortly after
107
										the article is published. <xsl:if test="$article_doi">
108
											<a>
109
												<xsl:attribute name="href">
110
													<xsl:choose>
111
														<xsl:when test="starts-with($article_doi, 'http')">
112
															<xsl:value-of select="$article_doi"/>
113
														</xsl:when>
114
														<xsl:when test="starts-with($article_doi, 'doi:')">
115
															<xsl:value-of
116
																select="concat('http://dx.doi.org/', substring-after($article_doi, 'doi:'))"
117
															/>
118
														</xsl:when>
119
													</xsl:choose>
120
												</xsl:attribute>
121
												<xsl:value-of select="$article_doi"/>
122
											</a>
123
										</xsl:if>
124
									</span>
125
								</xsl:when>
126
								<xsl:otherwise>
127
									<span style="font-style: italic;">Citation not yet available.</span>
128
								</xsl:otherwise>
129
							</xsl:choose>
130
						</xsl:otherwise>
131
					</xsl:choose>
132
				</blockquote>
133
			</div>
134
		</xsl:if>
135

  
136
		
137
		<!-- General, non-citation, metadata display-->
138

  
139
		<table class="ds-includeSet-table">
140
			<tr class="ds-table-row">
141
				<td>
142
					<xsl:choose>
143
						<xsl:when test="$treebase_url != ''">
144
							<span class="bold">View Full Content in TreeBASE</span>
145
						</xsl:when>
146
						<xsl:when test="$knb_url!=''">
147
							<span class="bold">View Full Content in KNB</span>
148
						</xsl:when>
149
						<xsl:when test="$datafiles!=''">
150
							<span class="bold">Dryad Package Identifier</span>
151
						</xsl:when>
152
						<xsl:otherwise>
153
							<span class="bold">Dryad File Identifier</span>
154
						</xsl:otherwise>
155
					</xsl:choose>
156
				</td>
157
				<td>
158
					<xsl:choose>
159
						<xsl:when test="$my_doi">
160
							<a>
161
								<xsl:attribute name="href">
162
									<xsl:call-template name="checkURL">
163
										<xsl:with-param name="url"
164
											select="concat('http://dx.doi.org/', substring-after($my_doi, 'doi:'))"/>
165
										<xsl:with-param name="localize" select="$localize"/>
166
									</xsl:call-template>
167
								</xsl:attribute>
168
								<xsl:value-of select="$my_doi"/>
169
							</a>
170
						</xsl:when>
171
						<xsl:when test="$my_uri">
172
							<a>
173
								<xsl:attribute name="href">
174
									<xsl:call-template name="checkURL">
175
										<xsl:with-param name="url" select="$my_uri"/>
176
										<xsl:with-param name="localize" select="$localize"/>
177
									</xsl:call-template>
178
								</xsl:attribute>
179
								<xsl:value-of select="$my_uri"/>
180
							</a>
181
						</xsl:when>
182
					</xsl:choose>
183
				</td>
184
			</tr>
185

  
186
			<xsl:if
187
				test=".//dim:field[@element='identifier'][not(@qualifier)][not(contains(., 'dryad.'))]">
188
				
189
				<xsl:variable name="dc-creators" select=".//dim:field[@element='creator'][@mdschema='dc']"/>
190

  
191
				<xsl:if test="$dc-creators != ''">
192
					<tr class="ds-table-row">
193
						<td>
194
							<xsl:choose>
195
								<xsl:when test="count($dc-creators) &gt; 1">
196
									<span class="bold">Authors</span>
197
								</xsl:when>
198
								<xsl:otherwise>
199
									<span class="bold">Author</span>
200
								</xsl:otherwise>
201
							</xsl:choose>
202
						</td>
203
						<td>
204
							<xsl:for-each select="$dc-creators">
205
								<xsl:value-of select="."/><br/>
206
							</xsl:for-each>
207
						</td>
208
					</tr>
209
				</xsl:if>
210
				
211
				<xsl:variable name="dc-publishers"
212
					select=".//dim:field[@element='publisher'][@mdschema='dc']"/>
213
				
214
				<xsl:if test="$dc-publishers != ''">
215
					<tr class="ds-table-row">
216
						<td>
217
							<xsl:choose>
218
								<xsl:when test="count($dc-publishers) &gt; 1">
219
									<span class="bold">Publishers</span>
220
								</xsl:when>
221
								<xsl:otherwise>
222
									<span class="bold">Publisher</span>
223
								</xsl:otherwise>
224
							</xsl:choose>
225
						</td>
226
						<td>
227
							<xsl:for-each select="$dc-publishers">
228
								<xsl:value-of select="."/><br/>
229
							</xsl:for-each>
230
						</td>
231
					</tr>
232
				</xsl:if>
233
				
234
				<xsl:variable name="dc-date"
235
					select=".//dim:field[@element='date'][not(@qualifier)][@mdschema='dc']"/>
236
				
237
				<xsl:if test="$dc-date != ''">
238
					<tr class="ds-table-row">
239
						<td>
240
								<span class="bold">Published</span>
241
						</td>
242
						<td>
243
							<xsl:value-of select="$dc-date[1]"/>
244
						</td>
245
					</tr>
246
				</xsl:if>
247
			</xsl:if>
248

  
249
			<xsl:variable name="description">
250
				<xsl:for-each select=".//dim:field[@element='description'][not(@qualifier='provenance')]">
251
					<xsl:copy-of select="node()"/>
252
					<br/>
253
				</xsl:for-each>
254
			</xsl:variable>
255

  
256
			<xsl:if test="$description!=''">
257
				<tr class="ds-table-row">
258
					<td>
259
						<xsl:choose>
260
							<xsl:when test="//dim:field[@element='relation'][@qualifier='ispartof']">
261
								<span class="bold">Description</span>
262
							</xsl:when>
263
							<xsl:otherwise>
264
								<span class="bold">Abstract</span>
265
							</xsl:otherwise>
266
						</xsl:choose>
267
					</td>
268
					<td>
269
						<xsl:copy-of select="$description"/>
270
					</td>
271
					<td> </td>
272
				</tr>
273
			</xsl:if>
274

  
275
			<xsl:variable name="describedBy">
276
				<xsl:for-each select=".//dim:field[@element='relation' and @qualifier='ispartof']">
277
					<a>
278
						<xsl:attribute name="href">
279
							<xsl:call-template name="checkURL">
280
								<xsl:with-param name="url" select="."/>
281
								<xsl:with-param name="localize" select="$localize"/>
282
							</xsl:call-template>
283
						</xsl:attribute>
284
						<xsl:copy-of select="."/>
285
					</a>
286
					<br/>
287
				</xsl:for-each>
288
			</xsl:variable>
289
			<xsl:if test="$describedBy!=''">
290
				<tr class="ds-table-row">
291
					<td>
292
						<span class="bold">Contained in Data Package</span>
293
					</td>
294
					<td>
295
						<xsl:copy-of select="$describedBy"/>
296
					</td>
297
					<td> </td>
298
				</tr>
299
			</xsl:if>
300

  
301
			<xsl:variable name="sciNames">
302
				<xsl:for-each select=".//dim:field[@element='ScientificName']">
303
					<xsl:copy-of select="node()"/>
304
					<br/>
305
				</xsl:for-each>
306
			</xsl:variable>
307
			<xsl:if test="$sciNames!=''">
308
				<tr class="ds-table-row">
309
					<td>
310
						<span class="bold">Scientific Names</span>
311
					</td>
312
					<td>
313
						<xsl:copy-of select="$sciNames"/>
314
					</td>
315
					<td> </td>
316
				</tr>
317
			</xsl:if>
318

  
319
			<xsl:variable name="spatialCoverage">
320
				<xsl:for-each select=".//dim:field[@element='coverage'][@qualifier='spatial']">
321
					<xsl:copy-of select="node()"/>
322
					<br/>
323
				</xsl:for-each>
324
			</xsl:variable>
325
			<xsl:if test="$spatialCoverage!=''">
326
				<tr class="ds-table-row">
327
					<td>
328
						<span class="bold">Spatial Coverage</span>
329
					</td>
330
					<td>
331
						<xsl:copy-of select="$spatialCoverage"/>
332
					</td>
333
					<td> </td>
334
				</tr>
335
			</xsl:if>
336

  
337
			<xsl:variable name="temporalCoverage">
338
				<xsl:for-each select=".//dim:field[@element='coverage'][@qualifier='temporal']">
339
					<xsl:copy-of select="node()"/>
340
					<br/>
341
				</xsl:for-each>
342
			</xsl:variable>
343
			<xsl:if test="$temporalCoverage!=''">
344
				<tr class="ds-table-row">
345
					<td>
346
						<span class="bold">Temporal Coverage</span>
347
					</td>
348
					<td>
349
						<xsl:copy-of select="$temporalCoverage"/>
350
					</td>
351
					<td> </td>
352
				</tr>
353
			</xsl:if>
354

  
355
			<xsl:variable name="keywords">
356
				<xsl:for-each select=".//dim:field[@element='subject'][@mdschema='dc'][not(@qualifier)]">
357
					<xsl:copy-of select="node()"/>
358
					<br/>
359
				</xsl:for-each>
360
			</xsl:variable>
361
			<xsl:if test="$keywords!=''">
362
				<tr class="ds-table-row">
363
					<td>
364
						<span class="bold">Keywords</span>
365
					</td>
366
					<td>
367
						<xsl:copy-of select="$keywords"/>
368
					</td>
369
					<td> </td>
370
				</tr>
371
			</xsl:if>
372

  
373
			<xsl:if test=".//dim:field[@element='identifier'][not(@qualifier)][contains(., 'dryad.')]">
374
				<tr class="ds-table-row">
375
					<td>
376
						<span class="bold">Date Deposited</span>
377
					</td>
378
					<td>
379
						<xsl:copy-of select=".//dim:field[@element='date' and @qualifier='accessioned']"/>
380
					</td>
381
					<td> </td>
382
				</tr>
383
			</xsl:if>
384

  
385
		</table>
386

  
387
		<!-- we only want this view from item view - not the administrative pages -->
388
		<xsl:if test="$meta[@qualifier='URI' and contains(.., 'handle')]">
389
			<div style="padding: 10px; margin-top: 5px; margin-bottom: 5px;">
390
				<a href="?show=full">Show Full Metadata</a>
391
			</div>
392
		</xsl:if>
393

  
394
		<xsl:variable name="embargoedDate"
395
			select=".//dim:field[@element='date' and @qualifier='embargoedUntil']"/>
396
		<xsl:variable name="embargoType">
397
			<xsl:choose>
398
				<xsl:when test=".//dim:field[@element='type' and @qualifier='embargo']">
399
					<xsl:value-of select=".//dim:field[@element='type' and @qualifier='embargo']"/>
400
				</xsl:when>
401
				<xsl:otherwise>
402
					<xsl:text>unknown</xsl:text>
403
				</xsl:otherwise>
404
			</xsl:choose>
405
		</xsl:variable>
406
		<xsl:choose>
407
			<xsl:when test="$embargoedDate!=''">
408
				<!-- this all might be overkill, need to confirm embargoedDate element disappears after time expires -->
409
				<xsl:variable name="dateDiff">
410
					<xsl:call-template name="datetime:difference">
411
						<xsl:with-param name="start" select="datetime:date()"/>
412
						<xsl:with-param name="end" select="datetime:date($embargoedDate)"/>
413
					</xsl:call-template>
414
				</xsl:variable>
415
				<xsl:choose>
416
					<xsl:when test="$embargoedDate='9999-01-01' and $embargoType='oneyear'">
417
						<div id="embargo_notice">
418
							<i18n:text>xmlui.ArtifactBrowser.RestrictedItem.head_resource.oneyear</i18n:text>
419
						</div>
420
					</xsl:when>
421
					<xsl:when
422
						test="$embargoedDate='9999-01-01' and ($embargoType='untilArticleAppears' or $embargoType='unknown')">
423
						<div id="embargo_notice">
424
							<i18n:text>xmlui.ArtifactBrowser.RestrictedItem.head_resource.publication</i18n:text>
425
						</div>
426
					</xsl:when>
427
					<xsl:when test="not(starts-with($dateDiff, '-'))">
428
						<div id="embargo_notice">
429
							<i18n:text>xmlui.ArtifactBrowser.RestrictedItem.head_resource</i18n:text>
430
							<xsl:value-of select="$embargoedDate"/>
431
						</div>
432
					</xsl:when>
433
					<xsl:otherwise>
434
						<xsl:call-template name="checkedAndNoEmbargo"/>
435
					</xsl:otherwise>
436
				</xsl:choose>
437
			</xsl:when>
438
			<xsl:when test="./mets:fileSec/mets:fileGrp[@USE='CONTENT']">
439
				<xsl:call-template name="checkedAndNoEmbargo"/>
440
			</xsl:when>
441
		</xsl:choose>
442

  
443
		<xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='CC-LICENSE' or @USE='LICENSE']"/>
444

  
445
		<xsl:if
446
			test=".//dim:field[@element='rights'][.='http://creativecommons.org/publicdomain/zero/1.0/']">
447
			<xsl:choose>
448
				<!-- this all might be overkill, need to confirm embargoedDate element disappears after time expires -->
449
				<xsl:when test="$embargoedDate!=''">
450
					<xsl:variable name="dateDiff">
451
						<xsl:call-template name="datetime:difference">
452
							<xsl:with-param name="start" select="datetime:date()"/>
453
							<xsl:with-param name="end" select="datetime:date($embargoedDate)"/>
454
						</xsl:call-template>
455
					</xsl:variable>
456
					<xsl:if test="starts-with($dateDiff, '-')">
457
						<div style="padding-top: 10px;">
458
							<i18n:text>xmlui.dri2xhtml.METS-1.0.license-cc0</i18n:text>
459
							<xsl:text> &#160; </xsl:text>
460
							<a href="http://creativecommons.org/publicdomain/zero/1.0/" target="_blank">
461
								<img src="/themes/Dryad/images/cc-zero.png"/>
462
							</a>
463
							<a href="http://opendefinition.org/">
464
								<img src="/themes/Dryad/images/opendata.png"/>
465
							</a>
466
						</div>
467
					</xsl:if>
468
				</xsl:when>
469
				<xsl:otherwise>
470
					<div style="padding-top: 10px;">
471
						<i18n:text>xmlui.dri2xhtml.METS-1.0.license-cc0</i18n:text>
472
						<xsl:text> &#160; </xsl:text>
473
						<a href="http://creativecommons.org/publicdomain/zero/1.0/" target="_blank">
474
							<img src="/themes/Dryad/images/cc-zero.png"/>
475
						</a>
476
						<a href="http://opendefinition.org/">
477
							<img src="/themes/Dryad/images/opendata.png"/>
478
						</a>
479
					</div>
480
				</xsl:otherwise>
481
			</xsl:choose>
482
		</xsl:if>
483
	</xsl:template>
484

  
485
	<xsl:template name="checkedAndNoEmbargo">
486
		<table class="ds-table file-list">
487
			<tr class="ds-table-header-row"> </tr>
488
			<tr>
489
				<xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='CONTENT']">
490
					<xsl:with-param name="context" select="."/>
491
					<xsl:with-param name="primaryBitstream"
492
						select="./mets:structMap[@TYPE='LOGICAL']/mets:div[@TYPE='DSpace Item']/mets:fptr/@FILEID"
493
					/>
494
				</xsl:apply-templates>
495
			</tr>
496
		</table>
497
	</xsl:template>
498

  
499

  
500
</xsl:stylesheet>
lib/style/skins/mets/DryadUtils.xsl
1
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
2
    xmlns:dri="http://di.tamu.edu/DRI/1.0/" xmlns:mets="http://www.loc.gov/METS/"
3
    xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
4
    xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/TR/xlink/"
5
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan"
6
    xmlns:datetime="http://exslt.org/dates-and-times" xmlns:encoder="xalan://java.net.URLEncoder"
7
    xmlns:strings="http://exslt.org/strings"
8
    exclude-result-prefixes="xalan strings encoder datetime" version="1.0">
9
	
10
    <xsl:variable name="ascii"> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:variable> 
11
    <xsl:variable name="latin1">&#160;&#161;&#162;&#163;&#164;&#165;&#166;&#167;&#168;&#169;&#170;&#171;&#172;&#173;&#174;&#175;&#176;&#177;&#178;&#179;&#180;&#181;&#182;&#183;&#184;&#185;&#186;&#187;&#188;&#189;&#190;&#191;&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#215;&#216;&#217;&#218;&#219;&#220;&#221;&#222;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#240;&#241;&#242;&#243;&#244;&#245;&#246;&#247;&#248;&#249;&#250;&#251;&#252;&#253;&#254;&#255;</xsl:variable> 
12
	
13
    <!-- Characters that usually don't need to be escaped --> 
14
    <xsl:variable name="safe">!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:variable> 
15
	
16
    <xsl:variable name="hex" >0123456789ABCDEF</xsl:variable>
17
	
18
    <xsl:template name="name-parse">
19
        <xsl:param name="name"/>
20
        <xsl:variable name="names"
21
            select="strings:split(normalize-space(translate($name, '.', ' ')))"/>
22
        <xsl:variable name="count" select="count($names)"/>
23
        <xsl:if test="$count &gt; 0">
24
            <!-- handle the last name, first -->
25
            <xsl:value-of select="$names[$count]"/>
26
            <xsl:if test="$count &gt; 1">
27
                <!--<xsl:text>, </xsl:text>-->
28
            		<xsl:text> </xsl:text>
29
                <!-- now the first and middle names -->
30
                <xsl:for-each select="$names">
31
                    <xsl:choose>
32
                        <xsl:when test="position() = $count"/>
33
                        <xsl:otherwise>
34
                            <xsl:value-of select="substring(., 1, 1)"/>
35
                            <!--<xsl:text>.</xsl:text>-->
36
                        </xsl:otherwise>
37
                    </xsl:choose>
38
                </xsl:for-each>
39
            </xsl:if>
40
        </xsl:if>
41
    </xsl:template>
42
    <xsl:template name="name-parse-reverse">
43
        <xsl:param name="name"/>
44
        <xsl:variable name="names" select="strings:split(translate($name, '.', ' '), ',')"/>
45
        <xsl:value-of select="normalize-space($names[1])"/>
46
        <xsl:text> </xsl:text>
47
        <xsl:for-each select="strings:split(normalize-space($names[2]), ' ')">
48
        	<xsl:value-of select="substring(., 1, 1)"/>
49
        </xsl:for-each>
50
    </xsl:template>
51
    <datetime:month-lengths xmlns:date="http://exslt.org/dates-and-times">
52
        <datetime:month>31</datetime:month>
53
        <datetime:month>28</datetime:month>
54
        <datetime:month>31</datetime:month>
55
        <datetime:month>30</datetime:month>
56
        <datetime:month>31</datetime:month>
57
        <datetime:month>30</datetime:month>
58
        <datetime:month>31</datetime:month>
59
        <datetime:month>31</datetime:month>
60
        <datetime:month>30</datetime:month>
61
        <datetime:month>31</datetime:month>
62
        <datetime:month>30</datetime:month>
63
        <datetime:month>31</datetime:month>
64
    </datetime:month-lengths>
65
    <xsl:template name="datetime:difference">
66
        <xsl:param name="start"/>
67
        <xsl:param name="end"/>
68
        <xsl:variable name="start-neg" select="starts-with($start, '-')"/>
69
        <xsl:variable name="start-no-neg">
70
            <xsl:choose>
71
                <xsl:when test="$start-neg or starts-with($start, '+')">
72
                    <xsl:value-of select="substring($start, 2)"/>
73
                </xsl:when>
74
                <xsl:otherwise>
75
                    <xsl:value-of select="$start"/>
76
                </xsl:otherwise>
77
            </xsl:choose>
78
        </xsl:variable>
79
        <xsl:variable name="start-no-neg-length" select="string-length($start-no-neg)"/>
80
        <xsl:variable name="start-timezone">
81
            <xsl:choose>
82
                <xsl:when test="substring($start-no-neg, $start-no-neg-length) = 'Z'">Z</xsl:when>
83
                <xsl:otherwise>
84
                    <xsl:variable name="tz"
85
                        select="substring($start-no-neg, $start-no-neg-length - 5)"/>
86
                    <xsl:if
87
                        test="(substring($tz, 1, 1) = '-' or substring($tz, 1, 1) = '+') and substring($tz, 4, 1) = ':'">
88
                        <xsl:value-of select="$tz"/>
89
                    </xsl:if>
90
                </xsl:otherwise>
91
            </xsl:choose>
92
        </xsl:variable>
93
        <xsl:variable name="end-neg" select="starts-with($end, '-')"/>
94
        <xsl:variable name="end-no-neg">
95
            <xsl:choose>
96
                <xsl:when test="$end-neg or starts-with($end, '+')">
97
                    <xsl:value-of select="substring($end, 2)"/>
98
                </xsl:when>
99
                <xsl:otherwise>
100
                    <xsl:value-of select="$end"/>
101
                </xsl:otherwise>
102
            </xsl:choose>
103
        </xsl:variable>
104
        <xsl:variable name="end-no-neg-length" select="string-length($end-no-neg)"/>
105
        <xsl:variable name="end-timezone">
106
            <xsl:choose>
107
                <xsl:when test="substring($end-no-neg, $end-no-neg-length) = 'Z'">Z</xsl:when>
108
                <xsl:otherwise>
109
                    <xsl:variable name="tz" select="substring($end-no-neg, $end-no-neg-length - 5)"/>
110
                    <xsl:if
111
                        test="(substring($tz, 1, 1) = '-' or substring($tz, 1, 1) = '+') and substring($tz, 4, 1) = ':'">
112
                        <xsl:value-of select="$tz"/>
113
                    </xsl:if>
114
                </xsl:otherwise>
115
            </xsl:choose>
116
        </xsl:variable>
117
        <xsl:variable name="difference">
118
            <xsl:if
119
                test="(not(string($start-timezone)) or $start-timezone = 'Z' or (substring($start-timezone, 2, 2) &lt;= 23 and substring($start-timezone, 5, 2) &lt;= 59)) and (not(string($end-timezone)) or $end-timezone = 'Z' or (substring($end-timezone, 2, 2) &lt;= 23 and substring($end-timezone, 5, 2) &lt;= 59))">
120
                <xsl:variable name="start-dt"
121
                    select="substring($start-no-neg, 1, $start-no-neg-length - string-length($start-timezone))"/>
122
                <xsl:variable name="start-dt-length" select="string-length($start-dt)"/>
123
                <xsl:variable name="end-dt"
124
                    select="substring($end-no-neg, 1, $end-no-neg-length - string-length($end-timezone))"/>
125
                <xsl:variable name="end-dt-length" select="string-length($end-dt)"/>
126
                <xsl:variable name="start-year"
127
                    select="substring($start-dt, 1, 4) * (($start-neg * -2) + 1)"/>
128
                <xsl:variable name="end-year"
129
                    select="substring($end-dt, 1, 4) * (($end-neg * -2) + 1)"/>
130
                <xsl:variable name="diff-year" select="$end-year - $start-year"/>
131
                <xsl:choose>
132
                    <xsl:when test="not(number($start-year) and number($end-year))"/>
133
                    <xsl:when test="$start-dt-length = 4 or $end-dt-length = 4">
134
                        <xsl:choose>
135
                            <xsl:when test="$diff-year &lt; 0">-P <xsl:value-of
136
                                    select="$diff-year * -1"/> Y</xsl:when>
137
                            <xsl:otherwise>P <xsl:value-of select="$diff-year"/> Y</xsl:otherwise>
138
                        </xsl:choose>
139
                    </xsl:when>
140
                    <xsl:when
141
                        test="substring($start-dt, 5, 1) = '-' and substring($end-dt, 5, 1) = '-'">
142
                        <xsl:variable name="start-month" select="substring($start-dt, 6, 2)"/>
143
                        <xsl:variable name="end-month" select="substring($end-dt, 6, 2)"/>
144
                        <xsl:variable name="diff-month" select="$end-month - $start-month"/>
145
                        <xsl:choose>
146
                            <xsl:when test="not($start-month &lt;= 12 and $end-month &lt;= 12)"/>
147
                            <xsl:when test="$start-dt-length = 7 or $end-dt-length = 7">
148
                                <xsl:variable name="months" select="$diff-month + ($diff-year * 12)"/>
149
                                <xsl:variable name="abs-months"
150
                                    select="$months * ((($months >= 0) * 2) - 1)"/>
151
                                <xsl:variable name="y" select="floor($abs-months div 12)"/>
152
                                <xsl:variable name="m" select="$abs-months mod 12"/>
153
                                <xsl:if test="$months &lt; 0">-</xsl:if>
154
                                <xsl:text>P</xsl:text>
155
                                <xsl:if test="$y">
156
                                    <xsl:value-of select="$y"/> Y</xsl:if>
157
                                <xsl:if test="$m">
158
                                    <xsl:value-of select="$m"/> M</xsl:if>
159
                            </xsl:when>
160
                            <xsl:when
161
                                test="substring($start-dt, 8, 1) = '-' and substring($end-dt, 8, 1) = '-'">
162
                                <xsl:variable name="start-day" select="substring($start-dt, 9, 2)"/>
163
                                <xsl:variable name="end-day" select="substring($end-dt, 9, 2)"/>
164
                                <xsl:if test="$start-day &lt;= 31 and $end-day &lt;= 31">
165
                                    <xsl:variable name="month-lengths"
166
                                        select="document('')/*/datetime:month-lengths/datetime:month"/>
167
                                    <xsl:variable name="start-y-1" select="$start-year - 1"/>
168
                                    <xsl:variable name="start-leaps"
169
                                        select="floor($start-y-1 div 4) - floor($start-y-1 div 100) + floor($start-y-1 div 400)"/>
170
                                    <xsl:variable name="start-leap"
171
                                        select="(not($start-year mod 4) and $start-year mod 100) or not($start-year mod 400)"/>
172
                                    <xsl:variable name="start-month-days"
173
                                        select="sum($month-lengths[position() &lt; $start-month])"/>
174
                                    <xsl:variable name="start-days">
175
                                        <xsl:variable name="days"
176
                                            select="($start-year * 365) + $start-leaps + $start-month-days + $start-day"/>
177
                                        <xsl:choose>
178
                                            <xsl:when test="$start-leap and $start-month > 2">
179
                                                <xsl:value-of select="$days + 1"/>
180
                                            </xsl:when>
181
                                            <xsl:otherwise>
182
                                                <xsl:value-of select="$days"/>
183
                                            </xsl:otherwise>
184
                                        </xsl:choose>
185
                                    </xsl:variable>
186
                                    <xsl:variable name="end-y-1" select="$end-year - 1"/>
187
                                    <xsl:variable name="end-leaps"
188
                                        select="floor($end-y-1 div 4) - floor($end-y-1 div 100) + floor($end-y-1 div 400)"/>
189
                                    <xsl:variable name="end-leap"
190
                                        select="(not($end-year mod 4) and $end-year mod 100) or not($end-year mod 400)"/>
191
                                    <xsl:variable name="end-month-days"
192
                                        select="sum($month-lengths[position() &lt; $end-month])"/>
193
                                    <xsl:variable name="end-days">
194
                                        <xsl:variable name="days"
195
                                            select="($end-year * 365) + $end-leaps + $end-month-days + $end-day"/>
196
                                        <xsl:choose>
197
                                            <xsl:when test="$end-leap and $end-month > 2">
198
                                                <xsl:value-of select="$days + 1"/>
199
                                            </xsl:when>
200
                                            <xsl:otherwise>
201
                                                <xsl:value-of select="$days"/>
202
                                            </xsl:otherwise>
203
                                        </xsl:choose>
204
                                    </xsl:variable>
205
                                    <xsl:variable name="diff-days" select="$end-days - $start-days"/>
206
                                    <xsl:choose>
207
                                        <xsl:when
208
                                            test="$start-dt-length = 10 or $end-dt-length = 10">
209
                                            <xsl:choose>
210
                                                <xsl:when test="$diff-days &lt; 0">-P <xsl:value-of
211
                                                  select="$diff-days * -1"/> D</xsl:when>
212
                                                <xsl:otherwise>P <xsl:value-of select="$diff-days"/>
213
                                                  D</xsl:otherwise>
214
                                            </xsl:choose>
215
                                        </xsl:when>
216
                                        <xsl:when
217
                                            test="substring($start-dt, 11, 1) = 'T' and substring($end-dt, 11, 1) = 'T' and substring($start-dt, 14, 1) = ':' and substring($start-dt, 17, 1) = ':' and substring($end-dt, 14, 1) = ':' and substring($end-dt, 17, 1) = ':'">
218
                                            <xsl:variable name="start-hour"
219
                                                select="substring($start-dt, 12, 2)"/>
220
                                            <xsl:variable name="start-min"
221
                                                select="substring($start-dt, 15, 2)"/>
222
                                            <xsl:variable name="start-sec"
223
                                                select="substring($start-dt, 18)"/>
224
                                            <xsl:variable name="end-hour"
225
                                                select="substring($end-dt, 12, 2)"/>
226
                                            <xsl:variable name="end-min"
227
                                                select="substring($end-dt, 15, 2)"/>
228
                                            <xsl:variable name="end-sec"
229
                                                select="substring($end-dt, 18)"/>
230
                                            <xsl:if
231
                                                test="$start-hour &lt;= 23 and $end-hour &lt;= 23 and $start-min &lt;= 59 and $end-min &lt;= 59 and $start-sec &lt;= 60 and $end-sec &lt;= 60">
232
                                                <xsl:variable name="min-s" select="60"/>
233
                                                <xsl:variable name="hour-s" select="60 * 60"/>
234
                                                <xsl:variable name="day-s" select="60 * 60 * 24"/>
235
                                                <xsl:variable name="start-tz-adj">
236
                                                  <xsl:variable name="tz"
237
                                                  select="(substring($start-timezone, 2, 2) * $hour-s) + (substring($start-timezone, 5, 2) * $min-s)"/>
238
                                                  <xsl:choose>
239
                                                  <xsl:when test="starts-with($start-timezone, '-')">
240
                                                  <xsl:value-of select="$tz"/>
241
                                                  </xsl:when>
242
                                                  <xsl:when test="starts-with($start-timezone, '+')">
243
                                                  <xsl:value-of select="$tz * -1"/>
244
                                                  </xsl:when>
245
                                                  <xsl:otherwise>0</xsl:otherwise>
246
                                                  </xsl:choose>
247
                                                </xsl:variable>
248
                                                <xsl:variable name="end-tz-adj">
249
                                                  <xsl:variable name="tz"
250
                                                  select="(substring($end-timezone, 2, 2) * $hour-s) + (substring($end-timezone, 5, 2) * $min-s)"/>
251
                                                  <xsl:choose>
252
                                                  <xsl:when test="starts-with($end-timezone, '-')">
253
                                                  <xsl:value-of select="$tz"/>
254
                                                  </xsl:when>
255
                                                  <xsl:when test="starts-with($end-timezone, '+')">
256
                                                  <xsl:value-of select="$tz * -1"/>
257
                                                  </xsl:when>
258
                                                  <xsl:otherwise>0</xsl:otherwise>
259
                                                  </xsl:choose>
260
                                                </xsl:variable>
261
                                                <xsl:variable name="start-secs"
262
                                                  select="$start-sec + ($start-min * $min-s) + ($start-hour * $hour-s) + ($start-days * $day-s) + $start-tz-adj"/>
263
                                                <xsl:variable name="end-secs"
264
                                                  select="$end-sec + ($end-min * $min-s) + ($end-hour * $hour-s) + ($end-days * $day-s) + $end-tz-adj"/>
265
                                                <xsl:variable name="diff-secs"
266
                                                  select="$end-secs - $start-secs"/>
267
                                                <xsl:variable name="s"
268
                                                  select="$diff-secs * ((($diff-secs &lt; 0) * -2) + 1)"/>
269
                                                <xsl:variable name="days"
270
                                                  select="floor($s div $day-s)"/>
271
                                                <xsl:variable name="hours"
272
                                                  select="floor(($s - ($days * $day-s)) div $hour-s)"/>
273
                                                <xsl:variable name="mins"
274
                                                  select="floor(($s - ($days * $day-s) - ($hours * $hour-s)) div $min-s)"/>
275
                                                <xsl:variable name="secs"
276
                                                  select="$s - ($days * $day-s) - ($hours * $hour-s) - ($mins * $min-s)"/>
277
                                                <xsl:if test="$diff-secs &lt; 0">-</xsl:if>
278
                                                <xsl:text>P</xsl:text>
279
                                                <xsl:if test="$days">
280
                                                  <xsl:value-of select="$days"/>
281
                                                  <xsl:text>D</xsl:text>
282
                                                </xsl:if>
283
                                                <xsl:if test="$hours or $mins or $secs">T</xsl:if>
284
                                                <xsl:if test="$hours">
285
                                                  <xsl:value-of select="$hours"/>
286
                                                  <xsl:text>H</xsl:text>
287
                                                </xsl:if>
288
                                                <xsl:if test="$mins">
289
                                                  <xsl:value-of select="$mins"/>
290
                                                  <xsl:text>M</xsl:text>
291
                                                </xsl:if>
292
                                                <xsl:if test="$secs">
293
                                                  <xsl:value-of select="$secs"/>
294
                                                  <xsl:text>S</xsl:text>
295
                                                </xsl:if>
296
                                            </xsl:if>
297
                                        </xsl:when>
298
                                    </xsl:choose>
299
                                </xsl:if>
300
                            </xsl:when>
301
                        </xsl:choose>
302
                    </xsl:when>
303
                </xsl:choose>
304
            </xsl:if>
305
        </xsl:variable>
306
        <xsl:value-of select="$difference"/>
307
    </xsl:template>
308
	<xsl:template name="checkURL">
309
		<xsl:param name="url"/>
310
		<xsl:param name="localize"/>
311
		<xsl:choose>
312
			<xsl:when test="$localize">
313
				<xsl:choose>
314
					<xsl:when test="starts-with($url, 'http://hdl.handle.net/')">
315
						<xsl:value-of select="concat('/handle/', substring($url, 23))"/>
316
					</xsl:when>
317
					<xsl:when test="starts-with($url, 'http://datadryad.org/handle/')">
318
						<xsl:value-of select="concat('/handle/', substring($url, 29))"/>
319
					</xsl:when>
320
					<!--
321
						FIXME: this only works until our numbers reach five spaces;
322
						One solution: have a local webservice that resolves all DOIs
323
					-->
324
					<xsl:when test="starts-with($url, 'http://dx.doi.org/10.5061/')">
325
						<xsl:value-of select="concat('/doi?redirect=doi:', substring($url, 19))"/>
326
					</xsl:when>
327
					<xsl:otherwise>
328
						<xsl:value-of select="$url"/>
329
					</xsl:otherwise>
330
				</xsl:choose>
331
			</xsl:when>
332
			<xsl:otherwise>
333
				<xsl:value-of select="$url"/>
334
			</xsl:otherwise>
335
		</xsl:choose>
336
	</xsl:template>
337
	<!--  
338
		*********************************************
339
		OpenURL COinS Rendering Template
340
		*********************************************
341
		
342
		COinS Example:
343
		
344
		<span class="Z3988" 
345
		title="ctx_ver=Z39.88-2004&amp;
346
		rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;
347
		rfr_id=info%3Asid%2Focoins.info%3Agenerator&amp;
348
		rft.title=Making+WordPress+Content+Available+to+Zotero&amp;
349
		rft.aulast=Kraus&amp;
350
		rft.aufirst=Kari&amp;
351
		rft.subject=News&amp;
352
		rft.source=Zotero%3A+The+Next-Generation+Research+Tool&amp;
353
		rft.date=2007-02-08&amp;
354
		rft.type=blogPost&amp;
355
		rft.format=text&amp;
356
		rft.identifier=http://www.zotero.org/blog/making-wordpress-content-available-to-zotero/&amp;
357
		rft.language=English"></span>
358
		
359
		This Code does not parse authors names, instead relying on dc.contributor to populate the
360
		coins
361
	-->
362
	
363
	<xsl:template name="renderCOinS">
364
		<xsl:text>ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;</xsl:text>
365
		<xsl:for-each select=".//dim:field[@element = 'identifier']">
366
			<xsl:text>rft_id=</xsl:text>
367
			<xsl:value-of select="encoder:encode(string(.))"/>
368
			<xsl:text>&amp;</xsl:text>
369
		</xsl:for-each>
370
		<xsl:text>rfr_id=info%3Asid%2Fdatadryad.org%3Arepo&amp;</xsl:text>
371
		<xsl:for-each select=".//dim:field">
372
			<xsl:value-of select="concat('rft.', @element,'=',encoder:encode(string(.))) "/>
373
			<xsl:if test="position()!=last()">
374
				<xsl:text>&amp;</xsl:text>
375
			</xsl:if>
376
		</xsl:for-each>
377
	</xsl:template>
378

  
379
</xsl:stylesheet>

Also available in: Unified diff