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 class="wide_column">Title</th>
138
                <th>Principal Investigators</th>
139
                <!-- <th>Organization</th> -->
140
                <th>Data Tables (no metadata)</th>
141
                <xsl:if test="$enableediting = 'true'">
142
                  <th>Actions</th>
143
                </xsl:if>
144
              </tr>
145
          
146
            <xsl:for-each select="resultset/document">
147
              <xsl:sort select="./param[@name='dataset/title']"/>
148
              <tr>
149
                <td>
150
                <xsl:attribute name="class">
151
                  <xsl:choose>
152
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
153
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
154
                  </xsl:choose>
155
                </xsl:attribute>
156
          
157
              <!--
158
               Build a submit form to view the data package details, using hidden fields to POST the query values.
159
                  --> 
160
              <form action="@servlet-path@" method="POST">
161
              <xsl:attribute name="name">
162
                <xsl:value-of select="translate(./docid, '()-.', '')" />
163
              </xsl:attribute>
164
                    <input type="hidden" name="qformat" />
165
                    <input type="hidden" name="sessionid" />
166
              <xsl:if test="$enableediting = 'true'">
167
                <input type="hidden" name="enableediting" value="{$enableediting}"/>
168
              </xsl:if>
169
                    <input type="hidden" name="action" value="read"/>
170
                    <input type="hidden" name="docid">
171
                <xsl:attribute name="value">
172
                  <xsl:value-of select="./docid"/>
173
                </xsl:attribute>
174
                    </input>
175
              <xsl:for-each select="./relation">
176
                <input type="hidden" name="docid">
177
                  <xsl:attribute name="value" >
178
                    <xsl:value-of select="./relationdoc" />
179
                  </xsl:attribute>
180
                </input>
181
              </xsl:for-each>
182

    
183
              <!-- Create the link on the title column -->
184
              <a>
185
                <xsl:attribute name="href">javascript:submitform('read',document.<xsl:value-of select="translate(./docid, '()-.', '')"/>)</xsl:attribute>
186
                <xsl:choose>
187
                  <xsl:when test="./param[@name='dataset/title']!=''">
188
               <xsl:value-of select="./param[@name='dataset/title']"/>
189
                  </xsl:when>
190
                  <xsl:otherwise>
191
                    <xsl:value-of select="./param[@name='citation/title']"/>
192
                    <xsl:value-of select="./param[@name='software/title']"/>
193
                    <xsl:value-of select="./param[@name='protocol/title']"/>
194
                  </xsl:otherwise>
195
                </xsl:choose>
196
              </a>
197

    
198
              <!-- Include the docid in the title output -->
199
              <xsl:text>(</xsl:text>
200
                <xsl:value-of select="./docid"/>
201
              <xsl:text>)</xsl:text>
202
                  </form>
203
                </td>
204
          
205
              <!-- style the contacts returned -->
206
                <td>
207
                <xsl:attribute name="class">
208
                  <xsl:choose>
209
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
210
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
211
                  </xsl:choose>
212
                </xsl:attribute>
213
          
214
                  <xsl:for-each select="./param[@name='dataset/originator/individualName/surName']" >
215
              <xsl:value-of select="." />
216
                  <br />
217
             </xsl:for-each>
218
                  <xsl:for-each select="./param[@name='dataset/creator/individualName/surName']" >
219
              <xsl:value-of select="." />
220
                  <br />
221
                  </xsl:for-each>
222
                </td>
223

    
224
              <!-- style the organization returned -->
225
	      <!-- 
226
                <td>
227
                <xsl:attribute name="class">
228
                  <xsl:choose>
229
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
230
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
231
                  </xsl:choose>
232
                </xsl:attribute>
233
          
234
              <xsl:value-of select="./param[@name='dataset/originator/organizationName']" />
235
              <xsl:value-of select="./param[@name='dataset/creator/organizationName']" />
236
                </td>
237
		-->
238

    
239
              <!-- style the keywords returned -->
240
              <!--
