Project

General

Profile

1
<?xml version="1.0"?>
2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
    <xsl:param name="sessid"/>
4
    <xsl:param name="enableediting">false</xsl:param>
5
    <!-- This parameter gets overidden by the chosen default qformat -->
6
    <xsl:param name="qformat">default</xsl:param>
7
    <!-- this module for displaying a list of sbc citations, which is NOT an EML DOC -->
8
    <!-- parameters for searching, to be passed into stylesheet. defaults to all if no select 
9
    need 2 sets of quotes in select= " 'string' "
10
        <xsl:param name="author" select=" 'Reed' "/>   -->
11
    <!-- only using author at present -->
12
    <xsl:param name="author"/>
13
    <xsl:param name="keyword"/>
14
    <xsl:param name="year"/>
15
    
16
    <!-- another output attribute: media-type="text/xml" -->
17
    <xsl:preserve-space elements="text"/>
18
    <!--
19
    a parameter to use for counting authors or editors (using this? think not) -->
20
    <xsl:param name="nameCount"/>
21
    <!--
22
    parameters to use for storing contact author for reprint request  -->
23
    <xsl:param name="contactEmail"/>
24
    <xsl:param name="creatorEmail"/>
25
    <!-- 
26
    
27
   Variables for the DOI:
28
    url which can resolve DOIs (keep the trailing slash, so template can add the doi only)-->
29
    <xsl:variable name="doi_resolver_url">http://dx.doi.org/</xsl:variable>
30
    <!-- 
31
    text for the tooltip keep all on one line!-->
32
    <xsl:variable name="tooltip_text_DOI">Digital Object Identifer (DOI): an identifier for a resource on a digital network. Click on the DOI to go directly to the paper at the publisher\'s website. DOIs simplify maintenance of our database because a \'Resolver\' managed by the DOI Foundation handles the connection between the browser and the publisher\'s website</xsl:variable>
33
    <!--
34
    
35
    keys for grouping by year.    -->
36
    <!--  a key for grouping articles by pubdate -->
37
    <xsl:key name="articles-by-pubDate" match="citation[(article or chapter) and
38
        normalize-space(pubDate) ]" use="pubDate"/>
39
    <!--  
40
    a key for grouping presentations by pubdate -->
41
    <xsl:key name="presentations-by-pubDate" match="citation[(presentation) and
42
        normalize-space(pubDate)]" use="pubDate"/>
43
    <!--  
44
    a key for grouping articles by pubdate and author
45
    an attempt at more complicated grouping, to get the label and the citations to show together
46
    doesnt work yet. -->
47
    <xsl:key name="articles-by-pubDate_author" match="citation[(article or chapter) and
48
        normalize-space(pubDate)]" use="concat(pubDate,':',creator/individualName/surName)"/>
49
    <!--
50
    
51
      create a path to the tooltip.js (get tokens in for this)      @style-skins-path@/{$qformat}  -->
52
    <xsl:variable name="javascript_path">/catalog/style/skins/sbclter</xsl:variable>
53
    <!--
54
    
55
    create a metacat url with variables (switch to tokens, please) -->
56
    <xsl:variable name="catalog">http://sbc.lternet.edu/catalog/</xsl:variable>
57
    <xsl:variable name="style">sbclter</xsl:variable>
58
    <xsl:variable name="metacat_url">
59
        <xsl:value-of select="$catalog"/>
60
        <xsl:text>metacat?action=read&amp;qformat=</xsl:text>
61
        <xsl:value-of select="$style"/>
62
        <xsl:text>&amp;docid=</xsl:text>
63
        <!-- docid attached later -->
64
    </xsl:variable>
65
    <!--
66
    variable for sending reprint request via email -->
67
    <!--   <xsl:variable name="send_email">
68
           <a href="mailto:{$contactEmail}?subject=Reprint Request, via SBC-LTER pubsDB">request from author</a> 
69
    </xsl:variable>  -->
70
    <!-- 
71
    Change this match expression if reading single-citation docs
72
    
73
    
74
    -->
75
    <xsl:template match="/citationList">
76
   
77
        <html>
78
            <head>
79
                <script type="text/javascript"/>
80
                <!--
81
                        <script language="JavaScript" type="text/javascript" src="./wz_tooltip.js"></script>
82
             -->
83
                <!--
84
                <script language="JavaScript">
85
                    <![CDATA[
86
                    function resolve_doi {
87
                        document.getSelection();
88
                         if(!Qr){void(Qr=prompt('Enter DOI to resolve, e.g. 10.1000/202:',''))}
89
                         if(Qr)location.href='http://dx.doi.org/'+escape(Qr)+' '
90
                   ]]>
91
                    </script>
92
        -->
93
                <!-- begin the header area
94
        <xsl:call-template name="pageheader" />
95
        end the header area -->
96
            </head>
97
            <body>
98
                <table>
99
                    <tr>
100
                        <td>
101
                            <a name="INPRESS"/>
102
                            <h4>In Press</h4>
103
                        </td>
104
                    </tr>
105
                    <!-- matches only publish-able citations (no theses or presentations), 
106
			which also have an empty (or whitespace) pubDate -->
107
                    <xsl:for-each select="citation[(article or
108
                        chapter or
109
                        book or                 
110
                        editedBook or                
111
                        report or
112
                        audioVisual) and                     
