Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile$'
4
  *      Authors: Matthew Brooke
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *
9
  *   '$Author: mecum $'
10
  *     '$Date: 2017-10-20 15:30:24 -0700 (Fri, 20 Oct 2017) $'
11
  * '$Revision: 10432 $'
12
  *
13
  * This program is free software; you can redistribute it and/or modify
14
  * it under the terms of the GNU General Public License as published by
15
  * the Free Software Foundation; either version 2 of the License, or
16
  * (at your option) any later version.
17
  *
18
  * This program is distributed in the hope that it will be useful,
19
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
  * GNU General Public License for more details.
22
  *
23
  * You should have received a copy of the GNU General Public License
24
  * along with this program; if not, write to the Free Software
25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
  *
27
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
28
  * convert an XML file that is valid with respect to the eml-variable.dtd
29
  * module of the Ecological Metadata Language (EML) into an HTML format
30
  * suitable for rendering with modern web browsers.
31
-->
32
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33

    
34
  <xsl:output method="html" encoding="UTF-8"
35
              doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
36
              doctype-system="http://www.w3.org/TR/html4/loose.dtd"
37
              indent="yes" />  
38

    
39
  <!-- This module is for party member and it is self contained-->
40

    
41
  <xsl:template name="party">
42
      <xsl:param name="partyfirstColStyle"/>
43
      <div class="row-fluid">
44
        <xsl:choose>
45
         <xsl:when test="references!=''">
46
          <xsl:variable name="ref_id" select="references"/>
47
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
48
          <xsl:for-each select="$references">
49
            <xsl:apply-templates mode="party">
50
             <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
51
            </xsl:apply-templates>
52
          </xsl:for-each>
53
        </xsl:when>
54
        <xsl:otherwise>
55
          <xsl:apply-templates mode="party">
56
            <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
57
          </xsl:apply-templates>
58
        </xsl:otherwise>
59
      </xsl:choose>
60
      </div>
61
  </xsl:template>
62

    
63
  <!-- *********************************************************************** -->
64

    
65

    
66
  <xsl:template match="individualName" mode="party">
67
      <xsl:param name="partyfirstColStyle"/>
68
      <xsl:if test="normalize-space(.)!=''">
69
        <div class="control-group">
70
        	<label class="control-label">Individual</label>
71
        	<div class="controls" >
72
	           <b><xsl:value-of select="./salutation"/><xsl:text> </xsl:text>
73
	           <xsl:value-of select="./givenName"/><xsl:text> </xsl:text>
74
	           <xsl:value-of select="./surName"/></b>
75
        	</div>
76
        </div>	
77
      </xsl:if>
78
  </xsl:template>
79

    
80

    
81
  <xsl:template match="organizationName" mode="party">
82
      <xsl:param name="partyfirstColStyle"/>
83
      <xsl:if test="normalize-space(.)!=''">
84
        <div class="control-group">
85
        	<label class="control-label">Organization</label>
86
        	<div class="controls">
87
        		<b><xsl:value-of select="."/></b>
88
        	</div>
89
        </div>
90
      </xsl:if>
91
  </xsl:template>
92
  
93
  <xsl:template match="role" mode="party">
94
      <xsl:param name="partyfirstColStyle"/>
95
      <xsl:if test="normalize-space(.)!=''">
96
        <div class="control-group">
97
        	<label class="control-label">Role</label>
98
        	<div class="controls" >
99
        		
100
        		<xsl:variable name="role" select="." />
101
        		
102
        		<xsl:choose>
103
			        <xsl:when test="$role='principalInvestigator'">
104
			           <xsl:text>Principal Investigator</xsl:text>
105
			        </xsl:when>
106
			         <xsl:when test="$role='collaboratingPrincipalInvestigator'">
107
			           <xsl:text>Collaborating Principal Investigator</xsl:text>
108
			        </xsl:when>
109
			        <xsl:when test="$role='custodianSteward'">
110
			           <xsl:text>Custodian / Steward</xsl:text>
111
			        </xsl:when>