241
                <td>
242
                <xsl:attribute name="class">
243
                  <xsl:choose>
244
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
245
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
246
                  </xsl:choose>
247
                </xsl:attribute>
248
          
249
                  <xsl:for-each select="./param[@name='keyword']">
250
                  <xsl:value-of select="." />
251
                  <br />
252
                  </xsl:for-each>
253
                </td>
254
              -->
255

    
256
							<!--
257
                 create links to each of this package's data entities. 
258
                 needed to edit the url first, then pass it to the form template with param.
259
                 mob replaced this section 2006-05-01 -->              
260
                <td>
261
                <xsl:attribute name="class">
262
                  <xsl:choose>
263
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
264
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
265
                  </xsl:choose>
266
                </xsl:attribute>                 
267
                  <!-- Check the url, edit string if it uses ecogrid protocol. -->               
268
                  <xsl:for-each select="./param[@name='dataTable/entityName']"> 
269
                    <xsl:variable name="entity_name" select="."/>
270
                  <xsl:variable name="URL"
271
                    select="following-sibling::param[@name='dataTable/physical/distribution/online/url']" />                 
272
                  <xsl:choose>
273
                    <!-- 
274
                      if the content of url is to external data table -->
275
                    <xsl:when test="starts-with($URL,'http')">            
276
                      <xsl:variable name="URL1" select="$URL"/>
277
                        <xsl:call-template name="data_use_agreement_form">
278
                            <xsl:with-param name="entity_name" select="$entity_name"/>
279
                            <xsl:with-param name="URL1" select="$URL1"/>
280
                        </xsl:call-template>
281
                    </xsl:when>                 
282
                    <!-- 
283
                      if URL uses ecogrid protocol, strip off table name, then create metacat query  -->
284
                    <xsl:when test="starts-with($URL,'ecogrid')">                          
285
                      <xsl:variable name="URLsubstr" select="substring-after($URL, 'ecogrid://')"/>
286
                      <xsl:variable name="docID" select="substring-after($URLsubstr, '/')"/>
287
                       <xsl:variable name="URL1">
288
                       	<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"/>
289
                           
290
                        <!-- <xsl:text>http://sbcdata.lternet.edu/catalog/metacat?action=read&amp;qformat=</xsl:text>
291
                        	<xsl:value-of select="$qformat"/>
292
                          <xsl:text>&amp;docid=</xsl:text>
293
                          <xsl:value-of select="$docID"/> -->
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:when>
300
                    <xsl:otherwise>
301
                         <!-- 
302
                         else, assume the url content is the just name of a metacat table -->
303
                       <xsl:variable name="URL1">
304
                          <xsl:text>@systemidserver@@servlet-path@?action=read&amp;qformat=</xsl:text>
305
                           <xsl:value-of select="$qformat"/>
306
                           <xsl:text>&amp;docid=</xsl:text>
307
                           <xsl:value-of select="$URL"/>
308
                       </xsl:variable>
309
                       <xsl:call-template name="data_use_agreement_form">
310
                            <xsl:with-param name="entity_name" select="$entity_name"/>
311
                            <xsl:with-param name="URL1" select="$URL1"/>
312
                       </xsl:call-template>
313
                    </xsl:otherwise>                
314
                  </xsl:choose>
315
                  </xsl:for-each>                 
316
                </td>             
317
  
318
								
319
								
320
								
321
	               <!-- 
322
								 
323
                   if editing is turned on, add some buttons -->
324
                <xsl:if test="$enableediting = 'true'">
325
                <td>
326
                <xsl:attribute name="class">
327
                  <xsl:choose>
328
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
329
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
330
                  </xsl:choose>
331
                </xsl:attribute>
332
          
333
                  <form action="@servlet-path@" method="POST">
334
                    <input type="hidden" name="action" value="read"/>
335
               <input type="hidden" name="qformat" value="{$qformat}"/>
336
                 <input type="hidden" name="sessionid"  value="{$sessid}"/>
