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: walker $'
10
  *     '$Date: 2015-03-09 15:37:19 -0700 (Mon, 09 Mar 2015) $'
11
  * '$Revision: 9145 $'
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="data-pid"><xsl:value-of select="$docID"></xsl:value-of></xsl:attribute>
135
			   <xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docID"/></xsl:attribute>
136
           </xsl:when>
137
            <xsl:when test="contains($URL,'/object/')">
138
			   <xsl:variable name="docID" select="substring-after('$URL', '/object/')"/>
139
			   <xsl:attribute name="data-pid"><xsl:value-of select="$docID"></xsl:value-of></xsl:attribute>   
140
			   <xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
141
           </xsl:when>
142
           <xsl:otherwise>
143
			   <xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
144
           </xsl:otherwise>
145
          </xsl:choose>
146
          <xsl:attribute name="target">_blank</xsl:attribute>
147
          <xsl:value-of select="."/>
148
        </a>
149
        <xsl:if test="$withHTMLLinks = '1'">
150
	        <!-- stats for hosted documents loaded with ajax call -->
151
	        <xsl:if test="starts-with($URL,'ecogrid')">
152
				<xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
153
				<xsl:variable name="docID" select="substring-after($URL1, '/')"/>
154
				<xsl:variable name="divID">dataStats</xsl:variable>
155
				<span>
156
	          		<xsl:attribute name="id">
157
	          			<xsl:value-of select="$divID" />
158
	          		</xsl:attribute>
159
				</span>
160
				<script language="JavaScript">
161
					if (window.loadStats) {
162
						loadStats(
163
							'<xsl:value-of select="$divID" />', 
164
							'<xsl:value-of select="$docID" />', 
165
							'<xsl:value-of select="$contextURL" />/metacat', 
166
							'<xsl:value-of select="$qformat" />');
167
					}
168
				</script>
169
			</xsl:if>
170
		</xsl:if>		
171
      
172
  </xsl:template>
173

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

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

    
214
  <xsl:template name="renderParameters">
215
    <xsl:param name="disfirstColStyle"/>
216
    <table class="table table-striped">
217
      <xsl:for-each select="parameter" >
218
      <tr>
219
        <td class="{$disfirstColStyle}">
220
          <xsl:value-of select="name" />
221
        </td>
222
        <td class="{$secondColStyle}">
223
         <xsl:value-of select="value" />
224
        </td>
225
      </tr>
226
    </xsl:for-each>
227
    </table>
228
  </xsl:template>
229

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

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

    
278
   <xsl:template match="description">
279
     <xsl:param name="disfirstColStyle"/>
280
     <xsl:call-template name="text">
281
        <xsl:with-param name="textfirstColStyle" select="$secondColStyle" />
282
     </xsl:call-template>
283
   </xsl:template>
284

    
285
   <xsl:template name="renderParameterDefinition">
286
     <xsl:param name="disfirstColStyle"/>
287
     <tr>
288
        <td class="{$disfirstColStyle}">
289
          <xsl:value-of select="name" />
290
        </td>
291
        <td class="{$disfirstColStyle}">
292
          <xsl:choose>
293
            <xsl:when test="defaultValue">
294
              <xsl:value-of select="defaultValue" />
295
            </xsl:when>
296
            <xsl:otherwise>
297
              &#160;
298
            </xsl:otherwise>
299
          </xsl:choose>
300

    
301
        </td>
302
        <td class="{$secondColStyle}">
303
          <xsl:value-of select="definition" />
304
        </td>
305
            
306
      </tr>
307
   </xsl:template>
308

    
309
  <!-- ********************************************************************* -->
310
  <!-- *******************************  Offline data  ********************** -->
311
  <!-- ********************************************************************* -->
312

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

    
351
  <!-- ********************************************************************* -->
352
  <!-- *******************************  Inline data  *********************** -->
353
  <!-- ********************************************************************* -->
354

    
355

    
356
  <xsl:template match="inline">
357
    <xsl:param name="disfirstColStyle"/>
358
    <xsl:param name="dissubHeaderStyle"/>
359
    <xsl:param name="docid"/>
360
    <xsl:param name="level">entity</xsl:param>
361
    <xsl:param name="entitytype"/>
362
    <xsl:param name="entityindex"/>
363
    <xsl:param name="physicalindex"/>
364
    <xsl:param name="distributionindex"/>
365

    
366
    <div class="control-group">
367
		<label class="control-label">Inline Data</label>
368
		<div class="controls controls-well">
369
	      <!-- for top top distribution-->
370
	      <xsl:if test="$level='toplevel'">
371
	        <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>
372
	        Inline Data</a>
373
	      </xsl:if>
374
	      <xsl:if test="$level='entitylevel'">
375
	        <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>
376
	        Inline Data</a>
377
	      </xsl:if>
378
		</div>
379
	</div>
380
    
381
  </xsl:template>
382

    
383

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