Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
*  '$RCSfile: resultset.xsl,v $'
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: cjones $'
10
*     '$Date: 2004/10/05 23:50:46 $'
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 showing the resultset of a query
29
* into an HTML format suitable for rendering with modern web browsers.
30
-->
31
<!-- 2006-05-01 mob: link to data entity is now a form, submits to a cgi requesting some user info, then on to data. 
32
required another javascript (original one contains metacat params) and a template to generate the form.
33
-->
34

    
35
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
36
  <xsl:param name="cgi-url" select='string("")'/>
37
  <xsl:param name="sessid"/>
38
  <xsl:param name="enableediting">false</xsl:param>
39
  <xsl:param name="contextURL"/>
40
  <!-- This parameter gets overidden by the chosen default qformat -->
41
  <xsl:param name="qformat">default</xsl:param>
42
  <xsl:param name="servletURL"/>
43
  
44
  <!-- import the header, footer, and sidebars for customized styling -->
45
  <xsl:import href="{$contextURL}/style/skins/{$qformat}/templates/xsl/pageheader.xsl"/>
46
  <xsl:import href="{$contextURL}/style/skins/{$qformat}/templates/xsl/pagefooter.xsl"/>
47
  <xsl:import href="{$contextURL}/style/skins/{$qformat}/templates/xsl/page_leftsidebar.xsl"/>
48
  <xsl:import href="{$contextURL}/style/skins/{$qformat}/templates/xsl/page_rightsidebar.xsl"/>
49
  <xsl:import href="{$contextURL}/style/skins/{$qformat}/templates/xsl/loginbox.xsl"/>
50
  <xsl:import href="{$contextURL}/style/skins/{$qformat}/templates/xsl/searchbox.xsl"/>
51

    
52
  <!-- send the resultset back to the browser styled in HTML -->
53
  <xsl:output method="html" encoding="iso-8859-1" indent="yes" standalone="yes"
54
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
55
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
56
	
57
	<!-- this param set to require a user to accept a datause agreement 
58
  <xsl:param name="visit_datauseagreement">true</xsl:param> -->
59

    
60
  <!-- The main template matches the XML document root -->
61
  <xsl:template match="/">
62
   <html>
63
      <head>
64
        <link rel="stylesheet" type="text/css" 
65
              href="{$contextURL}/style/skins/{$qformat}/{$qformat}.css" />
66
        <script language="Javascript" type="text/JavaScript"
67
          src="{$contextURL}/style/skins/{$qformat}/{$qformat}.js" />
68
        <script language="Javascript" type="text/JavaScript"
69
          src="{$contextURL}/style/common/{$qformat}/branding.js" />
70
        <script language="JavaScript">
71
          <![CDATA[
72
          function submitform(action,form_ref) {
73
              form_ref.action.value=action;
74
              form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
75
              form_ref.qformat.value="]]><xsl:value-of select="$qformat" /><![CDATA[";
76
              form_ref.submit();
77
          }
78
          ]]>
79
        </script>
80
        <script language="JavaScript">
81
          <![CDATA[  
82
          function view_entity(form_ref) {
83
               form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
84
              form_ref.qformat.value="]]><xsl:value-of select="$qformat" /><![CDATA[";
85
              form_ref.submit();
86
          }
87
            ]]>          
88
        </script>				
89
				
90

    
91
      </head>
92

    
93
      <body>
94
        <!-- begin the header area -->
95
        <xsl:call-template name="pageheader" />
96
        <!-- end the header area -->
97
   
98
        <!-- begin the left sidebar area -->
99
        <xsl:call-template name="page_leftsidebar" />
100
        <!-- end the left sidebar area -->
101
   
102
        <!-- begin the content area -->
103
        <div id="content">
104

    
105
          <!-- begin login form area -->
106
          <xsl:call-template name="loginbox" />
107
          <!-- end login form area -->
108

    
109
          <!-- begin search form area -->
110
          <xsl:call-template name="searchbox" />
111
          <!-- end search form area --> 
112
         
113

    
114
          <!-- begin results section (XSLT generated) -->
115
          <div id="data-catalog-area">
116

    
117
          <!-- State how many package hits were returned -->
118
          <xsl:choose>
119
            <xsl:when test="count(resultset/document)=1">
