Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile: eml-distribution-2.0.0.xsl,v $'
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: cjones $'
10
  *     '$Date: 2004/10/05 23:50:34 $'
11
  * '$Revision: 1.1 $'
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-2.0.0.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>Data Available Online:</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
     <xsl:variable name="entity_name">
125
         <xsl:value-of select="../../../../entityName"/>
126
     </xsl:variable>
127
    <tr>
128
        <!-- contents of this row depends on resource being downloaded
129
             if it's in a dataTable tree, url is intercepted by data-use-agreement-form which asks
130
             for some info via cgi script.
131
        -->
132
  <xsl:choose>
133
      <xsl:when test="ancestor::dataTable">   
134
      <td class="{$disfirstColStyle}">
135
        <xsl:text>&#160;</xsl:text>
136
        <xsl:text>View data after acceptance of Data Use Agreement:</xsl:text>
137
      </td>
138
      <td class="{$secondColStyle}">
139
       <!--     create links to each of this package's data entities. 
140
                   edit the url first, then pass it to the form template with param. -->
141
  
142
          
143
                 <xsl:choose>
144
                    <!-- 
145
                      if the content of url is to external data table -->
146
                    <xsl:when test="starts-with($URL,'http')">            
147
                      <xsl:variable name="URL1" select="$URL"/>
148
                        <xsl:call-template name="data_use_agreement_form">
149
                            <xsl:with-param name="entity_name" select="$entity_name"/>
150
                            <xsl:with-param name="URL1" select="$URL1"/>
151
                        </xsl:call-template>
152
                    </xsl:when>                 
153
                    <!-- 
154
                      if URL uses ecogrid protocol, strip off table name, then create metacat query  -->
155
                    <xsl:when test="starts-with($URL,'ecogrid')">                          
156
                      <xsl:variable name="URLsubstr" select="substring-after($URL, 'ecogrid://')"/>
157
                      <xsl:variable name="docID" select="substring-after($URLsubstr, '/')"/>
158
                       <xsl:variable name="URL1">
159
                           <!-- 
160
                           <xsl:text>@systemidserver@@servlet-path@?action=read&amp;qformat=</xsl:text><xsl:value-of select="$qformat"/><xsl:text>&amp;docid=</xsl:text><xsl:value-of select="$docID"/>
161
                           -->
162
                           <xsl:text>http://sbc.lternet.edu/catalog/metacat?action=read&amp;qformat=</xsl:text>
163
                           <xsl:value-of select="$qformat"/>
164
                           <xsl:text>&amp;docid=</xsl:text>
165
                           <xsl:value-of select="$docID"/>
166
                       </xsl:variable>
167
                       <xsl:call-template name="data_use_agreement_form">
168
                            <xsl:with-param name="entity_name" select="$entity_name"/>
169
                            <xsl:with-param name="URL1" select="$URL1"/>
170
                        </xsl:call-template>
171
                    </xsl:when>
172
                    <xsl:otherwise>
173
                         <!-- 
174
                         else, assume the url content is the just name of a metacat table -->
175
                       <xsl:variable name="URL1">
176
                          <xsl:text>@systemidserver@@servlet-path@?action=read&amp;qformat=</xsl:text>
177
                           <xsl:value-of select="$qformat"/>
178
                           <xsl:text>&amp;docid=</xsl:text>
179
                           <xsl:value-of select="$URL"/>
180
                       </xsl:variable>
181
                       <xsl:call-template name="data_use_agreement_form">
182
                            <xsl:with-param name="entity_name" select="$entity_name"/>
183
                            <xsl:with-param name="URL1" select="$URL1"/>
184
                       </xsl:call-template>
185
                    </xsl:otherwise>                
186
                  </xsl:choose>
187
         </td>
188
              </xsl:when>
189
              <xsl:otherwise>
190
                  <!-- the original content, url shows as a link. -->
191
                     <td class="{$disfirstColStyle}">
192
                        <xsl:text>&#160;</xsl:text>
193
                            <xsl:text>View this object:</xsl:text>
194
                        </td>
195
                        <td class="{$secondColStyle}">
196
                             <a>
197
                                  <xsl:choose>
198
                                     <xsl:when test="starts-with($URL,'ecogrid')">
199
		         <xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
200
		      <xsl:variable name="docID" select="substring-after($URL1, '/')"/>
201
		<xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docID"/></xsl:attribute>
202
           </xsl:when>
203
           <xsl:otherwise>
204
		<xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
205
           </xsl:otherwise>
206
          </xsl:choose>
207
          <xsl:attribute name="target">_blank</xsl:attribute>
208
          <xsl:value-of select="."/>
209
        </a>
210
          </td>
211
          </xsl:otherwise>
212
         </xsl:choose>
213
          
