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 5951 leinfelder
	xmlns:sms="http://ecoinformatics.org/sms/annotation.1.0beta1"
34 5536 leinfelder
	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 5951 leinfelder
				<!-- 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 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
147 5952 leinfelder
					Data Object
148 5951 leinfelder
					(<xsl:value-of select="$mapCount"/>
149
		     		<xsl:text> attributes</xsl:text>):
150 5732 leinfelder
     			</td>
151
     			<td class="roweven">
152 5739 leinfelder
     				<xsl:for-each select="./*[local-name()='map']">
153 5951 leinfelder
     					<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 5739 leinfelder
     					<xsl:if test="position() != last()">, </xsl:if>
160
     				</xsl:for-each>
161 5951 leinfelder
162 5732 leinfelder
     			</td>
163
     		</tr>
164
			<tr>
165 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
166 5739 leinfelder
     				Data Package:
167 5732 leinfelder
     			</td>
168
     			<td class="roweven">
169 5951 leinfelder
     				<xsl:value-of select="./@dataPackage"/>
170 5739 leinfelder
     				(<a>
171 5732 leinfelder
						<xsl:attribute name="href">
172 5951 leinfelder
							<xsl:value-of select="$tripleURI"/><xsl:value-of select="./@dataPackage"/>
173 5732 leinfelder
						</xsl:attribute>
174 5739 leinfelder
						<xsl:text>View Metadata</xsl:text>
175
					</a>)
176 5732 leinfelder
177
					<!-- stats -->
178
					<span id="emlStats"></span>
179
					<script language="JavaScript">
180
						loadStats(
181
							'emlStats',
182 5951 leinfelder
							'<xsl:value-of select="./@dataPackage" />',
183 5732 leinfelder
							'<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 5728 leinfelder
	<xsl:template name="observation">
193 5733 leinfelder
		<table class="onehundred_percent">
194 5728 leinfelder
			<tr>
195 5732 leinfelder
				<th colspan="2">
196
					Observation (<xsl:value-of select="./@label"/>)
197
				</th>
198
			</tr>
199
			<tr>
200 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
201 5732 leinfelder
					Entity:
202 5728 leinfelder
				</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 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
217 5728 leinfelder
					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 5721 leinfelder
	<xsl:template name="measurement">
229
		<!-- measurement -->
230 5733 leinfelder
		<table class="subGroup subGroup_border onehundred_percent">
231 5728 leinfelder
			<tr>
232 5733 leinfelder
				<th colspan="2">
233 5728 leinfelder
					Measurement (<xsl:value-of select="./@label" />)
234
				</th>
235
			</tr>
236 5769 leinfelder
			<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 5728 leinfelder
			<tr>
275 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
276 5728 leinfelder
					Characteristic[s]:
277
				</td>
278
				<td class="roweven">
279
					<xsl:for-each select="./*[local-name()='characteristic']">
280 5722 leinfelder
						<span>
281 5721 leinfelder
							<xsl:attribute name="title">
282 5728 leinfelder
								<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
283 5721 leinfelder
								<xsl:text>#</xsl:text>
284 5728 leinfelder
								<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 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
293 5728 leinfelder
					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 5743 leinfelder
				<td class="rowodd" width="{$labelWidth}">
308 5728 leinfelder
					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 5721 leinfelder
							<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
316 5728 leinfelder
						</xsl:attribute>
317
						<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
318
					</span>
319
				</td>
320
			</tr>
321
		</table>
322 5721 leinfelder
323
	</xsl:template>
324
325 5740 leinfelder
	<xsl:template name="measurementSummary">
326
		<!-- entity -->
327 5766 leinfelder
		<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 5740 leinfelder
			<span>
362
				<xsl:attribute name="title">
363 5766 leinfelder
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='standard']/@id, ':'), .)"/>
364 5740 leinfelder
					<xsl:text>#</xsl:text>
365 5766 leinfelder
					<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 5740 leinfelder
			</span>
369 5766 leinfelder
		</td>
370
		<td>
371
			<!-- protocol -->
372 5740 leinfelder
			<span>
373
				<xsl:attribute name="title">
374 5766 leinfelder
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='protocol']/@id, ':'), .)"/>
375 5740 leinfelder
					<xsl:text>#</xsl:text>
376 5766 leinfelder
					<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 5740 leinfelder
			</span>
380 5766 leinfelder
		</td>
381 5740 leinfelder
	</xsl:template>
382
383
	<xsl:template name="modelSummary">
384 5743 leinfelder
		<table class="subGroup subGroup_border onehundred_percent">
385 5740 leinfelder
			<tr>
386 5766 leinfelder
				<th colspan="5">
387 5740 leinfelder
					Attribute Summary
388
				</th>
389
			</tr>
390
391 5766 leinfelder
			<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 5740 leinfelder
			<!-- reference to the annotation parent -->
408
			<xsl:variable name="thisAnnotationId">
409
				<xsl:value-of select="./@id"/>
410
			</xsl:variable>
411 5951 leinfelder
			<!-- reference to the dataPackage parent -->
412
			<xsl:variable name="thisDataPackage">
413
				<xsl:value-of select="./@dataPackage"/>
414
			</xsl:variable>
415 5740 leinfelder
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 5952 leinfelder
						<!-- the dataObject that contains the attribute -->
424
						<a>
425 5951 leinfelder
							<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 5952 leinfelder
							<xsl:value-of select="$attributeLabel"/>
429
							<xsl:text> (</xsl:text>
430 5951 leinfelder
							<xsl:value-of select="./@dataObject"/>
431 5952 leinfelder
							<xsl:text>)</xsl:text>
432
						</a>
433 5740 leinfelder
					</td>
434 5766 leinfelder
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 5740 leinfelder
				</tr>
444
445
			</xsl:for-each>
446
447
		</table>
448
449
	</xsl:template>
450
451 5721 leinfelder
	<xsl:template name="attributeDetail">
452
		<xsl:param name="attributeLabel"/>
453
		<!-- look up the attribute mapping for the given label -->
454 5727 leinfelder
		<xsl:for-each select="key('attributes', concat(//*[local-name()='annotation']/@id, $attributeLabel))">
455 5721 leinfelder
			<!-- get the <measurement> node using this label -->
456 5726 leinfelder
			<table>
457 5721 leinfelder
				<tr>
458 5727 leinfelder
					<xsl:for-each select="key('measurements', concat(//*[local-name()='annotation']/@id, ./@measurement))">
459 5728 leinfelder
						<td>
460
							<xsl:call-template name="measurement"/>
461
						</td>
462 5721 leinfelder
					</xsl:for-each>
463
				</tr>
464
			</table>
465
		</xsl:for-each>
466
	</xsl:template>
467 5536 leinfelder
468
</xsl:stylesheet>