112
			        <xsl:when test="$role='coPrincipalInvestigator'">
113
			           <xsl:text>Co-Principal Investigator</xsl:text>
114
			        </xsl:when>
115
			        <xsl:otherwise>
116
			         	<xsl:value-of select="concat(
117
							  translate(
118
							    substring($role, 1, 1),
119
							    'abcdefghijklmnopqrstuvwxyz',
120
							    'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
121
							  ),
122
							  substring($role,2,string-length($role)-1)
123
							)"/>
124
			        </xsl:otherwise>
125
			     </xsl:choose>
126
        		
127
        	</div>
128
        </div>	
129
      </xsl:if>
130
  </xsl:template>
131

    
132

    
133
  <xsl:template match="positionName" mode="party">
134
      <xsl:param name="partyfirstColStyle"/>
135
      <xsl:if test="normalize-space(.)!=''">
136
      <div class="control-group">
137
        	<label class="control-label">Position</label>
138
        	<div class="controls">
139
        		<xsl:value-of select="."/>
140
        	</div>
141
       </div>
142
      </xsl:if>
143
  </xsl:template>
144

    
145

    
146
  <xsl:template match="address" mode="party">
147
    <xsl:param name="partyfirstColStyle"/>
148
    <xsl:if test="normalize-space(.)!=''">
149
      <xsl:call-template name="addressCommon">
150
         <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
151
      </xsl:call-template>
152
    </xsl:if>
153
    </xsl:template>
154

    
155
   <!-- This template will be call by other place-->
156
   <xsl:template name="address">
157
      <xsl:param name="partyfirstColStyle"/>
158
        <xsl:choose>
159
         <xsl:when test="references!=''">
160
          <xsl:variable name="ref_id" select="references"/>
161
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
162
          <xsl:for-each select="$references">
163
            <xsl:call-template name="addressCommon">
164
             <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
165
            </xsl:call-template>
166
          </xsl:for-each>
167
        </xsl:when>
168
        <xsl:otherwise>
169
          <xsl:call-template name="addressCommon">
170
             <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
171
          </xsl:call-template>
172
        </xsl:otherwise>
173
      </xsl:choose>
174
  </xsl:template>
175

    
176
   <xsl:template name="addressCommon">
177
    <xsl:param name="partyfirstColStyle"/>
178
    <xsl:if test="normalize-space(.)!=''">
179
    <div class="control-group">
180
    	<label class="control-label">Address</label>
181
    	<div class="controls">
182
    		<address>
183
			    <xsl:for-each select="deliveryPoint">
184
			    	<xsl:value-of select="."/><xsl:text>, </xsl:text>
185
			    </xsl:for-each>
186
			    <br/>
187
			    <!-- only include comma if city exists... -->
188
			    <xsl:if test="normalize-space(city)!=''">
189
			        <xsl:value-of select="city"/><xsl:text>, </xsl:text>
190
			    </xsl:if>
191
			    <xsl:if test="normalize-space(administrativeArea)!='' or normalize-space(postalCode)!=''">
192
			        <xsl:value-of select="administrativeArea"/><xsl:text> </xsl:text><xsl:value-of select="postalCode"/><xsl:text> </xsl:text>
193
			    </xsl:if>
194
			    <xsl:if test="normalize-space(country)!=''">
195
			      <xsl:value-of select="country"/>
196
			    </xsl:if>
197
    		</address>
198
		</div> 
199
	</div>
200
    </xsl:if>
201
   </xsl:template>
202

    
203
  <xsl:template match="phone" mode="party">
204
      <xsl:param name="partyfirstColStyle"/>
205
      <div class="control-group">
206
      	<label class="control-label">Phone</label>
207
          <div class="controls">
208
             <xsl:value-of select="."/>
209
             <xsl:if test="normalize-space(./@phonetype)!=''">
210
               <xsl:text> (</xsl:text><xsl:value-of select="./@phonetype"/><xsl:text>)</xsl:text>
211
             </xsl:if>
212
          </div>
213
      </div>
214
  </xsl:template>
