Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
	*  '$RCSfile$'
4
	*      Authors: Matt Jones, CHad Berkley
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: leinfelder $'
10
	*     '$Date: 2010-08-30 23:34:14 +0000 (Mon, 30 Aug 2010) $'
11
	* '$Revision: 5533 $'
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 showing the resultset of a query
29
	* into an HTML format suitable for rendering with modern web browsers.
30
-->
31
<xsl:stylesheet 
32
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33
	xmlns:sms="http://ecoinformatics.org/sms/annotation.1.0beta1"
34
	xmlns:fn="http://www.w3.org/2005/xpath-functions"
35
	version="2.0">
36

    
37
	<xsl:output method="html" />
38
	<xsl:param name="sessionid" />
39
	<xsl:param name="qformat">semtools</xsl:param>
40
	<xsl:param name="enableediting">false</xsl:param>
41
	<xsl:param name="contextURL"/>
42
	<xsl:param name="tripleURI"><xsl:value-of select="$contextURL" /><![CDATA[/metacat?action=read&qformat=]]><xsl:value-of select="$qformat" /><![CDATA[&sessionid=]]><xsl:value-of select="$sessionid" /><![CDATA[&docid=]]></xsl:param>
43
	<xsl:param name="labelWidth">120</xsl:param>
44
	<xsl:param name="showEntity">false</xsl:param>
45
	
46
	<xsl:key name="mapping" match="//*[local-name()='map']" use="concat(../@id, @measurement)" />
47
	<xsl:key name="attributes" match="//*[local-name()='map']" use="concat(../@id, @attribute)" />
48
	<xsl:key name="measurements" match="//*[local-name()='measurement']" use="concat(../../@id, @label)" />
49
	
50
	<xsl:template name="annotation">
51
		<xsl:param name="showAll">true</xsl:param>
52
		<table align="center" width="100%" class="subGroup">
53
			<tr>
54
				<td>
55
					<!-- annotation summary -->
56
					<xsl:call-template name="annotationSummary" />
57
				</td>
58
			</tr>
59
			
60
			<xsl:choose>
61
			
62
				<xsl:when test="$showAll='true'">
63
				
64
					<!-- render the full observations and measurements -->
65
					<xsl:for-each select="./*[local-name()='observation']">
66
						<tr>
67
							<td>
68
								<table class="subGroup subGroup_border onehundred_percent">
69
									<tr valign="top">
70
										<td>
71
											<!-- observation entity -->
72
											<xsl:call-template name="observation" />
73
										</td>
74
									</tr>
75
									<tr>
76
										<td>
77
											<table class="onehundred_percent">
78
												<tr>
79
													<!-- measurement -->
80
													<xsl:for-each select="./*[local-name()='measurement']">
81
														<td>
82
															<xsl:call-template name="measurement" />
83
														</td>	
84
													</xsl:for-each> 
85
												</tr>
86
											</table>			
87
										</td>	
88
									</tr>
89
								</table>
90
							</td>		
91
						</tr>
92
					</xsl:for-each><!-- end observation -->
93
						
94
				</xsl:when><!--end show all-->	
95
				<xsl:otherwise>
96
					<tr>
97
						<td>
98
							<xsl:call-template name="modelSummary" />
99
						</td>
100
					</tr>		
101
				</xsl:otherwise>
102
			</xsl:choose>
103
			
104
			<tr class="searchresultsdivider">
105
				<td></td>
106
			</tr>
107
		</table>		
108
		
109
	</xsl:template>
110
	
111
	<xsl:template name="annotationSummary">
112
		<table class="subGroup subGroup_border onehundred_percent">
113
			<tr>
114
				<th colspan="2">
115
     				Annotation
116
     				<a>
117
						<xsl:attribute name="href">
118
							<xsl:value-of select="$tripleURI"/><xsl:value-of select="./@id"/>
119
						</xsl:attribute>
120
						(<xsl:value-of select="./@id"/>)
121
					</a>
122
										
123
					<!-- stats -->
124
					<span id="annotationStats"></span>
125
					<script language="JavaScript">