113
                        not(normalize-space(pubDate)) and
114
                        creator/individualName/surName[contains(.,$author)] 
115
                        ]">
116
                        <xsl:sort select="creator/individualName/surName" order="ascending"/>
117
                        <tr>
118
                            <td class="eighty_percent">
119
                                <div class="hanging-paragraph smaller-font bottom-padding">
120
                                    <xsl:call-template name="citation">
121
                                        <xsl:with-param name="author"/>
122
                                    </xsl:call-template>
123
                                </div>
124
                            </td>
125
                            <td class="twenty_percent">
126
                                <div class="bottom-padding left-padding smaller-font">
127
                                    <xsl:call-template name="paper_link_doi"/>
128
                                </div>
129
                            </td>
130
                        </tr>
131
                    </xsl:for-each>
132
                    <tr>
133
                        <td>
134
                            <h4>Published</h4>
135
                        </td>
136
                    </tr>
137
                    <tr>
138
                        <td>
139
                            <a id="ART_CHAP"/>
140
                            <h5>Articles and Chapters</h5>
141
                        </td>
142
                    </tr>
143
                    <!-- citation[(article or chapter) and normalize-space(pubDate) and -->
144
                    <xsl:for-each select="
145
                        citation[generate-id(.)=generate-id(key('articles-by-pubDate',
146
                        pubDate))]/pubDate">
147
                        <xsl:sort select="." order="descending"/>
148
                        <tr>
149
                            <td>
150
                                <h5>
151
                                    <xsl:value-of select="."/>
152
                                </h5>
153
                            </td>
154
                        </tr>
155
                        <!--    <tr><td><xsl:value-of select="count(key('articles-by-pubDate',.))"/></td></tr> -->
156
                        <xsl:for-each select="key('articles-by-pubDate',.)">
157
                            <xsl:sort select="creator/individualName/surName" order="ascending"/>
158
                            <xsl:if test="creator/individualName/surName[contains(.,$author)] ">
159
                                <tr>
160
                                    <td class="eighty_percent">
161
                                        <div class="hanging-paragraph smaller-font bottom-padding">
162
                                            <xsl:call-template name="citation">
163
                                                <xsl:with-param name="author" select="$author"/>
164
                                            </xsl:call-template>
165
                                        </div>
166
                                    </td>
167
                                    <td class="twenty_percent">
168
                                        <div class="bottom-padding left-padding smaller-font">
169
                                            <xsl:call-template name="paper_link_doi"/>
170
                                        </div>
171
                                    </td>
172
                                </tr>
173
                            </xsl:if>
174
                        </xsl:for-each>
175
                    </xsl:for-each>
176
                    <tr>
177
                        <td>
178
                            <a id="BOOKS"/>
179
                            <h5>Books</h5>
180
                        </td>
181
                    </tr>
182
                    <xsl:for-each select="citation[(book or editedBook) and
183
                        normalize-space(pubDate) and
184
                        creator/individualName/surName[contains(.,$author)] ]">
185
                        <xsl:sort select="creator/individualName/surName" order="ascending"/>
186
                        <tr>
187
                            <td class="eighty_percent">
188
                                <div class="hanging-paragraph smaller-font bottom-padding">
189
                                    <xsl:call-template name="citation">
190
                                        <xsl:with-param name="author"/>
191
                                    </xsl:call-template>
192
                                </div>
193
                            </td>
194
                            <td class="twenty_percent">
195
                                <div class="bottom-padding left-padding smaller-font">
196
                                    <xsl:call-template name="paper_link_doi"/>
197
                                </div>
198
                            </td>
199
                        </tr>
200
                    </xsl:for-each>
201
                    <tr>
202
                        <td>
203
                            <a id="THESES"/>
204
                            <h5>Theses</h5>
205
                        </td>
206
                    </tr>
207
                    <xsl:for-each select="citation[thesis and
208
                        normalize-space(pubDate) and
209
                        creator/individualName/surName[contains(.,$author)] ] ">
210
                        <xsl:sort select="creator/individualName/surName" order="ascending"/>
211
                        <tr>
212
                            <td class="eighty_percent">
213
                                <div class="hanging-paragraph smaller-font bottom-padding">
214
                                    <xsl:call-template name="citation">
215
                                        <xsl:with-param name="author"/>
216
                                    </xsl:call-template>
217
                                </div>
218
                            </td>
219
                            <td class="twenty_percent">
220
                                <div class="bottom-padding left-padding smaller-font">
221
                                    <xsl:call-template name="paper_link_doi"/>
222
                                </div>
223
                            </td>
224
                        </tr>
225
                    </xsl:for-each>