215

    
216

    
217
  <xsl:template match="electronicMailAddress" mode="party">
218
      <xsl:param name="partyfirstColStyle"/>
219
      <xsl:if test="normalize-space(.)!=''">
220
       <div class="control-group">
221
       	<label class="control-label" >
222
            Email Address
223
          </label>
224
          <div class="controls">
225
            <a><xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute>
226
                    <xsl:value-of select="."/></a>
227
          </div>
228
       </div>
229

    
230
      </xsl:if>
231
  </xsl:template>
232

    
233

    
234
  <xsl:template match="onlineUrl" mode="party">
235
      <xsl:param name="partyfirstColStyle"/>
236
      <xsl:if test="normalize-space(.)!=''">
237
      <div class="control-group">
238
      	<label class="control-label">Web Address</label>
239
        <div class="controls">
240
            <a><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
241
            <xsl:value-of select="."/></a>
242
       	</div>
243
      </div>
244
    </xsl:if>
245
  </xsl:template>
246

    
247

    
248
    
249
    <xsl:template match="userId" mode="party">
250
        <xsl:param name="partyfirstColStyle"/>
251
        <xsl:if test="normalize-space(.)!=''">
252
            <div class="control-group">
253
                <label class="control-label">Id</label>
254
                <div class="controls">
255
                    <!-- Display the userId as a link when it appears to be an
256
                    ORCID. The display of ORCID information is subject to
257
                    ORCID's guidelines:
258

    
259
                        https://orcid.org/trademark-and-id-display-guidelines
260

    
261
                    We want to display the content as a hyperlinked ORCID when
262
                    we're reasonably sure the value of the userId element is an
263
                    ORCID and otherwise just display the non-hyperlinked value
264
                    of the element.
265

    
266
                    An example serialization of an ORCID in EML is
267

    
268
                        <userId directory="http://orcid.org">
269
                            http://orcid.org/0000-0003-1315-3818
270
                        </userId>
271
                    -->
272

    
273
                    <!-- Set up space-normalized variables for later use. -->
274
                    <xsl:variable name="directory" select="normalize-space(./@directory)" />
275
                    <xsl:variable name="value" select="normalize-space(.)" />
276
                    
277
                    <xsl:choose>
278
                        <xsl:when test="starts-with($directory, 'http://orcid.org') or starts-with($directory, 'https://orcid.org') or ($directory = '' and (starts-with($value, 'http://orcid.org') or starts-with(@value, 'https://orcid.org')))">
279
                            <!-- ORCID Logo -->
280
                            <a href="https://orcid.org">
281
                                <img src="img/orcid_64x64.png" style="display: inline; margin-right: 5px;" width="16" height="16" />
282
                            </a>
283
                            <!-- ORCID Link-->
284
                            <xsl:element name="a">
285
                                <xsl:choose>
286
                                    <xsl:when test="starts-with($value, 'http://orcid.org') or starts-with($value, 'https://orcid.org')">
287
                                        <xsl:attribute name="href">
288
                                            <xsl:value-of select="$value"/>
289
                                        </xsl:attribute>
290
                                        <xsl:attribute name="target">_blank</xsl:attribute>
291
                                    </xsl:when>
292
                                    <xsl:otherwise>
293
                                        <xsl:attribute name="href">
294
                                            <xsl:value-of select="concat('http://orcid.org/', $value)" />
295
                                        </xsl:attribute>
296
                                        <xsl:attribute name="target">_blank</xsl:attribute>
297
                                    </xsl:otherwise>
298
                                </xsl:choose>
299
                                <xsl:value-of select="$value"/>
300
                            </xsl:element>
301
                        </xsl:when>
302
                        <xsl:otherwise>                            
303
                            <xsl:value-of select="."/>
304
                        </xsl:otherwise>
305
                    </xsl:choose>
306
                </div>
307
            </div>
308
        </xsl:if>
309
    </xsl:template>
310
    <xsl:template match="text()" mode="party" />
311
</xsl:stylesheet>
(15-15/27)