126
						loadStats(
127
							'annotationStats', 
128
							'<xsl:value-of select="./@id" />', 
129
							'<xsl:value-of select="$contextURL" />/metacat',
130
							'<xsl:value-of select="$qformat" />');
131
					</script>
132
				</th>	
133
			</tr>
134
			<tr>
135
				<xsl:variable name="mapCount">
136
					<xsl:value-of select="count(./*[local-name()='map'])"/>
137
				</xsl:variable>
138
				<!-- reference to the annotation parent -->
139
				<xsl:variable name="thisAnnotationId">
140
					<xsl:value-of select="./@id"/>
141
				</xsl:variable>
142
				<!-- reference to the dataPackage parent -->
143
				<xsl:variable name="thisDataPackage">
144
					<xsl:value-of select="./@dataPackage"/>
145
				</xsl:variable>
146
				<td class="rowodd" width="{$labelWidth}">
147
					Data Object  
148
					(<xsl:value-of select="$mapCount"/>
149
		     		<xsl:text> attributes</xsl:text>):
150
     			</td>
151
     			<td class="roweven">
152
     				<xsl:for-each select="./*[local-name()='map']">
153
     					<a>
154
							<xsl:attribute name="href">
155
								<xsl:value-of select="$tripleURI"/><xsl:value-of select="$thisDataPackage"/>&amp;displaymodule=entity&amp;entitytype=dataTable&amp;entityindex=<xsl:value-of select="number(./@dataObject)+1"/>&amp;annotationId=<xsl:value-of select="$thisAnnotationId"/>
156
							</xsl:attribute>
157
     						<xsl:value-of select="./@attribute"/>
158
						</a>
159
     					<xsl:if test="position() != last()">, </xsl:if>
160
     				</xsl:for-each>
161
     				
162
     			</td>
163
     		</tr>
164
			<tr>
165
				<td class="rowodd" width="{$labelWidth}">
166
     				Data Package:
167
     			</td>
168
     			<td class="roweven">
169
     				<xsl:value-of select="./@dataPackage"/>
170
     				(<a>
171
						<xsl:attribute name="href">
172
							<xsl:value-of select="$tripleURI"/><xsl:value-of select="./@dataPackage"/>
173
						</xsl:attribute>
174
						<xsl:text>View Metadata</xsl:text>
175
					</a>)
176
											
177
					<!-- stats -->
178
					<span id="emlStats"></span>
179
					<script language="JavaScript">
180
						loadStats(
181
							'emlStats', 
182
							'<xsl:value-of select="./@dataPackage" />', 
183
							'<xsl:value-of select="$contextURL" />/metacat',
184
							'<xsl:value-of select="$qformat" />');
185
					</script>
186
						
187
				</td>
188
     		</tr>
189
     	</table>
190
	</xsl:template>
191
	
192
	<xsl:template name="observation">
193
		<table class="onehundred_percent">
194
			<tr>
195
				<th colspan="2">
196
					Observation (<xsl:value-of select="./@label"/>)
197
				</th>
198
			</tr>
199
			<tr>
200
				<td class="rowodd" width="{$labelWidth}">
201
					Entity:
202
				</td>
203
				<td class="roweven">
204
					<p>
205
						<xsl:attribute name="title">
206
							<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='entity']/@id, ':'), .)"/>
207
							<xsl:text>#</xsl:text>
208
							<xsl:value-of select="substring-after(./*[local-name()='entity']/@id, ':')"/>
209
						</xsl:attribute> 
210
						<xsl:value-of select="substring-after(./*[local-name()='entity']/@id, ':')"/>
211
					</p>	
212
				</td>
213
			</tr>
214
			
215
			<tr>		
216
				<td class="rowodd" width="{$labelWidth}">
217
					Ontology:
218
				</td>
219
				<td class="roweven">	 
220
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='entity']/@id, ':'), .)"/>
221
				</td>
222
			</tr>
223
			
224
		</table>
225
	
226
	</xsl:template>
227
	
228
	<xsl:template name="measurement">
229
		<!-- measurement -->
230
		<table class="subGroup subGroup_border onehundred_percent">
231
			<tr>
232
				<th colspan="2"> 	
233
					Measurement (<xsl:value-of select="./@label" />)
234
				</th>
235
			</tr>
