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
		<xsl:for-each select="../*[local-name()='entity']">
293
			<span>
294
				<xsl:attribute name="title">
295
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
296
					<xsl:text>#</xsl:text>
297
					<xsl:value-of select="substring-after(./@id, ':')"/>
298
				</xsl:attribute>
299
				<xsl:value-of select="substring-after(./@id, ':')"/>
300
			</span>
301
			(<xsl:value-of select="../@label"/>)
302
			<xsl:if test="position() != last()">, </xsl:if>
303
		</xsl:for-each>
304
		<xsl:text> / </xsl:text>
305
		<!-- measurement -->
306
		<!-- 
307
		<xsl:value-of select="./@label" />
308
		-->
309
		<!-- characteristic -->
310
		<xsl:for-each select="./*[local-name()='characteristic']">
311
			<span>
312
				<xsl:attribute name="title">
313
					<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./@id, ':'), .)"/>
314
					<xsl:text>#</xsl:text>
315
					<xsl:value-of select="substring-after(./@id, ':')"/>
316
				</xsl:attribute>
317
				<xsl:value-of select="substring-after(./@id, ':')"/>
318
			</span>
319
			<xsl:if test="position() != last()">, </xsl:if>
320
		</xsl:for-each>
321
		<xsl:text> / </xsl:text>
322
		<!-- standard -->
323
		<span>
324
			<xsl:attribute name="title">
325
				<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='standard']/@id, ':'), .)"/>
326
				<xsl:text>#</xsl:text>
327
				<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>	
328
			</xsl:attribute>					
329
			<xsl:value-of select="substring-after(./*[local-name()='standard']/@id, ':')"/>
330
		</span>
331
		<xsl:text> / </xsl:text>							
332
		<!-- protocol -->
333
		<span>
334
			<xsl:attribute name="title">
335
				<xsl:value-of select="fn:namespace-uri-for-prefix(substring-before(./*[local-name()='protocol']/@id, ':'), .)"/>
336
				<xsl:text>#</xsl:text>
337
				<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
338
			</xsl:attribute>					
339
			<xsl:value-of select="substring-after(./*[local-name()='protocol']/@id, ':')"/>
340
		</span>
341
	</xsl:template>
342
	
343
	<xsl:template name="modelSummary">
344
		<table class="subGroup subGroup_border onehundred_percent">
345
			<tr>
346
				<th colspan="2">
347
					Attribute Summary
348
				</th>
349
			</tr>
350
			
351
			<!-- reference to the annotation parent -->
352
			<xsl:variable name="thisAnnotationId">
353
				<xsl:value-of select="./@id"/>
354
			</xsl:variable>
355
			
356
			<xsl:for-each select="./*[local-name()='map']">
357
				<tr>
358
					<!-- look up the attribute -->
359
					<xsl:variable name="attributeLabel">
360
						<xsl:value-of select="./@attribute"/>
361
					</xsl:variable>
362
					<td class="rowodd">
363
						<xsl:value-of select="$attributeLabel"/>
364
					</td>
365
					<td>
366
						<!-- look up the attribute mapping for the given attribute -->
367
						<xsl:for-each select="key('attributes', concat($thisAnnotationId, $attributeLabel))">
368
							<table>
369
								<tr>
370
									<!-- get the <measurement> node using this label -->
371
									<xsl:for-each select="key('measurements', concat($thisAnnotationId, ./@measurement))">
372
										<td>
373
											<xsl:call-template name="measurementSummary"/>
374
										</td>	
375
									</xsl:for-each>
376
								</tr>
377
							</table>		
378
						</xsl:for-each>
379
					</td>
380
				</tr>
381
					
382
			</xsl:for-each>
383
			
384
		</table>	
385
		
386
	</xsl:template>
387
	
388
	<xsl:template name="attributeDetail">
389
		<xsl:param name="attributeLabel"/>
390
		<!-- look up the attribute mapping for the given label -->
391
		<xsl:for-each select="key('attributes', concat(//*[local-name()='annotation']/@id, $attributeLabel))">
392
			<!-- get the <measurement> node using this label -->
393
			<table>
394
				<tr>
395
					<xsl:for-each select="key('measurements', concat(//*[local-name()='annotation']/@id, ./@measurement))">
396
						<td>
397
							<xsl:call-template name="measurement"/>
398
						</td>	
399
					</xsl:for-each>
400
				</tr>
401
			</table>		
402
		</xsl:for-each>
403
	</xsl:template>
404

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