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

    
37
  <!-- import the header, footer, and sidebars for customized styling -->
38
  <xsl:import href="@systemidserver@@style-skins-path@/@default-style@/templates/xsl/pageheader.xsl"/>
39
  <xsl:import href="@systemidserver@@style-skins-path@/@default-style@/templates/xsl/pagefooter.xsl"/>
40
  <xsl:import href="@systemidserver@@style-skins-path@/@default-style@/templates/xsl/page_leftsidebar.xsl"/>
41
  <xsl:import href="@systemidserver@@style-skins-path@/@default-style@/templates/xsl/page_rightsidebar.xsl"/>
42
  <xsl:import href="@systemidserver@@style-skins-path@/@default-style@/templates/xsl/loginbox.xsl"/>
43
  <xsl:import href="@systemidserver@@style-skins-path@/@default-style@/templates/xsl/searchbox.xsl"/>
44

    
45
  <!-- send the resultset back to the browser styled in HTML -->
46
  <xsl:output method="html" encoding="iso-8859-1" indent="yes" standalone="yes"
47
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
48
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
49

    
50
  <xsl:param name="sessid"/>
51
  <xsl:param name="enableediting">false</xsl:param>
52
  <!-- This parameter gets overidden by the chosen default qformat -->
53
  <xsl:param name="qformat">default</xsl:param>
54
	
55
	<!-- this param set to require a user to accept a datause agreement 
56
  <xsl:param name="visit_datauseagreement">true</xsl:param> -->
57

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

    
89
      </head>
90

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

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

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

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

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

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

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

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

    
366
         </div>  <!-- end data-catalog-area -->
367
        </div>
368
        <!-- end content area -->
369

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

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

    
378
      </body>
379
    </html>
380
  </xsl:template>
381
  <!-- 
382

    
383

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