120
              <p>
121
              <xsl:number value="count(resultset/document)" /> data package found:
122
              </p>
123
            </xsl:when>
124
            <xsl:otherwise>
125
              <p>
126
              <xsl:number value="count(resultset/document)" /> data packages found:
127
              </p>
128
            </xsl:otherwise>
129
          </xsl:choose>
130
          
131
          <!-- This tests to see if there are returned documents,
132
          if there are not then don't show the query results -->
133
          <xsl:if test="count(resultset/document) &gt; 0">
134

    
135
            <!-- create the results table, and style each of the returnfield that
136
            were specified in the original query -->
137
            <table class="group group_border">
138
              <tr>
139
                 <!--<th>Type</th> -->
140
                <th class="wide_column">Title (follow link for metadata)</th>
141
                <th>Principal Investigators</th>
142
                <!-- <th>Organization</th> -->
143
                <th>Download Data Tables (no metadata)</th>
144
                <xsl:if test="$enableediting = 'true'">
145
                  <th>Actions</th>
146
                </xsl:if>
147
              </tr>
148
          
149
            <xsl:for-each select="resultset/document">
150
              <xsl:sort select="./param[@name='eml/dataset/title']"/>
151
              <tr>
152
              
153
               <!-- style the keyword table-cell for data type-->
154
               <!-- removed: too many keywords
155
                <td>
156
                <xsl:attribute name="class">
157
                  <xsl:choose>
158
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
159
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
160
                  </xsl:choose>
161
                </xsl:attribute>
162
                <xsl:for-each select="./param[@name='keyword']">
163
                  <xsl:value-of select="." />
164
                  <br />
165
                  </xsl:for-each>
166
                </td>
167
             -->
168
              
169
              
170
 <!-- style the Title table-cell for data type-->
171
                <td>
172
                <xsl:attribute name="class">
173
                  <xsl:choose>
174
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
175
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
176
                  </xsl:choose>
177
                </xsl:attribute>
178
          
179
              <!--
180
               Build a submit form to view the data package details, using hidden fields to POST the query values.
181
                  --> 
182
              <form action="{$servletURL}" method="POST">
183
              <xsl:attribute name="name">
184
                <xsl:value-of select="translate(./docid, '()-.', '')" />
185
              </xsl:attribute>
186
                    <input type="hidden" name="qformat" />
187
                    <input type="hidden" name="sessionid" />
188
              <xsl:if test="$enableediting = 'true'">
189
                <input type="hidden" name="enableediting" value="{$enableediting}"/>
190
              </xsl:if>
191
                    <input type="hidden" name="action" value="read"/>
192
                    <input type="hidden" name="docid">
193
                <xsl:attribute name="value">
194
                  <xsl:value-of select="./docid"/>
195
                </xsl:attribute>
196
                    </input>
197
              <xsl:for-each select="./relation">
198
                <input type="hidden" name="docid">
199
                  <xsl:attribute name="value" >
200
                    <xsl:value-of select="./relationdoc" />
201
                  </xsl:attribute>
202
                </input>
203
              </xsl:for-each>
204

    
205
              <!-- Create the link on the title column -->
206
              <a>
207
                <xsl:attribute name="href">javascript:submitform('read',document.<xsl:value-of select="translate(./docid, '()-.', '')"/>)</xsl:attribute>
208
                <xsl:choose>
209
                  <xsl:when test="./param[@name='eml/dataset/title']!=''">
210
               <xsl:value-of select="./param[@name='eml/dataset/title']"/>
211
                  </xsl:when>
212
                  <xsl:otherwise>
213
                    <xsl:value-of select="./param[@name='eml/citation/title']"/>
214
                    <xsl:value-of select="./param[@name='eml/software/title']"/>
215
                    <xsl:value-of select="./param[@name='eml/protocol/title']"/>
216
                  </xsl:otherwise>
217
                </xsl:choose>
218
              </a>
219

    
220
              <!-- Include the docid in the title output -->
221
              <xsl:text>(</xsl:text>
222
                <xsl:value-of select="./docid"/>
223
              <xsl:text>)</xsl:text>
224
                  </form>
225
                </td>
226
          
227
                
228
 <!-- style the table-cell for PIs -->
229
                <td>
