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-15 10:37:09 -0700 (Mon, 15 Jul 2013) $'
11
  * '$Revision: 7982 $'
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="iso-8859-1"
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
      <table class="{$tabledefaultStyle}">
52
       <xsl:choose>
53
         <xsl:when test="references!=''">
54
          <xsl:variable name="ref_id" select="references"/>
55
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
56
          <xsl:for-each select="$references">
57
            <xsl:apply-templates select="online">
58
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
59
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
60
            </xsl:apply-templates>
61
            <xsl:apply-templates select="offline">
62
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
63
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
64
            </xsl:apply-templates>
65
            <xsl:apply-templates select="inline">
66
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
67
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
68
               <xsl:with-param name="docid" select="$docid"/>
69
               <xsl:with-param name="level" select="$level"/>
70
               <xsl:with-param name="entitytype" select="$entitytype"/>
71
               <xsl:with-param name="entityindex" select="$entityindex"/>
72
               <xsl:with-param name="physicalindex" select="$physicalindex"/>
73
               <xsl:with-param name="distributionindex" select="$distributionindex"/>
74
             </xsl:apply-templates>
75
          </xsl:for-each>
76
        </xsl:when>
77
        <xsl:otherwise>
78
            <xsl:apply-templates select="online">
79
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
80
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
81
            </xsl:apply-templates>
82
            <xsl:apply-templates select="offline">
83
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
84
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
85
            </xsl:apply-templates>
86
            <xsl:apply-templates select="inline">
87
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
88
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
89
               <xsl:with-param name="docid" select="$docid"/>
90
               <xsl:with-param name="level" select="$level"/>
91
               <xsl:with-param name="entitytype" select="$entitytype"/>
92
               <xsl:with-param name="entityindex" select="$entityindex"/>
93
               <xsl:with-param name="physicalindex" select="$physicalindex"/>
94
               <xsl:with-param name="distributionindex" select="$distributionindex"/>
95
            </xsl:apply-templates>
96
        </xsl:otherwise>
97
       </xsl:choose>
98
      </table>
99
  </xsl:template>
100

    
101
  <!-- ********************************************************************* -->
102
  <!-- *******************************  Online data  *********************** -->
103
  <!-- ********************************************************************* -->
104
  <xsl:template match="online">
105
    <xsl:param name="disfirstColStyle"/>
106
    <xsl:param name="dissubHeaderStyle"/>
107
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
108
        <xsl:text>Online Distribution Info:</xsl:text>
109
    </td></tr>
110
    <xsl:apply-templates select="url">
111
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
112
    </xsl:apply-templates>
113
    <xsl:apply-templates select="connection">
114
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
115
    </xsl:apply-templates>
116
    <xsl:apply-templates select="connectionDefinition">
117
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
118
    </xsl:apply-templates>
119
  </xsl:template>
120

    
121
  <xsl:template match="url">
122
    <xsl:param name="disfirstColStyle"/>
123
    <xsl:variable name="URL" select="."/>
124
    <tr>
125
      <td class="{$disfirstColStyle}">
126
        <xsl:text>&#160;</xsl:text>
127
      </td>
128
      <td class="{$secondColStyle}">
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
       </td>
166
    </tr>
167
  </xsl:template>
168

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

    
189
  <!-- A template shared by connection references and connection in line-->
190
  <xsl:template name="connectionCommon">
191
    <xsl:param name="disfirstColStyle"/>
192
    <xsl:if test="parameter">
193
      <tr>
194
        <td class="{$disfirstColStyle}">
195
          <xsl:text>Parameter(s):</xsl:text>
196
        </td>
197
        <td class="{$secondColStyle}"><xsl:text>&#160;</xsl:text>
198
        </td>
199
      </tr>
200
      <xsl:call-template name="renderParameters">
201
        <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
202
      </xsl:call-template>
203
    </xsl:if>
204
    <xsl:apply-templates select="connectionDefinition">
205
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
206
    </xsl:apply-templates>
207
  </xsl:template>
208

    
209
  <xsl:template name="renderParameters">
210
    <xsl:param name="disfirstColStyle"/>
211
    <xsl:for-each select="parameter" >
212
      <tr>
213
        <td class="{$disfirstColStyle}">
214
          <xsl:text>&#160;&#160;&#160;&#160;&#160;</xsl:text><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
  </xsl:template>
222

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

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

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

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

    
297
              </td>
298
              <td class="{$secondColStyle}">
299
                <xsl:value-of select="definition" />
300
              </td>
301
            </tr>
302
          </table>
303
        </td>
304
      </tr>
305
   </xsl:template>
306

    
307
  <!-- ********************************************************************* -->
308
  <!-- *******************************  Offline data  ********************** -->
309
  <!-- ********************************************************************* -->
310

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

    
343
  <!-- ********************************************************************* -->
344
  <!-- *******************************  Inline data  *********************** -->
345
  <!-- ********************************************************************* -->
346

    
347

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

    
358
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
359
        <xsl:text>Inline Data:</xsl:text>
360
    </td></tr>
361
    <tr><td class="{$disfirstColStyle}">
362
      <xsl:text>&#160;</xsl:text></td>
363
      <td class="{$secondColStyle}">
364
      <!-- for top top distribution-->
365
      <xsl:if test="$level='toplevel'">
366
        <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>
367
        <b>Inline Data</b></a>
368
      </xsl:if>
369
      <xsl:if test="$level='entitylevel'">
370
        <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>
371
        <b>Inline Data</b></a>
372
      </xsl:if>
373
     </td></tr>
374
  </xsl:template>
375

    
376

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