Project

General

Profile

1 5536 leinfelder
<?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 5542 leinfelder
	<xsl:param name="sessionid" />
39 5536 leinfelder
	<xsl:param name="qformat">semtools</xsl:param>
40
	<xsl:param name="enableediting">false</xsl:param>
41
	<xsl:param name="contextURL"/>
42 5542 leinfelder
	<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 5743 leinfelder
	<xsl:param name="labelWidth">120</xsl:param>
44 5769 leinfelder
	<xsl:param name="showEntity">false</xsl:param>
45 5542 leinfelder
46 5727 leinfelder
	<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 5540 leinfelder
50 5536 leinfelder
	<xsl:template name="annotation">
51 5590 leinfelder
		<xsl:param name="showAll">true</xsl:param>
52 5732 leinfelder
		<table align="center" width="100%" class="subGroup">
53 5591 leinfelder
			<tr>
54
				<td>
55 5728 leinfelder
					<!-- annotation summary -->
56 5738 leinfelder
					<xsl:call-template name="annotationSummary" />
57 5536 leinfelder
				</td>
58
			</tr>
59 5578 leinfelder
60 5740 leinfelder
			<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 5591 leinfelder
					<tr>
97 5740 leinfelder
						<td>
98
							<xsl:call-template name="modelSummary" />
99
						</td>
100
					</tr>
101
				</xsl:otherwise>
102
			</xsl:choose>
103 5578 leinfelder
104
			<tr class="searchresultsdivider">
105 5721 leinfelder
				<td></td>
106 5536 leinfelder
			</tr>
107 5721 leinfelder
		</table>
108 5590 leinfelder
109 5536 leinfelder
	</xsl:template>
110 5721 leinfelder
111 5738 leinfelder
	<xsl:template name="annotationSummary">
112 5733 leinfelder
		<table class="subGroup subGroup_border onehundred_percent">
113 5732 leinfelder
			<tr>
114 5733 leinfelder
				<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 5732 leinfelder
				<xsl:variable name="mapCount">
136
					<xsl:value-of select="count(./*[local-name()='map'])"/>
137
				</xsl:variable>
138 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
139 5739 leinfelder
					Data Table <xsl:value-of select="./@dataTable"/>:
140 5732 leinfelder
     			</td>
141
     			<td class="roweven">
142 5739 leinfelder
     				<xsl:for-each select="./*[local-name()='map']">
143
     					<xsl:value-of select="./@attribute"/>
144
     					<xsl:if test="position() != last()">, </xsl:if>
145
     				</xsl:for-each>
146
     				(<a>
147 5732 leinfelder
						<xsl:attribute name="href">
148
							<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"/>
149
						</xsl:attribute>
150 5739 leinfelder
	     				<xsl:value-of select="$mapCount"/>
151
	     				<xsl:text> attributes</xsl:text>
152
					</a>)
153 5732 leinfelder
     			</td>
154
     		</tr>
155
			<tr>
156 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
157 5739 leinfelder
     				Data Package:
158 5732 leinfelder
     			</td>
159
     			<td class="roweven">
160 5739 leinfelder
     				<xsl:value-of select="./@emlPackage"/>
161
     				(<a>
162 5732 leinfelder
						<xsl:attribute name="href">
163
							<xsl:value-of select="$tripleURI"/><xsl:value-of select="./@emlPackage"/>
164
						</xsl:attribute>
165 5739 leinfelder
						<xsl:text>View Metadata</xsl:text>
166
					</a>)
167 5732 leinfelder
168
					<!-- stats -->
169
					<span id="emlStats"></span>
170
					<script language="JavaScript">
171
						loadStats(
172
							'emlStats',
173
							'<xsl:value-of select="./@emlPackage" />',
174
							'<xsl:value-of select="$contextURL" />/metacat',
175
							'<xsl:value-of select="$qformat" />');
176
					</script>
177
178
				</td>
179
     		</tr>
180
     	</table>
181
	</xsl:template>
182
183 5728 leinfelder
	<xsl:template name="observation">
184 5733 leinfelder
		<table class="onehundred_percent">
185 5728 leinfelder
			<tr>
186 5732 leinfelder
				<th colspan="2">
187
					Observation (<xsl:value-of select="./@label"/>)
188
				</th>
189
			</tr>
190
			<tr>
191 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
192 5732 leinfelder
					Entity:
193 5728 leinfelder
				</td>
194
				<td class="roweven">
195
					<p>
196
						<xsl:attribute name="title">
197
							<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='entity']/@id, ':'), .)"/>
198
							<xsl:text>#</xsl:text>
199
							<xsl:value-of select="substring-after(./*[local-name()='entity']/@id, ':')"/>