337
                    <input type="hidden" name="docid">
338
                    <xsl:attribute name="value">
339
                 <xsl:value-of select="./docid"/>
340
                    </xsl:attribute>
341
                    </input>
342
                    <center>
343
                    <input type="SUBMIT"  value=" View " name="View">
344
               </input>
345
                    </center>
346
                  </form>
347
              <form action="@cgi-prefix@/register-dataset.cgi" 
348
                    method="POST">
349
                    <input type="hidden" name="stage" value="modify"/>  
350
                   <input type="hidden" name="cfg" value="{$qformat}"/>
351
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
352
                <input type="hidden" name="docid">
353
                  <xsl:attribute name="value">
354
                    <xsl:value-of select="./docid"/>
355
                  </xsl:attribute>
356
                </input>
357
                    <input type="SUBMIT"  value=" Edit " name="Edit">
358
                 </input>
359
                  </form>
360
              <form action="@cgi-prefix@/register-dataset.cgi" 
361
                    method="POST">
362
                    <input type="hidden" name="stage" value="delete"/>  
363
                   <input type="hidden" name="cfg" value="{$qformat}"/>
364
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
365
                <input type="hidden" name="docid">
366
                  <xsl:attribute name="value">
367
                    <xsl:value-of select="./docid"/>
368
                  </xsl:attribute>
369
                </input>
370
                    <input type="submit"  value="Delete" name="Delete">
371
                 </input>
372
                  </form>
373
                </td>    
374
                </xsl:if>
375
                </tr>
376
             </xsl:for-each>
377
             </table>
378
           </xsl:if>
379

    
380
         </div>  <!-- end data-catalog-area -->
381
        </div>
382
        <!-- end content area -->
383

    
384
        <!-- begin the right sidebar area -->
385
        <xsl:call-template name="page_rightsidebar" />
386
        <!-- end the right sidebar area -->
387

    
388
        <!-- begin the footer area -->
389
        <xsl:call-template name="pagefooter" />
390
        <!-- end the footer area -->
391

    
392
      </body>
393
    </html>
394
  </xsl:template>
395
  <!-- 
396

    
397

    
398
  template to display data use agreement form. 
399
  mob, 2006-05-01 -->
400
  <xsl:template name="data_use_agreement_form">
401
      <xsl:param name="entity_name"/>
402
      <xsl:param name="URL1"/>
403
      <!-- create form to pass url and entity's name to cgi with data agreement page. form name must be unique/dynamic -->
404
      <form action="@cgi-prefix@/data-use-agreement.cgi" method="POST"> 
405
      <!-- <form action="http://sbcdata.lternet.edu/cgi-bin/data-use-agreement.cgi" method="POST">      -->
406
      	<xsl:attribute name="name">
407
		<xsl:value-of select="translate($entity_name,',:()-. ' ,'')" />
408
        </xsl:attribute>
409
        <input type="hidden" name="qformat" />
410
        <input type="hidden" name="sessionid" />
411
        <xsl:if test="$enableediting = 'true'">
412
		<input type="hidden" name="enableediting" value="{$enableediting}"/>
413
        </xsl:if>
414
	<input type="hidden" name="url">
415
		<xsl:attribute name="value">
416
              	 	<xsl:value-of select="$URL1"/>
417
              	</xsl:attribute>
418
        </input>   
419
        <input type="hidden" name="entityName">
420
             <xsl:attribute name="value">
421
               <xsl:value-of select="$entity_name"/>
422
             </xsl:attribute>
423
        </input>
424
        <a>      
425
        	<xsl:attribute name="href">javascript:view_entity(document.<xsl:value-of select="translate($entity_name,',:()-. ' ,'')" />)</xsl:attribute>
426
		<xsl:value-of select="$entity_name"/>     <!-- the entity name forms the anchor text --> 
427
	 </a>                           
428
	 <br/>                     
429
    </form>
430
  </xsl:template>
431
</xsl:stylesheet>
(12-12/14)