230
                <xsl:attribute name="class">
231
                  <xsl:choose>
232
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
233
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
234
                  </xsl:choose>
235
                </xsl:attribute>
236
          
237
                  <xsl:for-each select="./param[@name='eml/dataset/creator/individualName/surName']" >
238
              <xsl:value-of select="." />
239
                  <br />
240
             </xsl:for-each> 
241
             </td>
242
 
243
<!-- style the table-cell for the data tables-->
244
							<!--
245
                 create links to each of this package's data entities. 
246
                 needed to edit the url first, then pass it to the form template with param.
247
                 mob replaced this section 2006-05-01 -->              
248
                <td>
249
                <xsl:attribute name="class">
250
                  <xsl:choose>
251
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
252
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
253
                  </xsl:choose>
254
                </xsl:attribute>                 
255
                  <!-- Check the url, edit string if it uses ecogrid protocol. -->               
256
                  <xsl:for-each select="./param[@name='eml/dataset/dataTable/entityName']"> 
257
                    <xsl:variable name="entity_name" select="."/>
258
                  <xsl:variable name="URL"
259
                    select="following-sibling::param[@name='eml/dataset/dataTable/physical/distribution/online/url']" />                 
260
                  <xsl:choose>
261
                    <!-- 
262
                      if the content of url is to external data table -->
263
                    <xsl:when test="starts-with($URL,'http')">            
264
                      <xsl:variable name="URL1" select="$URL"/>
265
                        <xsl:call-template name="data_use_agreement_form">
266
                            <xsl:with-param name="entity_name" select="$entity_name"/>
267
                            <xsl:with-param name="URL1" select="$URL1"/>
268
                        </xsl:call-template>
269
                    </xsl:when>                 
270
                    <!-- 
271
                      if URL uses ecogrid protocol, strip off table name, then create metacat query  -->
272
                    <xsl:when test="starts-with($URL,'ecogrid')">                          
273
                      <xsl:variable name="URLsubstr" select="substring-after($URL, 'ecogrid://')"/>
274
                      <xsl:variable name="docID" select="substring-after($URLsubstr, '/')"/>
275
                       <xsl:variable name="URL1">
276
                       	<xsl:text>{$servletURL}?action=read&amp;qformat=</xsl:text><xsl:value-of select="$qformat"/><xsl:text>&amp;docid=</xsl:text><xsl:value-of select="$docID"/>
277
                           
278
                        <!-- <xsl:text>http://sbcdata.lternet.edu/catalog/metacat?action=read&amp;qformat=</xsl:text>
279
                        	<xsl:value-of select="$qformat"/>
280
                          <xsl:text>&amp;docid=</xsl:text>
281
                          <xsl:value-of select="$docID"/> -->
282
                       </xsl:variable>
283
                       <xsl:call-template name="data_use_agreement_form">
284
                            <xsl:with-param name="entity_name" select="$entity_name"/>
285
                            <xsl:with-param name="URL1" select="$URL1"/>
286
                        </xsl:call-template>
287
                    </xsl:when>
288
                    <xsl:otherwise>
289
                         <!-- 
290
                         else, assume the url content is the just name of a metacat table -->
291
                       <xsl:variable name="URL1">
292
                          <xsl:text>{$servletURL}?action=read&amp;qformat=</xsl:text>
293
                           <xsl:value-of select="$qformat"/>
294
                           <xsl:text>&amp;docid=</xsl:text>
295
                           <xsl:value-of select="$URL"/>
296
                       </xsl:variable>
297
                       <xsl:call-template name="data_use_agreement_form">
298
                            <xsl:with-param name="entity_name" select="$entity_name"/>
299
                            <xsl:with-param name="URL1" select="$URL1"/>
300
                       </xsl:call-template>
301
                    </xsl:otherwise>                
302
                  </xsl:choose>
303
                  </xsl:for-each>                 
304
                </td>             
305
  
306
								
307
								
308
								
309
	               <!-- 
310
								 
311
                   if editing is turned on, add some buttons -->
312
                <xsl:if test="$enableediting = 'true'">
313
                <td>
314
                <xsl:attribute name="class">
315
                  <xsl:choose>
316
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
317
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
318
                  </xsl:choose>
319
                </xsl:attribute>