200
						</xsl:attribute>
201
						<xsl:value-of select="substring-after(./*[local-name()='entity']/@id, ':')"/>
202
					</p>
203
				</td>
204
			</tr>
205
206
			<tr>
207 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
208 5728 leinfelder
					Ontology:
209
				</td>
210
				<td class="roweven">
211
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='entity']/@id, ':'), .)"/>
212
				</td>
213
			</tr>
214
215
		</table>
216
217
	</xsl:template>
218
219 5721 leinfelder
	<xsl:template name="measurement">
220
		<!-- measurement -->
221 5733 leinfelder
		<table class="subGroup subGroup_border onehundred_percent">
222 5728 leinfelder
			<tr>
223 5733 leinfelder
				<th colspan="2">
224 5728 leinfelder
					Measurement (<xsl:value-of select="./@label" />)
225
				</th>
226
			</tr>
227 5769 leinfelder
			<xsl:choose>
228
				<xsl:when test="$showEntity = 'true'">
229
					<tr>
230
						<td class="rowodd" width="{$labelWidth}">
231
							Entity:
232
						</td>
233
						<td class="roweven">
234
							<xsl:for-each select="../*[local-name()='entity']">
235
								<span>
236
									<xsl:attribute name="title">
237
										<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
238
										<xsl:text>#</xsl:text>
239
										<xsl:value-of select="substring-after(./@id, ':')"/>
240
									</xsl:attribute>
241
									<xsl:value-of select="substring-after(./@id, ':')"/>
242
								</span>
243
							</xsl:for-each>
244
						</td>
245
					</tr>
246
				</xsl:when>
247
				<xsl:otherwise>
248
					<tr>
249
						<td class="rowodd" width="{$labelWidth}">
250
							Column:
251
						</td>
252
						<td class="roweven">
253
							<xsl:variable name="columnkey">
254
								<xsl:value-of select="concat(../../@id, @label)" />
255
							</xsl:variable>
256
							<xsl:for-each select="key('mapping', $columnkey )">
257
								<xsl:value-of select="./@attribute" />
258
							</xsl:for-each>
259
						</td>
260
					</tr>
261
				</xsl:otherwise>
262
			</xsl:choose>
263
264
265 5728 leinfelder
			<tr>
266 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
267 5728 leinfelder
					Characteristic[s]:
268
				</td>
269
				<td class="roweven">
270
					<xsl:for-each select="./*[local-name()='characteristic']">
271 5722 leinfelder
						<span>
272 5721 leinfelder
							<xsl:attribute name="title">
273 5728 leinfelder
								<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
274 5721 leinfelder
								<xsl:text>#</xsl:text>
275 5728 leinfelder
								<xsl:value-of select="substring-after(./@id, ':')"/>
276
							</xsl:attribute>
277
							<xsl:value-of select="substring-after(./@id, ':')"/>
278
						</span>
279
					</xsl:for-each>
280
				</td>
281
			</tr>
282
			<tr>
283 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
284 5728 leinfelder
					Standard:
285
				</td>
286
				<td class="roweven">
287
					<span>
288
						<xsl:attribute name="title">
289
							<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='standard']/@id, ':'), .)"/>
290
							<xsl:text>#</xsl:text>
291
							<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
292
						</xsl:attribute>
293
						<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
294
					</span>
295
				</td>
296
			</tr>
297
			<tr>
298 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
299 5728 leinfelder
					Protocol:
300
				</td>
301
				<td class="roweven">
302
					<span>
303
						<xsl:attribute name="title">
304
							<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='protocol']/@id, ':'), .)"/>
305
							<xsl:text>#</xsl:text>
306 5721 leinfelder
							<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
307 5728 leinfelder
						</xsl:attribute>
308
						<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
309
					</span>
310
				</td>
311
			</tr>
312
		</table>
313 5721 leinfelder
314
	</xsl:template>
315
316 5740 leinfelder
	<xsl:template name="measurementSummary">
317
		<!-- entity -->
318 5766 leinfelder
		<td>
319
			<xsl:for-each select="../*[local-name()='entity']">
320
				<span>
321
					<xsl:attribute name="title">
322
						<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
323
						<xsl:text>#</xsl:text>
324
						<xsl:value-of select="substring-after(./@id, ':')"/>
325
					</xsl:attribute>
326
					<xsl:value-of select="substring-after(./@id, ':')"/>
327
				</span>
328
				(<xsl:value-of select="../@label"/>)
329
				<xsl:if test="position() != last()">, </xsl:if>
330
			</xsl:for-each>
331
		</td>
332
		<td>
333
			<!-- measurement -->
334
			<!--
335
			<xsl:value-of select="./@label" />
336
			-->
