Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile$'
4
  *      Authors: Matthew Brooke
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: 2013-07-16 13:17:24 -0700 (Tue, 16 Jul 2013) $'
11
  * '$Revision: 8005 $'
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 that is valid with respect to the eml-variable.dtd
29
  * module of the Ecological Metadata Language (EML) into an HTML format
30
  * suitable for rendering with modern web browsers.
31
-->
32
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33
  <xsl:import href="eml-text.xsl" />
34
  <xsl:output method="html" encoding="UTF-8"
35
              doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
36
              doctype-system="http://www.w3.org/TR/html4/loose.dtd"
37
              indent="yes" />  
38

    
39

    
40
<!-- This module is for distribution and it is self-contained-->
41

    
42
  <xsl:template name="distribution">
43
      <xsl:param name="disfirstColStyle"/>
44
      <xsl:param name="dissubHeaderStyle"/>
45
      <xsl:param name="docid"/>
46
      <xsl:param name="level">entitylevel</xsl:param>
47
      <xsl:param name="entitytype"/>
48
      <xsl:param name="entityindex"/>
49
      <xsl:param name="physicalindex"/>
50
      <xsl:param name="distributionindex"/>
51
      
52
      
53
       <xsl:choose>
54
         <xsl:when test="references!=''">
55
          <xsl:variable name="ref_id" select="references"/>
56
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
57
          <xsl:for-each select="$references">
58
            <xsl:apply-templates select="online">
59
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
60
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
61
            </xsl:apply-templates>
62
            <xsl:apply-templates select="offline">
63
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
64
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
65
            </xsl:apply-templates>
66
            <xsl:apply-templates select="inline">
67
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
68
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
69
               <xsl:with-param name="docid" select="$docid"/>
70
               <xsl:with-param name="level" select="$level"/>
71
               <xsl:with-param name="entitytype" select="$entitytype"/>
72
               <xsl:with-param name="entityindex" select="$entityindex"/>
73
               <xsl:with-param name="physicalindex" select="$physicalindex"/>
74
               <xsl:with-param name="distributionindex" select="$distributionindex"/>
75
             </xsl:apply-templates>
76
          </xsl:for-each>
77
        </xsl:when>
78
        <xsl:otherwise>
79
            <xsl:apply-templates select="online">
80
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
81
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
82
            </xsl:apply-templates>
83
            <xsl:apply-templates select="offline">
84
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
85
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
86
            </xsl:apply-templates>
87
            <xsl:apply-templates select="inline">
88
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
89
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
90
               <xsl:with-param name="docid" select="$docid"/>
91
               <xsl:with-param name="level" select="$level"/>
92
               <xsl:with-param name="entitytype" select="$entitytype"/>
93
               <xsl:with-param name="entityindex" select="$entityindex"/>
94
               <xsl:with-param name="physicalindex" select="$physicalindex"/>
95
               <xsl:with-param name="distributionindex" select="$distributionindex"/>
96
            </xsl:apply-templates>
97
        </xsl:otherwise>
98
       </xsl:choose>
99
       
100
  </xsl:template>
101

    
102
  <!-- ********************************************************************* -->
103
  <!-- *******************************  Online data  *********************** -->
104
  <!-- ********************************************************************* -->
105
  <xsl:template match="online">
106
    <xsl:param name="disfirstColStyle"/>
107
    <xsl:param name="dissubHeaderStyle"/>
108
    <div class="control-group">
109
		<label class="control-label">Online Distribution Info</label>
110
		<div class="controls controls-well">
111
			<xsl:apply-templates select="url">
112
		      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
113
		    </xsl:apply-templates>
114
		    <xsl:apply-templates select="connection">
115
		      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
116
		    </xsl:apply-templates>
117
		    <xsl:apply-templates select="connectionDefinition">
118
		      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
119
		    </xsl:apply-templates>
120
		</div>
121
	</div>	
122
    
123
  </xsl:template>
124

    
125
  <xsl:template match="url">
126
    <xsl:param name="disfirstColStyle"/>
127
    <xsl:variable name="URL" select="."/>
128
    
129
         <a>
130
           <xsl:choose>
131
           <xsl:when test="starts-with($URL,'ecogrid')">
132
			<xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
133
			<xsl:variable name="docID" select="substring-after($URL1, '/')"/>
134
			<xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docID"/></xsl:attribute>
135
           </xsl:when>
136
           <xsl:otherwise>
137
			<xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
138
           </xsl:otherwise>
139
          </xsl:choose>
140
          <xsl:attribute name="target">_blank</xsl:attribute>
141
          <xsl:value-of select="."/>
142
        </a>
143
        <xsl:if test="$withHTMLLinks = '1'">
144
	        <!-- stats for hosted documents loaded with ajax call -->
145
	        <xsl:if test="starts-with($URL,'ecogrid')">
146
				<xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