320
          
321
                  <form action="{$servletURL}" method="POST">
322
                    <input type="hidden" name="action" value="read"/>
323
               <input type="hidden" name="qformat" value="{$qformat}"/>
324
                 <input type="hidden" name="sessionid"  value="{$sessid}"/>
325
                    <input type="hidden" name="docid">
326
                    <xsl:attribute name="value">
327
                 <xsl:value-of select="./docid"/>
328
                    </xsl:attribute>
329
                    </input>
330
                    <center>
331
                    <input type="SUBMIT"  value=" View " name="View">
332
               </input>
333
                    </center>
334
                  </form>
335
              <form action="{$cgi-url}/register-dataset.cgi" 
336
                    method="POST">
337
                    <input type="hidden" name="stage" value="modify"/>  
338
                   <input type="hidden" name="cfg" value="{$qformat}"/>
339
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
340
                <input type="hidden" name="docid">
341
                  <xsl:attribute name="value">
342
                    <xsl:value-of select="./docid"/>
343
                  </xsl:attribute>
344
                </input>
345
                    <input type="SUBMIT"  value=" Edit " name="Edit">
346
                 </input>
347
                  </form>
348
              <form action="{$cgi-url}/register-dataset.cgi" 
349
                    method="POST">
350
                    <input type="hidden" name="stage" value="delete"/>  
351
                   <input type="hidden" name="cfg" value="{$qformat}"/>
352
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
353
                <input type="hidden" name="docid">
354
                  <xsl:attribute name="value">
355
                    <xsl:value-of select="./docid"/>
356
                  </xsl:attribute>
357
                </input>
358
                    <input type="submit"  value="Delete" name="Delete">
359
                 </input>
360
                  </form>
361
                </td>    
362
                </xsl:if>
363
                </tr>
364
             </xsl:for-each>
365
             </table>
366
           </xsl:if>
367

    
368
         </div>  <!-- end data-catalog-area -->
369
        </div>
370
        <!-- end content area -->
371

    
372
        <!-- begin the right sidebar area -->
373
        <xsl:call-template name="page_rightsidebar" />
374
        <!-- end the right sidebar area -->
375

    
376
        <!-- begin the footer area -->
377
        <xsl:call-template name="pagefooter" />
378
        <!-- end the footer area -->
379

    
380
      </body>
381
    </html>
382
  </xsl:template>
383
  <!-- 
384

    
385

    
386
  template to display data use agreement form. 
387
  mob, 2006-05-01 -->
388
  <xsl:template name="data_use_agreement_form">
389
      <xsl:param name="entity_name"/>
390
      <xsl:param name="URL1"/>
391
      <!-- create form to pass url and entity's name to cgi with data agreement page. form name must be unique/dynamic -->
392
      <form action="{$cgi-url}/data-use-agreement.cgi" method="POST"> 
393
      <!-- <form action="http://sbcdata.lternet.edu/cgi-bin/data-use-agreement.cgi" method="POST">      -->
394
      	<xsl:attribute name="name">
395
		<xsl:value-of select="translate($entity_name,',:()-. ' ,'')" />
396
        </xsl:attribute>
397
        <input type="hidden" name="qformat" />
398
        <input type="hidden" name="sessionid" />
399
        <xsl:if test="$enableediting = 'true'">
400
		<input type="hidden" name="enableediting" value="{$enableediting}"/>
401
        </xsl:if>
402
	<input type="hidden" name="url">
403
		<xsl:attribute name="value">
404
              	 	<xsl:value-of select="$URL1"/>
405
              	</xsl:attribute>
406
        </input>   
407
        <input type="hidden" name="entityName">
408
             <xsl:attribute name="value">
409
               <xsl:value-of select="$entity_name"/>
410
             </xsl:attribute>
411
        </input>
412
        <a>      
413
        	<xsl:attribute name="href">javascript:view_entity(document.<xsl:value-of select="translate($entity_name,',:()-. ' ,'')" />)</xsl:attribute>
414
		<xsl:value-of select="$entity_name"/>     <!-- the entity name forms the anchor text --> 
415
	 </a>                           
416
	 <br/>                     
417
    </form>
418
  </xsl:template>
419
</xsl:stylesheet>
(8-8/14)