226
                    <tr>
227
                        <td>
228
                            <a id="REP_CP"/>
229
                            <h5>Reports and Contributions to Conference Proceedings</h5>
230
                        </td>
231
                    </tr>
232
                    <xsl:for-each select="citation[(report or conferenceProceedings) and
233
                        normalize-space(pubDate) and
234
                        creator/individualName/surName[contains(.,$author)]  ]">
235
                        <xsl:sort select="creator/individualName/surName" order="ascending"/>
236
                        <tr>
237
                            <td class="eighty_percent">
238
                                <div class="hanging-paragraph smaller-font bottom-padding">
239
                                    <xsl:call-template name="citation">
240
                                        <xsl:with-param name="author"/>
241
                                    </xsl:call-template>
242
                                </div>
243
                            </td>
244
                            <td class="twenty_percent">
245
                                <div class="bottom-padding left-padding smaller-font">
246
                                    <xsl:call-template name="paper_link_doi"/>
247
                                </div>
248
                            </td>
249
                        </tr>
250
                    </xsl:for-each>
251
                    <tr>
252
                        <td>
253
                            <a id="AV"/>
254
                            <h5>Audio-Visual Resources</h5>
255
                        </td>
256
                    </tr>
257
                    <xsl:for-each select="citation[audioVisual and
258
                        normalize-space(pubDate) and
259
                        creator/individualName/surName[contains(.,$author)]  ] ">
260
                        <xsl:sort select="creator/individualName/surName" order="ascending"/>
261
                        <tr>
262
                            <td class="eighty_percent">
263
                                <div class="hanging-paragraph smaller-font bottom-padding">
264
                                    <xsl:call-template name="citation">
265
                                        <xsl:with-param name="author"/>
266
                                    </xsl:call-template>
267
                                </div>
268
                            </td>
269
                            <td class="twenty_percent">
270
                                <div class="bottom-padding left-padding smaller-font">
271
                                    <xsl:call-template name="paper_link_doi"/>
272
                                </div>
273
                            </td>
274
                        </tr>
275
                    </xsl:for-each>
276
                    <tr>
277
                        <td>
278
                            <a id="PRESENTATIONS"/>
279
                            <h4>Presentations</h4>
280
                        </td>
281
                    </tr>
282
                    <xsl:for-each select="citation[presentation and
283
                        normalize-space(pubDate) and
284
                        generate-id(.)=generate-id(key('presentations-by-pubDate',pubDate))]/pubDate
285
                        ">
286
                        <xsl:sort select="." order="descending"/>
287
                        <tr>
288
                            <td>
289
                                <h5>
290
                                    <xsl:value-of select="."/>
291
                                </h5>
292
                            </td>
293
                        </tr>
294
                        <xsl:for-each select="key('presentations-by-pubDate',.)">
295
                            <xsl:sort select="creator/individualName/surName" order="ascending"/>
296
                            <xsl:if test="creator/individualName/surName[contains(.,$author)] ">
297
                                <tr>
298
                                    <td class="eighty_percent">
299
                                        <div class="hanging-paragraph smaller-font bottom-padding">
300
                                            <xsl:call-template name="citation">
301
                                                <xsl:with-param name="author" select="$author"/>
302
                                            </xsl:call-template>
303
                                        </div>
304
                                    </td>
305
                                    <td class="twenty_percent">
306
                                        <div class="bottom-padding left-padding smaller-font">
307
                                            <xsl:call-template name="paper_link_doi"/>
308
                                        </div>
309
                                    </td>
310
                                </tr>
311
                            </xsl:if>
312
                        </xsl:for-each>
313
                    </xsl:for-each>
314
                </table>
315
                <script type="text/javascript" language="JavaScript">
316
                    <xsl:attribute name="src">
317
                        <xsl:value-of select="$javascript_path"/>
318
                        <xsl:text>/wz_tooltip.js</xsl:text>
319
                    </xsl:attribute>
320
                </script>
321
                <!-- <script language="JavaScript" type="text/javascript" src="./wz_tooltip.js"></script>  -->
322
            </body>
323
        </html>
324
        <!-- begin the footer area
325
        <xsl:call-template name="pagefooter" />
326
         end the footer area -->
327
        <!-- 
328

    
329
	used to be closing body and html tags here
330

    
331

    
332

    
333

    
334

    
335

    
336

    
337

    
338

    
339
-->
340
    </xsl:template>
341
    <!--
342
    -->
343
    <!--
344
    -->
345
    <xsl:template match="citation" name="citation">
346
        <xsl:param name="nameCount" select="count(creator)"/>
347
        <!-- 
348
        <tr>
349
            <td class="eighty_percent">  
350
                <div class="hanging-paragraph smaller-font bottom-padding"> -->
351
        <!--
352
                        ? put these (authors, date, title) in a tempate called citation_common? -->
353
        <!--
354
                        display authors with template, add punct.-->
355
        <xsl:call-template name="display_names">
356
            <xsl:with-param name="nameCount" select="$nameCount"/>