337
			<!-- characteristic -->
338
			<xsl:for-each select="./*[local-name()='characteristic']">
339
				<span>
340
					<xsl:attribute name="title">
341
						<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
342
						<xsl:text>#</xsl:text>
343
						<xsl:value-of select="substring-after(./@id, ':')"/>
344
					</xsl:attribute>
345
					<xsl:value-of select="substring-after(./@id, ':')"/>
346
				</span>
347
				<xsl:if test="position() != last()">, </xsl:if>
348
			</xsl:for-each>
349
		</td>
350
		<td>
351
			<!-- standard -->
352 5740 leinfelder
			<span>
353
				<xsl:attribute name="title">
354 5766 leinfelder
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='standard']/@id, ':'), .)"/>
355 5740 leinfelder
					<xsl:text>#</xsl:text>
356 5766 leinfelder
					<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
357
				</xsl:attribute>
358
				<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
359 5740 leinfelder
			</span>
360 5766 leinfelder
		</td>
361
		<td>
362
			<!-- protocol -->
363 5740 leinfelder
			<span>
364
				<xsl:attribute name="title">
365 5766 leinfelder
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='protocol']/@id, ':'), .)"/>
366 5740 leinfelder
					<xsl:text>#</xsl:text>
367 5766 leinfelder
					<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
368
				</xsl:attribute>
369
				<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
370 5740 leinfelder
			</span>
371 5766 leinfelder
		</td>
372 5740 leinfelder
	</xsl:template>
373
374
	<xsl:template name="modelSummary">
375 5743 leinfelder
		<table class="subGroup subGroup_border onehundred_percent">
376 5740 leinfelder
			<tr>
377 5766 leinfelder
				<th colspan="5">
378 5740 leinfelder
					Attribute Summary
379 5766 leinfelder
					(<a>
380
						<xsl:attribute name="href">
381
							<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"/>
382
						</xsl:attribute>
383
						<xsl:text>Data Table: </xsl:text>
384
						<xsl:value-of select="./@dataTable"/>
385
					</a>)
386 5740 leinfelder
				</th>
387
			</tr>
388
389 5766 leinfelder
390
			<tr>
391
				<td class="roweven" width="{$labelWidth}"></td>
392
     			<td class="rowodd">
393
     				Entity
394
     			</td>
395
     			<td class="rowodd">
396
     				Characteristic
397
     			</td>
398
     			<td class="rowodd">
399
     				Standard
400
     			</td>
401
     			<td class="rowodd">
402
     				Protocol
403
     			</td>
404
     		</tr>
405
406 5740 leinfelder
			<!-- reference to the annotation parent -->
407
			<xsl:variable name="thisAnnotationId">
408
				<xsl:value-of select="./@id"/>
409
			</xsl:variable>
410
411
			<xsl:for-each select="./*[local-name()='map']">
412
				<tr>
413
					<!-- look up the attribute -->
414
					<xsl:variable name="attributeLabel">
415
						<xsl:value-of select="./@attribute"/>
416
					</xsl:variable>
417
					<td class="rowodd">
418
						<xsl:value-of select="$attributeLabel"/>
419
					</td>
420 5766 leinfelder
421
					<!-- look up the attribute mapping for the given attribute -->
422
					<xsl:for-each select="key('attributes', concat($thisAnnotationId, $attributeLabel))">
423
						<!-- get the <measurement> node using this label -->
424
						<xsl:for-each select="key('measurements', concat($thisAnnotationId, ./@measurement))">
425
							<xsl:call-template name="measurementSummary"/>
426
						</xsl:for-each>
427
					</xsl:for-each>
428
429 5740 leinfelder
				</tr>
430
431
			</xsl:for-each>
432
433
		</table>
434
435
	</xsl:template>
436
437 5721 leinfelder
	<xsl:template name="attributeDetail">
438
		<xsl:param name="attributeLabel"/>
439
		<!-- look up the attribute mapping for the given label -->
440 5727 leinfelder
		<xsl:for-each select="key('attributes', concat(//*[local-name()='annotation']/@id, $attributeLabel))">
441 5721 leinfelder
			<!-- get the <measurement> node using this label -->
442 5726 leinfelder
			<table>
443 5721 leinfelder
				<tr>
444 5727 leinfelder
					<xsl:for-each select="key('measurements', concat(//*[local-name()='annotation']/@id, ./@measurement))">
445 5728 leinfelder
						<td>
446
							<xsl:call-template name="measurement"/>
447
						</td>
448 5721 leinfelder
					</xsl:for-each>
449
				</tr>
450
			</table>
451
		</xsl:for-each>
452
	</xsl:template>
453 5536 leinfelder
454
</xsl:stylesheet>