236
			<xsl:choose>
237
				<xsl:when test="$showEntity = 'true'">
238
					<tr>
239
						<td class="rowodd" width="{$labelWidth}">					
240
							Entity:
241
						</td>
242
						<td class="roweven">
243
							<xsl:for-each select="../*[local-name()='entity']">
244
								<span>
245
									<xsl:attribute name="title">
246
										<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
247
										<xsl:text>#</xsl:text>
248
										<xsl:value-of select="substring-after(./@id, ':')"/>
249
									</xsl:attribute>
250
									<xsl:value-of select="substring-after(./@id, ':')"/>
251
								</span>	
252
							</xsl:for-each>
253
						</td>
254
					</tr>
255
				</xsl:when>
256
				<xsl:otherwise>
257
					<tr>
258
						<td class="rowodd" width="{$labelWidth}">					
259
							Column:
260
						</td>
261
						<td class="roweven">
262
							<xsl:variable name="columnkey">
263
								<xsl:value-of select="concat(../../@id, @label)" />
264
							</xsl:variable>
265
							<xsl:for-each select="key('mapping', $columnkey )">
266
								<xsl:value-of select="./@attribute" />
267
							</xsl:for-each>
268
						</td>
269
					</tr>
270
				</xsl:otherwise>
271
			</xsl:choose>
272
			
273
			
274
			<tr>
275
				<td class="rowodd" width="{$labelWidth}">					
276
					Characteristic[s]:
277
				</td>
278
				<td class="roweven">
279
					<xsl:for-each select="./*[local-name()='characteristic']">
280
						<span>
281
							<xsl:attribute name="title">
282
								<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
283
								<xsl:text>#</xsl:text>
284
								<xsl:value-of select="substring-after(./@id, ':')"/>
285
							</xsl:attribute>
286
							<xsl:value-of select="substring-after(./@id, ':')"/>
287
						</span>	
288
					</xsl:for-each>
289
				</td>
290
			</tr>
291
			<tr>
292
				<td class="rowodd" width="{$labelWidth}">					
293
					Standard:
294
				</td>
295
				<td class="roweven">
296
					<span>
297
						<xsl:attribute name="title">
298
							<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='standard']/@id, ':'), .)"/>
299
							<xsl:text>#</xsl:text>
300
							<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>	
301
						</xsl:attribute>					
302
						<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
303
					</span>							
304
				</td>
305
			</tr>
306
			<tr>
307
				<td class="rowodd" width="{$labelWidth}">					
308
					Protocol:
309
				</td>
310
				<td class="roweven">
311
					<span>
312
						<xsl:attribute name="title">
313
							<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='protocol']/@id, ':'), .)"/>
314
							<xsl:text>#</xsl:text>
315
							<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
316
						</xsl:attribute>					
317
						<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
318
					</span>
319
				</td>
320
			</tr>
321
		</table>
322
		
323
	</xsl:template>
324
	
325
	<xsl:template name="measurementSummary">
326
		<!-- entity -->
327
		<td>
328
			<xsl:for-each select="../*[local-name()='entity']">
329
				<span>
330
					<xsl:attribute name="title">
331
						<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
332
						<xsl:text>#</xsl:text>
333
						<xsl:value-of select="substring-after(./@id, ':')"/>
334
					</xsl:attribute>
335
					<xsl:value-of select="substring-after(./@id, ':')"/>
336
				</span>
337
				(<xsl:value-of select="../@label"/>)
338
				<xsl:if test="position() != last()">, </xsl:if>
339
			</xsl:for-each>
340
		</td>
341
		<td>
342
			<!-- measurement -->
343
			<!-- 
344
			<xsl:value-of select="./@label" />
345
			-->
346
			<!-- characteristic -->
347
			<xsl:for-each select="./*[local-name()='characteristic']">
348
				<span>
349
					<xsl:attribute name="title">
350
						<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
351
						<xsl:text>#</xsl:text>
352
						<xsl:value-of select="substring-after(./@id, ':')"/>
353
					</xsl:attribute>
354
					<xsl:value-of select="substring-after(./@id, ':')"/>
355
				</span>
356
				<xsl:if test="position() != last()">, </xsl:if>