357
            <!-- doesnt seem to like this parameter. why? -->
358
        </xsl:call-template>
359
        <xsl:apply-templates select="creator/individualName"/>
360
        <!--
361
                        punctuate creators, add text if this is an edited book 
362
			note: jsp did not like the &#160; that was in the empty text string. alternative? 
363
			oxygen cleaned this to remove whitespace if I didnt put in. -->
364
        <xsl:choose>
365
            <xsl:when test="$nameCount=1">
366
                <xsl:choose>
367
                    <xsl:when test="editedBook">
368
                        <xsl:text>, ed. </xsl:text>
369
                    </xsl:when>
370
                    <xsl:otherwise>
371
                        <xsl:text> </xsl:text>
372
                    </xsl:otherwise>
373
                </xsl:choose>
374
            </xsl:when>
375
            <xsl:otherwise>
376
                <!-- more than one creator -->
377
                <xsl:choose>
378
                    <xsl:when test="editedBook">
379
                        <xsl:text>, eds. </xsl:text>
380
                    </xsl:when>
381
                    <xsl:otherwise>
382
                        <xsl:text>. </xsl:text>
383
                    </xsl:otherwise>
384
                </xsl:choose>
385
            </xsl:otherwise>
386
        </xsl:choose>
387
        <!--
388
                        the date goes in only if published -->
389
        <xsl:if test="normalize-space(pubDate)">
390
            <xsl:value-of select="pubDate"/>
391
            <xsl:text>. </xsl:text>
392
        </xsl:if>
393
        <!-- 
394
                        the title goes in all. books are underlined. 
395
	            titles are mixed content: apply-templates invokes built-in rule 
396
	            for title text, italics template below. -->
397
        <xsl:choose>
398
            <xsl:when test="editedBook">
399
                <xsl:call-template name="display-book-title"/>
400
            </xsl:when>
401
            <xsl:when test="book">
402
                <xsl:call-template name="display-book-title"/>
403
            </xsl:when>
404
            <xsl:otherwise>
405
                <xsl:apply-templates select="title"/>
406
                <xsl:text>. </xsl:text>
407
            </xsl:otherwise>
408
        </xsl:choose>
409
        <!-- 
410

    
411

    
412
                        end of common area. 
413
                        add the rest of the citation using a template for each type
414
                    Note: the ifs are now takin care of in the type templates, and inpress pubs should
415
                    show whatever info is available. -->
416
        <!--         <xsl:if test="normalize-space(pubDate)"> -->
417
        <xsl:choose>
418
            <xsl:when test="article">
419
                <xsl:call-template name="article"/>
420
            </xsl:when>
421
            <xsl:when test="chapter">
422
                <xsl:call-template name="chapter"/>
423
            </xsl:when>
424
            <xsl:when test="book">
425
                <xsl:call-template name="book"/>
426
            </xsl:when>
427
            <xsl:when test="editedBook">
428
                <xsl:call-template name="editedBook"/>
429
            </xsl:when>
430
            <xsl:when test="thesis">
431
                <xsl:call-template name="thesis"/>
432
            </xsl:when>
433
            <xsl:when test="presentation">
434
                <xsl:call-template name="presentation"/>
435
            </xsl:when>
436
            <xsl:when test="report">
437
                <xsl:call-template name="report"/>
438
            </xsl:when>
439
            <xsl:when test="audioVisual">
440
                <xsl:call-template name="audioVisual"/>
441
            </xsl:when>
442
            <xsl:when test="conferenceProceedings">
443
                <xsl:call-template name="proceedings"/>
444
            </xsl:when>
445
        </xsl:choose>
446
        
447
        <!-- this bit  shows the sbc id. for now, it makes entries easier to find and edit, but it can also be used to pull up a single-page view  -->
448
        <xsl:text> (sbc-id: </xsl:text>
449
        <xsl:value-of select="alternateIdentifier[@system='sbclter-bibliography']"/>
450
        <xsl:text>)</xsl:text>
451
        
452
        
453
        <!--           </xsl:if>  -->
454
        <!-- 
455
                </div>
456
            </td> 
457
            <td class="twenty_percent">
458
                <div class="bottom-padding left-padding smaller-font">
459
         -->
460
        <!-- 
461
                    
462
                    put the link to paper or resource here
463
                    <xsl:call-template name="paper_link_doi"/>
464
                </div>
465
            </td>
466
         -->
467
        <!-- 
468
        
469
        save till later 
470
            <td class="fifteen_percent">
471
	    <div class="smaller-font bottom-padding">
472
                 <xsl:call-template name="dataset_link"/>
473
		</div>
474
            </td>
475
        </tr> -->
476
    </xsl:template>
477
    <!--
478
    template to display author's names (creator tree). also needed when citation is a chapter, for book's editors (editor tree) -->
479
    <xsl:template name="display_names" match="creator/individualName |
480
        chapter/editor/individualName">
481
        <!-- <xsl:param name="nameCount" select="$nameCount"/> -->