214
          
215
      
216
    </tr>
217
  </xsl:template>
218

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

    
239
  <!-- A template shared by connection references and connection in line-->
240
  <xsl:template name="connectionCommon">
241
    <xsl:param name="disfirstColStyle"/>
242
    <xsl:if test="parameter">
243
      <tr>
244
        <td class="{$disfirstColStyle}">
245
          <xsl:text>Parameter(s):</xsl:text>
246
        </td>
247
        <td class="{$secondColStyle}"><xsl:text>&#160;</xsl:text>
248
        </td>
249
      </tr>
250
      <xsl:call-template name="renderParameters">
251
        <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
252
      </xsl:call-template>
253
    </xsl:if>
254
    <xsl:apply-templates select="connectionDefinition">
255
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
256
    </xsl:apply-templates>
257
  </xsl:template>
258

    
259
  <xsl:template name="renderParameters">
260
    <xsl:param name="disfirstColStyle"/>
261
    <xsl:for-each select="parameter" >
262
      <tr>
263
        <td class="{$disfirstColStyle}">
264
          <xsl:text>&#160;&#160;&#160;&#160;&#160;</xsl:text><xsl:value-of select="name" />
265
        </td>
266
        <td class="{$secondColStyle}">
267
         <xsl:value-of select="value" />
268
        </td>
269
      </tr>
270
    </xsl:for-each>
271
  </xsl:template>
272

    
273
   <xsl:template match="connectionDefinition">
274
    <xsl:param name="disfirstColStyle"/>
275
    <xsl:choose>
276
      <xsl:when test="references!=''">
277
        <xsl:variable name="ref_id" select="references"/>
278
        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
279
        <xsl:for-each select="$references">
280
          <xsl:call-template name="connectionDefinitionCommon">
281
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
282
          </xsl:call-template>
283
        </xsl:for-each>
284
      </xsl:when>
285
      <xsl:otherwise>
286
        <xsl:call-template name="connectionDefinitionCommon">
287
          <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
288
        </xsl:call-template>
289
      </xsl:otherwise>
290
    </xsl:choose>
291
   </xsl:template>
292

    
293
   <!-- This template will be shared by both reference and inline connectionDefinition-->
294
   <xsl:template name="connectionDefinitionCommon">
295
    <xsl:param name="disfirstColStyle"/>
296
      <tr>
297
          <td class="{$disfirstColStyle}">
298
            <xsl:text>Schema Name:</xsl:text>
299
          </td>
300
          <td class="{$secondColStyle}">
301
            <xsl:value-of select="schemeName" />
302
          </td>
303
       </tr>
304
       <tr>
305
          <td class="{$disfirstColStyle}">
306
            <xsl:text>Description:</xsl:text>
307
          </td>
308
          <td>
309
           <xsl:apply-templates select="description">
310
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
311
            </xsl:apply-templates>
312
          </td>
313
       </tr>
314
       <xsl:for-each select="parameterDefinition">
315
          <xsl:call-template name="renderParameterDefinition">
316
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
317
          </xsl:call-template>
318
       </xsl:for-each>
319
   </xsl:template>
320

    
321
   <xsl:template match="description">
322
     <xsl:param name="disfirstColStyle"/>
323
     <xsl:call-template name="text">
324
        <xsl:with-param name="textfirstColStyle" select="$secondColStyle" />
325
     </xsl:call-template>
326
   </xsl:template>
327

    
328
   <xsl:template name="renderParameterDefinition">
329
     <xsl:param name="disfirstColStyle"/>
330
     <tr>
331
        <td class="{$disfirstColStyle}">
332
          <xsl:text>&#160;&#160;&#160;&#160;&#160;</xsl:text><xsl:value-of select="name" /><xsl:text>:</xsl:text>
333
        </td>
334
        <td>
335
          <table class="{$tabledefaultStyle}">
336
            <tr>
337
              <td class="{$disfirstColStyle}">
338
                <xsl:choose>
339
                  <xsl:when test="defaultValue">
340
                    <xsl:value-of select="defaultValue" />
341
                  </xsl:when>
342
                  <xsl:otherwise>
343
                    &#160;
344
                  </xsl:otherwise>
345
                </xsl:choose>
346

    
347
              </td>
348
              <td class="{$secondColStyle}">
349
                <xsl:value-of select="definition" />
350
              </td>
351
            </tr>
352
          </table>
353
        </td>
354
      </tr>
355
   </xsl:template>
356

    
357
  <!-- ********************************************************************* -->
358
  <!-- *******************************  Offline data  ********************** -->
359
  <!-- ********************************************************************* -->
360

    
361
  <xsl:template match="offline">
362
    <xsl:param name="disfirstColStyle"/>
363
    <xsl:param name="dissubHeaderStyle"/>