357
			</xsl:for-each>
358
		</td>
359
		<td>
360
			<!-- standard -->
361
			<span>
362
				<xsl:attribute name="title">
363
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='standard']/@id, ':'), .)"/>
364
					<xsl:text>#</xsl:text>
365
					<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>	
366
				</xsl:attribute>					
367
				<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
368
			</span>
369
		</td>
370
		<td>							
371
			<!-- protocol -->
372
			<span>
373
				<xsl:attribute name="title">
374
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='protocol']/@id, ':'), .)"/>
375
					<xsl:text>#</xsl:text>
376
					<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
377
				</xsl:attribute>					
378
				<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
379
			</span>
380
		</td>	
381
	</xsl:template>
382
	
383
	<xsl:template name="modelSummary">
384
		<table class="subGroup subGroup_border onehundred_percent">
385
			<tr>
386
				<th colspan="5">
387
					Attribute Summary
388
				</th>
389
			</tr>
390
			
391
			<tr>
392
				<td class="roweven" width="{$labelWidth}"></td>
393
     			<td class="rowodd">
394
     				Entity
395
     			</td>
396
     			<td class="rowodd">
397
     				Characteristic
398
     			</td>
399
     			<td class="rowodd">
400
     				Standard
401
     			</td>
402
     			<td class="rowodd">
403
     				Protocol
404
     			</td>
405
     		</tr>
406
			
407
			<!-- reference to the annotation parent -->
408
			<xsl:variable name="thisAnnotationId">
409
				<xsl:value-of select="./@id"/>
410
			</xsl:variable>
411
			<!-- reference to the dataPackage parent -->
412
			<xsl:variable name="thisDataPackage">
413
				<xsl:value-of select="./@dataPackage"/>
414
			</xsl:variable>
415
			
416
			<xsl:for-each select="./*[local-name()='map']">
417
				<tr>
418
					<!-- look up the attribute -->
419
					<xsl:variable name="attributeLabel">
420
						<xsl:value-of select="./@attribute"/>
421
					</xsl:variable>
422
					<td class="rowodd">
423
						<!-- the dataObject that contains the attribute -->
424
						<a>
425
							<xsl:attribute name="href">
426
								<xsl:value-of select="$tripleURI"/><xsl:value-of select="$thisDataPackage"/>&amp;displaymodule=entity&amp;entitytype=dataTable&amp;entityindex=<xsl:value-of select="number(./@dataObject)+1"/>&amp;annotationId=<xsl:value-of select="$thisAnnotationId"/>
427
							</xsl:attribute>
428
							<xsl:value-of select="$attributeLabel"/>
429
							<xsl:text> (</xsl:text>
430
							<xsl:value-of select="./@dataObject"/>
431
							<xsl:text>)</xsl:text>
432
						</a>
433
					</td>
434
					
435
					<!-- look up the attribute mapping for the given attribute -->
436
					<xsl:for-each select="key('attributes', concat($thisAnnotationId, $attributeLabel))">
437
						<!-- get the <measurement> node using this label -->
438
						<xsl:for-each select="key('measurements', concat($thisAnnotationId, ./@measurement))">
439
							<xsl:call-template name="measurementSummary"/>
440
						</xsl:for-each>		
441
					</xsl:for-each>
442
					
443
				</tr>
444
					
445
			</xsl:for-each>
446
			
447
		</table>	
448
		
449
	</xsl:template>
450
	
451
	<xsl:template name="attributeDetail">
452
		<xsl:param name="attributeLabel"/>
453
		<!-- look up the attribute mapping for the given label -->
454
		<xsl:for-each select="key('attributes', concat(//*[local-name()='annotation']/@id, $attributeLabel))">
455
			<!-- get the <measurement> node using this label -->
456
			<table>
457
				<tr>
458
					<xsl:for-each select="key('measurements', concat(//*[local-name()='annotation']/@id, ./@measurement))">
459
						<td>
460
							<xsl:call-template name="measurement"/>
461
						</td>	
462
					</xsl:for-each>
463
				</tr>
464
			</table>		
465
		</xsl:for-each>
466
	</xsl:template>
467

    
468
</xsl:stylesheet>
(1-1/16)