482
        <xsl:variable name="nameCount" select="count(../../creator | ../../editor)"/>
483
        <xsl:if test="$nameCount = 1">
484
            <xsl:call-template name="surName_inits"/>
485
        </xsl:if>
486
        <!--- 
487
                         2 authors: last, f. and f. last -->
488
        <xsl:if test="$nameCount = 2">
489
            <xsl:if test="position() = 1">
490
                <xsl:call-template name="surName_inits"/>
491
                <xsl:text> and </xsl:text>
492
                <xsl:text/>
493
            </xsl:if>
494
            <xsl:if test="position() = 2">
495
                <xsl:call-template name="inits_surName"/>
496
            </xsl:if>
497
        </xsl:if>
498
        <!-- 3+ authors: last, f., f. last, f. last and f. last -->
499
        <xsl:if test="$nameCount &gt;2 ">
500
            <xsl:choose>
501
                <xsl:when test="position() = 1">
502
                    <xsl:call-template name="surName_inits"/>
503
                    <xsl:text>, </xsl:text>
504
                </xsl:when>
505
                <xsl:when test="position() = last()-1">
506
                    <xsl:call-template name="inits_surName"/>
507
                    <xsl:text> and </xsl:text>
508
                </xsl:when>
509
                <xsl:when test="position() = last()">
510
                    <xsl:call-template name="inits_surName"/>
511
                </xsl:when>
512
                <xsl:otherwise>
513
                    <xsl:call-template name="inits_surName"/>
514
                    <xsl:text>, </xsl:text>
515
                </xsl:otherwise>
516
            </xsl:choose>
517
        </xsl:if>
518
    </xsl:template>
519
    <!--
520
    template for formatting author names -->
521
    <!-- surName, initials -->
522
    <xsl:template name="surName_inits">
523
        <xsl:value-of select="surName"/>
524
        <xsl:text>, </xsl:text>
525
        <xsl:for-each select="givenName">
526
            <xsl:value-of select="substring(.,1,1)"/>
527
            <xsl:choose>
528
                <xsl:when test="position() = last()">
529
                    <xsl:text>.</xsl:text>
530
                </xsl:when>
531
                <xsl:otherwise>
532
                    <xsl:text>. </xsl:text>
533
                </xsl:otherwise>
534
            </xsl:choose>
535
        </xsl:for-each>
536
    </xsl:template>
537
    <!--
538
    template for formatting author names -->
539
    <!--initials surName -->
540
    <xsl:template name="inits_surName">
541
        <xsl:for-each select="givenName">
542
            <xsl:value-of select="substring(.,1,1)"/>
543
            <xsl:text>. </xsl:text>
544
        </xsl:for-each>
545
        <xsl:value-of select="surName"/>
546
    </xsl:template>
547
    <!--
548
    TEMPLATE FOR BOOK TITLES (used conditionally)-->
549
    <xsl:template name="display-book-title">
550
        <u>
551
            <xsl:apply-templates select="title"/>
552
        </u>
553
        <xsl:text>.&#160; </xsl:text>
554
    </xsl:template>
555
    <!--
556
    TEMPLATE FOR chapter/bookTitle (always underlined) -->
557
    <xsl:template name="display-bookTitle">
558
        <xsl:if test="chapter">
559
            <u>
560
                <xsl:apply-templates select="chapter/bookTitle"/>
561
            </u>
562
        </xsl:if>
563
        <xsl:if test="conferenceProceedings">
564
            <u>
565
                <xsl:apply-templates select="conferenceProceedings/bookTitle"/>
566
            </u>
567
        </xsl:if>
568
        <xsl:text>.&#160;</xsl:text>
569
    </xsl:template>
570
    <!--
571
    TEMPLATE FOR ITALICs -->
572
    <xsl:template match="emphasis">
573
        <i>
574
            <xsl:apply-templates/>
575
        </i>
576
    </xsl:template>
577
    <!-- to be replaced with this, eventually?
578
    <xsl:template match="italic">
579
         <i><xsl:apply-templates/></i>
580
     </xsl:template>
581
    <xsl:template match="bold">
582
         <b><xsl:apply-templates/></b>
583
     </xsl:template>
584
    <xsl:template match="underline">
585
         <u><xsl:apply-templates/></u>
586
     </xsl:template>
587
-->
588
    <!-- 
589
    TEMPLATE for a conferenceLocation ADDRESS -->
590
    <xsl:template name="address">
591
        <!--  this template is called, so context node is citation, and match need to be in test statements -->
592
        <xsl:if test="descendant::deliveryPoint">
593
            <xsl:for-each select="descendant::deliveryPoint">
594
                <xsl:value-of select="."/>
595
                <!-- its not last delivery point, so a comma between -->
596
                <xsl:if test="position() != last()">, </xsl:if>
597
                <!--  if its the last deliveryPoint, and more address tags follow, put a comma. -->
598
                <xsl:if test="position() = last()">
599
                    <xsl:if test="following-sibling::*">