364
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
365
        <xsl:text>Data are Offline:</xsl:text>
366
    </td></tr>
367
    <xsl:if test="(mediumName) and normalize-space(mediumName)!=''">
368
      <tr><td class="{$disfirstColStyle}"><xsl:text>Medium:</xsl:text></td>
369
      <td class="{$secondColStyle}"><xsl:value-of select="mediumName"/></td></tr>
370
    </xsl:if>
371
    <xsl:if test="(mediumDensity) and normalize-space(mediumDensity)!=''">
372
    <tr><td class="{$disfirstColStyle}"><xsl:text>Medium Density:</xsl:text></td>
373
    <td class="{$secondColStyle}"><xsl:value-of select="mediumDensity"/>
374
    <xsl:if test="(mediumDensityUnits) and normalize-space(mediumDensityUnits)!=''">
375
    <xsl:text> (</xsl:text><xsl:value-of select="mediumDensityUnits"/><xsl:text>)</xsl:text>
376
    </xsl:if>
377
    </td></tr>
378
    </xsl:if>
379
    <xsl:if test="(mediumVol) and normalize-space(mediumVol)!=''">
380
    <tr><td class="{$disfirstColStyle}"><xsl:text>Volume:</xsl:text></td>
381
    <td class="{$secondColStyle}"><xsl:value-of select="mediumVol"/></td></tr>
382
    </xsl:if>
383
    <xsl:if test="(mediumFormat) and normalize-space(mediumFormat)!=''">
384
    <tr><td class="{$disfirstColStyle}"><xsl:text>Format:</xsl:text></td>
385
    <td class="{$secondColStyle}"><xsl:value-of select="mediumFormat"/></td></tr>
386
    </xsl:if>
387
    <xsl:if test="(mediumNote) and normalize-space(mediumNote)!=''">
388
    <tr><td class="{$disfirstColStyle}"><xsl:text>Notes:</xsl:text></td>
389
    <td class="{$secondColStyle}"><xsl:value-of select="mediumNote"/></td></tr>
390
    </xsl:if>
391
  </xsl:template>
392

    
393
  <!-- ********************************************************************* -->
394
  <!-- *******************************  Inline data  *********************** -->
395
  <!-- ********************************************************************* -->
396

    
397

    
398
  <xsl:template match="inline">
399
    <xsl:param name="disfirstColStyle"/>
400
    <xsl:param name="dissubHeaderStyle"/>
401
    <xsl:param name="docid"/>
402
    <xsl:param name="level">entity</xsl:param>
403
    <xsl:param name="entitytype"/>
404
    <xsl:param name="entityindex"/>
405
    <xsl:param name="physicalindex"/>
406
    <xsl:param name="distributionindex"/>
407

    
408
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
409
        <xsl:text>Data:</xsl:text>
410
    </td></tr>
411
    <tr><td class="{$disfirstColStyle}">
412
      <xsl:text>&#160;</xsl:text></td>
413
      <td class="{$secondColStyle}">
414
      <!-- for top top distribution-->
415
      <xsl:if test="$level='toplevel'">
416
        <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>
417
        <b>Inline Data</b></a>
418
      </xsl:if>
419
      <xsl:if test="$level='entitylevel'">
420
        <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>
421
        <b>Inline Data</b></a>
422
      </xsl:if>
423
     </td></tr>
424
  </xsl:template>
425

    
426
<!--
427

    
428

    
429
-->
430
    <xsl:template name="data_use_agreement_form">
431
        <xsl:param name="entity_name"/>
432
        <xsl:param name="URL1"/>
433
         <form action="http://sbcdata.lternet.edu/cgi-bin/data-use-agreement.cgi" method="POST">
434
             <xsl:attribute name="name">
435
                <xsl:value-of select="translate($entity_name,'()-.' ,'')" />
436
             </xsl:attribute>
437
             <input type="hidden" name="qformat" />
438
             <input type="hidden" name="sessionid" />
439
             <input type="hidden" name="url">
440
                 <xsl:attribute name="value">
441
                         <xsl:value-of select="$URL1"/>
442
                 </xsl:attribute>
443
            </input>
444
            <input type="hidden" name="entityName">
445
                 <xsl:attribute name="value">
446
                    <xsl:value-of select="$entity_name"/>
447
                 </xsl:attribute>
448
           </input>
449
           <input type="submit" name="data" class="view-data-button">
450
               <xsl:attribute name="value">Click to View: <xsl:value-of select="$entity_name"/>
451
               </xsl:attribute>
452
           </input>
453
          <br />
454
         </form>
455
        </xsl:template>
456

    
457

    
458
<!--
459

    
460

    
461

    
462
-->
463

    
464

    
465
</xsl:stylesheet>
(21-21/58)