147
				<xsl:variable name="docID" select="substring-after($URL1, '/')"/>
148
				<xsl:variable name="divID">dataStats</xsl:variable>
149
				<span>
150
	          		<xsl:attribute name="id">
151
	          			<xsl:value-of select="$divID" />
152
	          		</xsl:attribute>
153
				</span>
154
				<script language="JavaScript">
155
					if (window.loadStats) {
156
						loadStats(
157
							'<xsl:value-of select="$divID" />', 
158
							'<xsl:value-of select="$docID" />', 
159
							'<xsl:value-of select="$contextURL" />/metacat', 
160
							'<xsl:value-of select="$qformat" />');
161
					}
162
				</script>
163
			</xsl:if>
164
		</xsl:if>		
165
      
166
  </xsl:template>
167

    
168
  <xsl:template match="connection">
169
    <xsl:param name="disfirstColStyle"/>
170
    <xsl:choose>
171
      <xsl:when test="references!=''">
172
        <xsl:variable name="ref_id" select="references"/>
173
        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
174
        <xsl:for-each select="$references">
175
          <xsl:call-template name="connectionCommon">
176
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
177
          </xsl:call-template>
178
        </xsl:for-each>
179
      </xsl:when>
180
      <xsl:otherwise>
181
        <xsl:call-template name="connectionCommon">
182
          <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
183
        </xsl:call-template>
184
      </xsl:otherwise>
185
    </xsl:choose>
186
  </xsl:template>
187

    
188
  <!-- A template shared by connection references and connection in line-->
189
  <xsl:template name="connectionCommon">
190
    <xsl:param name="disfirstColStyle"/>
191
    <xsl:if test="parameter">
192
      <div class="control-group">
193
		<label class="control-label">Parameter(s)</label>
194
		<div class="controls">
195
	      <xsl:call-template name="renderParameters">
196
	        <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
197
	      </xsl:call-template>
198
		</div>
199
	</div>
200
    </xsl:if>
201
    
202
    <xsl:apply-templates select="connectionDefinition">
203
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
204
    </xsl:apply-templates>
205
    
206
  </xsl:template>
207

    
208
  <xsl:template name="renderParameters">
209
    <xsl:param name="disfirstColStyle"/>
210
    <table class="table table-striped">
211
      <xsl:for-each select="parameter" >
212
      <tr>
213
        <td class="{$disfirstColStyle}">
214
          <xsl:value-of select="name" />
215
        </td>
216
        <td class="{$secondColStyle}">
217
         <xsl:value-of select="value" />
218
        </td>
219
      </tr>
220
    </xsl:for-each>
221
    </table>
222
  </xsl:template>
223

    
224
   <xsl:template match="connectionDefinition">
225
    <xsl:param name="disfirstColStyle"/>
226
    <xsl:choose>
227
      <xsl:when test="references!=''">
228
        <xsl:variable name="ref_id" select="references"/>
229
        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
230
        <xsl:for-each select="$references">
231
          <xsl:call-template name="connectionDefinitionCommon">
232
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
233
          </xsl:call-template>
234
        </xsl:for-each>
235
      </xsl:when>
236
      <xsl:otherwise>
237
        <xsl:call-template name="connectionDefinitionCommon">
238
          <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
239
        </xsl:call-template>
240
      </xsl:otherwise>
241
    </xsl:choose>
242
   </xsl:template>
243

    
244
   <!-- This template will be shared by both reference and inline connectionDefinition-->
245
   <xsl:template name="connectionDefinitionCommon">
246
    <xsl:param name="disfirstColStyle"/>
247
      <div class="control-group">
248
		<label class="control-label">Schema Name</label>
249
        <div class="controls">
250
            <xsl:value-of select="schemeName" />
251
		</div>
252
       </div>
253
       <div class="control-group">
254
		<label class="control-label">Description</label>
255
          <div class="controls">
256
           <xsl:apply-templates select="description">
257
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
258
            </xsl:apply-templates>
259
          </div>
260
       </div>
261
       
262
       <table class="table table-striped">
263
	       <xsl:for-each select="parameterDefinition">
264
	          <xsl:call-template name="renderParameterDefinition">
265
	            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
266
	          </xsl:call-template>
267
	       </xsl:for-each>
268
       </table>
269
       
270
   </xsl:template>
271

    
272
   <xsl:template match="description">
273
     <xsl:param name="disfirstColStyle"/>
274
     <xsl:call-template name="text">
275
        <xsl:with-param name="textfirstColStyle" select="$secondColStyle" />
276
     </xsl:call-template>
277
   </xsl:template>
278

    
279
   <xsl:template name="renderParameterDefinition">
280
     <xsl:param name="disfirstColStyle"/>
281
     <tr>
282
        <td class="{$disfirstColStyle}">
283
          <xsl:value-of select="name" />
284
        </td>
285
        <td class="{$disfirstColStyle}">
286
          <xsl:choose>