600
                        <xsl:text>, </xsl:text>
601
                    </xsl:if>
602
                </xsl:if>
603
            </xsl:for-each>
604
            <!-- finished with deliveryPoints -->
605
        </xsl:if>
606
        <xsl:if test="descendant::city">
607
            <xsl:value-of select="descendant::city"/>
608
            <xsl:if test="descendant::administrativeArea">
609
                <xsl:text>, </xsl:text>
610
            </xsl:if>
611
            <xsl:if test="descendant::country">
612
                <xsl:text>, </xsl:text>
613
            </xsl:if>
614
        </xsl:if>
615
        <xsl:if test="descendant::administrativeArea">
616
            <xsl:value-of select="descendant::administrativeArea"/>
617
            <xsl:if test="descendant::country">
618
                <xsl:text>, </xsl:text>
619
            </xsl:if>
620
        </xsl:if>
621
        <xsl:if test="descendant::country">
622
            <xsl:value-of select="descendant::country"/>
623
        </xsl:if>
624
        <!-- end with .  -->
625
        <xsl:text>.</xsl:text>
626
    </xsl:template>
627
    <!-- 
628
    TEMPLATE FOR ARTICLE REF -->
629
    <xsl:template name="article">
630
        <xsl:if test="descendant::journal[text()]">
631
            <xsl:value-of select="article/journal"/>
632
            <xsl:if test="descendant::volume[text()]">
633
                <xsl:text>, </xsl:text>
634
                <xsl:value-of select="article/volume"/>
635
                <xsl:if test="descendant::pageRange[text()]">
636
                    <xsl:text>: </xsl:text>
637
                    <xsl:value-of select="article/pageRange"/>
638
                </xsl:if>
639
            </xsl:if>
640
        </xsl:if>
641
        <xsl:text>. </xsl:text>
642
    </xsl:template>
643
    <!-- 
644
    TEMPLATE FOR CHAPTER REF -->
645
    <xsl:template name="chapter">
646
        <xsl:text>in: </xsl:text>
647
        <xsl:call-template name="display-bookTitle"/>
648
        <xsl:call-template name="display_names"/>
649
        <xsl:apply-templates select="chapter/editor/individualName"/>
650
        <!-- add punctuation for the editors-->
651
        <xsl:choose>
652
            <xsl:when test="$nameCount=1">
653
                <xsl:text>,&#160;ed.&#160;</xsl:text>
654
            </xsl:when>
655
            <xsl:otherwise>
656
                <!-- more than one creator -->
657
                <xsl:text>,&#160;eds.&#160;</xsl:text>
658
            </xsl:otherwise>
659
        </xsl:choose>
660
        <xsl:value-of select="chapter/publisher/organizationName"/>
661
        <xsl:text>.&#160;</xsl:text>
662
    </xsl:template>
663
    <!-- 
664
    TEMPLATE FOR BOOK REF -->
665
    <xsl:template name="book">
666
        <xsl:value-of select="book/publisher/organizationName"/>
667
        <xsl:text>. </xsl:text>
668
        <xsl:if test="descendant::totalPages[text()]">
669
            <xsl:value-of select="book/totalPages"/>
670
            <xsl:text>pp. </xsl:text>
671
        </xsl:if>
672
    </xsl:template>
673
    <!-- 
674
    TEMPLATE FOR editedBOOK REF -->
675
    <xsl:template name="editedBook">
676
        <xsl:value-of select="editedBook/publisher/organizationName"/>
677
        <xsl:text>. </xsl:text>
678
        <xsl:if test="editedBook/totalPages">
679
            <xsl:value-of select="."/>
680
            <xsl:text>pp. </xsl:text>
681
        </xsl:if>
682
    </xsl:template>
683
    <!-- 
684
    TEMPLATE FOR conferenceProceedings REF -->
685
    <xsl:template name="proceedings">
686
        <xsl:text> In: </xsl:text>
687
        <xsl:call-template name="display-bookTitle"/>
688
        <xsl:if test="descendant::pageRange[text()]">
689
            <xsl:text>pp</xsl:text>
690
            <xsl:value-of select="*/pageRange"/>
691
            <xsl:text>. </xsl:text>
692
        </xsl:if>
693
        <xsl:if test="descendant::conferenceDate[text()]">
694
            <xsl:value-of select="*/conferenceDate"/>
695
            <xsl:text>. </xsl:text>
696
        </xsl:if>
697
        <xsl:call-template name="address"/>
698
        <xsl:text>(</xsl:text>
699
        <xsl:value-of select="conferenceProceedings/publisher/organizationName"/>
700
        <xsl:text>).</xsl:text>
701
    </xsl:template>
702
    <!-- 
703
    TEMPLATE FOR report REF -->
704
    <xsl:template name="report">
705
        <xsl:if test="report/reportNumber">
706
            <xsl:text>Rpt. No. </xsl:text>
707
            <xsl:value-of select="report/reportNumber"/>
