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

    
428
</xsl:stylesheet>
(1-1/14)