287
            <xsl:when test="defaultValue">
288
              <xsl:value-of select="defaultValue" />
289
            </xsl:when>
290
            <xsl:otherwise>
291
              &#160;
292
            </xsl:otherwise>
293
          </xsl:choose>
294

    
295
        </td>
296
        <td class="{$secondColStyle}">
297
          <xsl:value-of select="definition" />
298
        </td>
299
            
300
      </tr>
301
   </xsl:template>
302

    
303
  <!-- ********************************************************************* -->
304
  <!-- *******************************  Offline data  ********************** -->
305
  <!-- ********************************************************************* -->
306

    
307
  <xsl:template match="offline">
308
    <xsl:param name="disfirstColStyle"/>
309
    <xsl:param name="dissubHeaderStyle"/>
310
    <div class="control-group">
311
		<label class="control-label">Offline Distribution Info</label>
312
		<div class="controls controls-well">
313
			<table class="table table-striped">
314
				<xsl:if test="(mediumName) and normalize-space(mediumName)!=''">
315
					<tr>
316
					<td class="{$disfirstColStyle}"><xsl:text>Medium</xsl:text></td>
317
					<td class="{$secondColStyle}"><xsl:value-of select="mediumName"/></td></tr>
318
			    </xsl:if>
319
			    <xsl:if test="(mediumDensity) and normalize-space(mediumDensity)!=''">
320
				    <tr><td class="{$disfirstColStyle}"><xsl:text>Medium Density</xsl:text></td>
321
				    <td class="{$secondColStyle}"><xsl:value-of select="mediumDensity"/>
322
				    <xsl:if test="(mediumDensityUnits) and normalize-space(mediumDensityUnits)!=''">
323
				    	<xsl:text> (</xsl:text><xsl:value-of select="mediumDensityUnits"/><xsl:text>)</xsl:text>
324
				    </xsl:if>
325
				    </td></tr>
326
			    </xsl:if>
327
			    <xsl:if test="(mediumVol) and normalize-space(mediumVol)!=''">
328
				    <tr><td class="{$disfirstColStyle}"><xsl:text>Volume</xsl:text></td>
329
				    <td class="{$secondColStyle}"><xsl:value-of select="mediumVol"/></td></tr>
330
			    </xsl:if>
331
			    <xsl:if test="(mediumFormat) and normalize-space(mediumFormat)!=''">
332
				    <tr><td class="{$disfirstColStyle}"><xsl:text>Format</xsl:text></td>
333
				    <td class="{$secondColStyle}"><xsl:value-of select="mediumFormat"/></td></tr>
334
			    </xsl:if>
335
			    <xsl:if test="(mediumNote) and normalize-space(mediumNote)!=''">
336
				    <tr><td class="{$disfirstColStyle}"><xsl:text>Notes</xsl:text></td>
337
				    <td class="{$secondColStyle}"><xsl:value-of select="mediumNote"/></td></tr>
338
			    </xsl:if>
339
		    </table>
340
		</div>
341
	</div>	
342
    
343
  </xsl:template>
344

    
345
  <!-- ********************************************************************* -->
346
  <!-- *******************************  Inline data  *********************** -->
347
  <!-- ********************************************************************* -->
348

    
349

    
350
  <xsl:template match="inline">
351
    <xsl:param name="disfirstColStyle"/>
352
    <xsl:param name="dissubHeaderStyle"/>
353
    <xsl:param name="docid"/>
354
    <xsl:param name="level">entity</xsl:param>
355
    <xsl:param name="entitytype"/>
356
    <xsl:param name="entityindex"/>
357
    <xsl:param name="physicalindex"/>
358
    <xsl:param name="distributionindex"/>
359

    
360
    <div class="control-group">
361
		<label class="control-label">Inline Data</label>
362
		<div class="controls controls-well">
363
	      <!-- for top top distribution-->
364
	      <xsl:if test="$level='toplevel'">
365
	        <a><xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&amp;displaymodule=inlinedata&amp;distributionlevel=<xsl:value-of select="$level"/>&amp;distributionindex=<xsl:value-of select="$distributionindex"/></xsl:attribute>
366
	        Inline Data</a>
367
	      </xsl:if>
368
	      <xsl:if test="$level='entitylevel'">
369
	        <a><xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&amp;displaymodule=inlinedata&amp;distributionlevel=<xsl:value-of select="$level"/>&amp;entitytype=<xsl:value-of select="$entitytype"/>&amp;entityindex=<xsl:value-of select="$entityindex"/>&amp;physicalindex=<xsl:value-of select="$physicalindex"/>&amp;distributionindex=<xsl:value-of select="$distributionindex"/></xsl:attribute>
370
	        Inline Data</a>
371
	      </xsl:if>
372
		</div>
373
	</div>
374
    
375
  </xsl:template>
376

    
377

    
378
</xsl:stylesheet>
(9-9/27)