708
            <xsl:text>, </xsl:text>
709
        </xsl:if>
710
        <xsl:if test="report/publisher/organizationName">
711
            <xsl:value-of select="report/publisher/organizationName"/>
712
            <xsl:text>. </xsl:text>
713
        </xsl:if>
714
        <xsl:if test="report/totalPages">
715
            <xsl:value-of select="report/totalPages"/>
716
            <xsl:text>pp. </xsl:text>
717
        </xsl:if>
718
    </xsl:template>
719
    <!-- 
720
    TEMPLATE FOR THESIS REF -->
721
    <xsl:template name="thesis">
722
        <xsl:value-of select="thesis/degree"/>
723
        <xsl:text>, </xsl:text>
724
        <xsl:value-of select="thesis/institution/organizationName"/>
725
        <!--  look for text in descendants of sibs following institution  -->
726
        <xsl:choose>
727
            <xsl:when test="thesis/institution/following-sibling::descendant[text()]">
728
                <xsl:text>, </xsl:text>
729
                <xsl:if test="descendant::address[child::*[text()]]">
730
                    <xsl:call-template name="address"/>
731
                </xsl:if>
732
                <xsl:if test="descendant::totalPages[text()]">
733
                    <xsl:text>&#160;</xsl:text>
734
                    <xsl:value-of select="thesis/totalPages"/>
735
                    <xsl:text>pp.</xsl:text>
736
                </xsl:if>
737
            </xsl:when>
738
            <xsl:otherwise>
739
                <!-- nothing follows institution -->
740
                <xsl:text>.</xsl:text>
741
            </xsl:otherwise>
742
        </xsl:choose>
743
    </xsl:template>
744
    <!-- 
745
    TEMPLATE FOR AUDIO-VISUAL REF -->
746
    <xsl:template name="audioVisual">
747
        <xsl:value-of select="audioVisual/publisher/organizationName"/>
748
        <xsl:text>. </xsl:text>
749
        <xsl:if test="audioVisual/publicationPlace">
750
            <xsl:value-of select="audioVisual/publicationPlace"/>
751
            <xsl:text>. </xsl:text>
752
        </xsl:if>
753
    </xsl:template>
754
    <!-- 
755
    TEMPLATE FOR PRESENTATION REF -->
756
    <xsl:template name="presentation">
757
        <xsl:text> at: </xsl:text>
758
        <xsl:value-of select="presentation/conferenceName"/>
759
        <!-- if a citation has a address descendant with a child containing text, 
760
            add a comma and call address, otherwise end with a . -->
761
        <xsl:choose>
762
            <xsl:when test="descendant::address[child::*[text()]]">
763
                <xsl:text>, </xsl:text>
764
                <xsl:call-template name="address"/>
765
            </xsl:when>
766
            <xsl:otherwise>
767
                <xsl:text>.</xsl:text>
768
            </xsl:otherwise>
769
        </xsl:choose>
770
    </xsl:template>
771
    <!-- 
772

    
773
    Include a link to the paper. FIrst look for a DOI. 
774
    then a pdf or doc (for inpress only?) or a ppt for presentation.
775
    default to author's email, defaults or text if no usable info. -->
776
    <!-- 
777
    
778
    
779
    *** you could reorganize the whole damn thing and create templates for accessing each type of resource. 
780
    which can hold the entire row. currently, parts of each , and now the second col is type-dependent. 
781
    then you can sort the big chunk of articles by date within it's own template! -->
782
    <xsl:template name="paper_link_doi">
783
        <xsl:variable name="paperUrl" select="distribution/online/url"/>
784
        <xsl:variable name="paperDoi" select="alternateIdentifier[@system='DOI']"/>
785
        <xsl:variable name="contactEmail" select="normalize-space(contact/electronicMailAddress)"/>
786
        <xsl:variable name="creatorEmail"
787
            select="normalize-space(creator[position()=1]/electronicMailAddress)"/>
788
        <xsl:choose>
789
            <xsl:when test="not(normalize-space(pubDate))">
790
            <!-- the paper is not yet published, ok to distribute a pdf or word doc (wont have a doi yet.) -->
791
                <xsl:choose>
792
                    <xsl:when test="contains($paperUrl,'.pdf')">
793
                        <a href="{$paperUrl}">view PDF document</a>
794
                    </xsl:when>
795
                    <xsl:when test="contains($paperUrl,'.doc')">
796
                        <a href="{$paperUrl}">MS-Word preprint</a>
797
                    </xsl:when>
798
                    <xsl:when test="contains($paperUrl,'.gov')">
799
                        <a href="{$paperUrl}">available</a>
800
                    </xsl:when>
801
                    <xsl:otherwise>
802
                        <!-- no distribution/url, so default to an email address -->
803
                        <xsl:call-template name="create_email_link">
804
                            <xsl:with-param name="contactEmail" select="$contactEmail"/>
805
                            <xsl:with-param name="creatorEmail" select="$creatorEmail"/>
806
                        </xsl:call-template>
807
                    </xsl:otherwise>
808
                </xsl:choose>
809
            </xsl:when>
810
            <xsl:otherwise>
811
                <!--  
812
                it's got a pub date, copyrights may apply -->
813
                <xsl:choose>
814
                    <!-- but if its a presentation, OK to distribute a powerpoint  -->
815
                <xsl:when test="presentation">
816
                    <xsl:choose>
817
                        <xsl:when test="contains($paperUrl,'.ppt')">
818
                            <a href="{$paperUrl}">PowerPoint document</a>
819
                        </xsl:when>
820
                        <xsl:otherwise>
821
                            <xsl:call-template name="create_email_link">
822
                                <xsl:with-param name="contactEmail" select="$contactEmail"/>
823
                                <xsl:with-param name="creatorEmail" select="$creatorEmail"/>
824
                            </xsl:call-template>
825
                        </xsl:otherwise>
826
                    </xsl:choose>
827
                </xsl:when>
828
            <xsl:otherwise>
829
                <!--  its got a pub date, and its not a presentation, so copyrights probably apply.
830
                look for a DOI first-->
831
                <!-- 
832
                (maybe will need a url to another catalog, eg, for a film, report or proceedings? -->
833
                <xsl:choose>
834
                    <xsl:when test="$paperDoi">
835
                        <!-- resolve the DOI, with a url  -->
836
                        <a>
837
                            <xsl:attribute name="href">
838
                                <xsl:value-of select="$doi_resolver_url"/>
839
                                <xsl:value-of select="$paperDoi "/>
840
                            </xsl:attribute>
841
			<!--        
842
		    <xsl:value-of select="$paperDoi"/>
843
			-->
844
			access with DOI
845
                            <!-- available via paper's DOI -->
846
                        </a>
847
                        <br/>
848
                        <a href="http://doi.org">
849
                            <xsl:attribute name="onmouseover">
850
                                <xsl:text>return escape('</xsl:text>
851
                                <xsl:value-of select="$tooltip_text_DOI"/>
852
                                <xsl:text>')</xsl:text>
853
                            </xsl:attribute> (what's this?) </a>
854
                    </xsl:when>
855
                    <xsl:when test="contains($paperUrl,'.com')">
856
                        <a href="{$paperUrl}">see publisher website</a>
857
                    </xsl:when>
858
                    <xsl:when test="contains($paperUrl,'.gov')">
859
                        <a href="{$paperUrl}">available</a>
860
                    </xsl:when>
861
                    <xsl:when test="contains($paperUrl,'.html')">
862
                        <a href="{$paperUrl}">available through another catalog</a>
863
                    </xsl:when>
864
                    <xsl:otherwise>
865
                        <!-- email the contact author -->
866
                        <xsl:call-template name="create_email_link">
867
                            <xsl:with-param name="contactEmail" select="$contactEmail"/>
868
                            <xsl:with-param name="creatorEmail" select="$creatorEmail"/>
869
                        </xsl:call-template>
870
                    </xsl:otherwise>
871
                </xsl:choose>
872
            </xsl:otherwise>
873
                </xsl:choose>
874
            </xsl:otherwise>
875
            </xsl:choose>
876
    </xsl:template>
877
    <!-- 
878
    
879
    template for sending an email to a contact author -->
880
    <xsl:template name="create_email_link">
881
        <xsl:param name="contactEmail" select="$contactEmail"/>
882
        <xsl:param name="creatorEmail" select="$creatorEmail"/>
883
        <xsl:choose>
884
            <xsl:when test="$contactEmail">
885
                <xsl:variable name="email4requests" select="$contactEmail"/>
886
                <a href="mailto:{$email4requests}?subject=Reprint Request, via SBC-LTER
887
                    pubsDB">email author</a>
888
            </xsl:when>
889
            <xsl:otherwise>
890
                <xsl:choose>
891
                    <xsl:when test="$creatorEmail">
892
                        <xsl:variable name="email4requests" select="$creatorEmail"/>
893
                        <a href="mailto:{$email4requests}?subject=Reprint Request, via
894
                            SBC-LTER pubs DB">email author</a>
895
                    </xsl:when>
896
                    <xsl:otherwise>
897
                        <xsl:text>contact author</xsl:text>
898
                    </xsl:otherwise>
899
                </xsl:choose>
900
            </xsl:otherwise>
901
        </xsl:choose>
902
    </xsl:template>
903
    <!--
904
    
905
    template for including a link to a dataset-->
906
    <xsl:template name="dataset_link">
907
        <xsl:if test="normalize-space(datasetID)">
908
            <!--create the url to datasets -->
909
            <!-- might have more than one. -->
910
            <xsl:for-each select="datasetID">
911
                <xsl:variable name="docid" select="."/>
912
                <a href="{$metacat_url}{$docid}">View Dataset</a>
913
                <br/>
914
            </xsl:for-each>
915
        </xsl:if>
916
    </xsl:template>
917
</xsl:stylesheet>
(13-13/14)