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
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
32

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

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

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

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

    
84
      <body>
85
        <!-- begin the header area -->
86
        <xsl:call-template name="pageheader" />
87
        <!-- end the header area -->
88
   
89
        <!-- begin the left sidebar area -->
90
        <xsl:call-template name="page_leftsidebar" />
91
        <!-- end the left sidebar area -->
92
   
93
        <!-- begin the content area -->
94
        <div id="content">
95

    
96
          <!-- begin login form area -->
97
          <xsl:call-template name="loginbox" />
98
          <!-- end login form area -->
99

    
100
          <!-- begin search form area -->
101
          <xsl:call-template name="searchbox" />
102
          <!-- end search form area --> 
103
         
104

    
105
          <!-- begin results section (XSLT generated) -->
106
          <div id="data-catalog-area">
107

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

    
126
            <!-- create the results table, and style each of the returnfield that
127
            were specified in the original query -->
128
            <table class="group group_border">
129
              <tr>
130
                <th class="wide_column">Title (FROM THE MOB CONTEXT)</th>
131
                <th>Principal Investigators</th>
132
                <!-- <th>Organization</th> -->
133
                <th>Data Tables (no metadata)</th>
134
                <xsl:if test="$enableediting = 'true'">
135
                  <th>Actions</th>
136
                </xsl:if>
137
              </tr>
138
          
139
            <xsl:for-each select="resultset/document">
140
              <xsl:sort select="./param[@name='dataset/title']"/>
141
              <tr>
142
                <td>
143
                <xsl:attribute name="class">
144
                  <xsl:choose>
145
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
146
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
147
                  </xsl:choose>
148
                </xsl:attribute>
149
          
150
                  <!--
151
                  Build a submit form to view the data package details, using hidden
152
                  fields to POST the query values.
153
                  --> 
154
                  <form action="@servlet-path@" method="POST">
155
              <xsl:attribute name="name">
156
                <xsl:value-of select="translate(./docid, '()-.', '')" />
157
              </xsl:attribute>
158
                    <input type="hidden" name="qformat" />
159
                    <input type="hidden" name="sessionid" />
160
              <xsl:if test="$enableediting = 'true'">
161
                <input type="hidden" name="enableediting" value="{$enableediting}"/>
162
              </xsl:if>
163
                    <input type="hidden" name="action" value="read"/>
164
                    <input type="hidden" name="docid">
165
                <xsl:attribute name="value">
166
                  <xsl:value-of select="./docid"/>
167
                </xsl:attribute>
168
                    </input>
169
              <xsl:for-each select="./relation">
170
                <input type="hidden" name="docid">
171
                  <xsl:attribute name="value" >
172
                    <xsl:value-of select="./relationdoc" />
173
                  </xsl:attribute>
174
                </input>
175
              </xsl:for-each>
176

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

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

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

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

    
250
              <!-- create links to each of the associated raw data entities -->
251
              
252
                <td>
253
                <xsl:attribute name="class">
254
                  <xsl:choose>
255
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
256
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
257
                  </xsl:choose>
258
                </xsl:attribute>
259
                  <!-- take each entity name and link it to the physical object url-->
260
                  <!-- put link in a variable to be be passed to the data agreement page first -->
261
                  
262
                  <xsl:for-each select="./param[@name='dataTable/entityName']">
263
                  <a>
264
                  <xsl:variable name="URL"
265
                    select="following-sibling::param[@name='dataTable/physical/distribution/online/url']" />
266

    
267
                    <xsl:choose>
268
                      <!-- if contents is a url to external data table -->
269
                      <xsl:when test="starts-with($URL,'http')">
270
                        <xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
271
                      </xsl:when>
272

    
273
                      <!-- strip out the ecogrid:// syntax if it's there, and the rest is in metacat -->
274
                      <xsl:when test="starts-with($URL,'ecogrid')">
275
                        <xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
276
                        <xsl:variable name="docID" select="substring-after($URL1, '/')"/>
277
                        <xsl:attribute name="href">
278
                          <!-- this needs to be on one line ... -->
279
                          <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"/>
280
                        </xsl:attribute>
281
                      </xsl:when>
282
                      
283
                      <!-- otherwise, assume the url field names a metacat table -->
284
                      <xsl:otherwise>
285
                        <xsl:attribute name="href">
286
                          <!-- this needs to be on one line -->
287
                          <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="$URL"/>
288
                        </xsl:attribute>
289
                      </xsl:otherwise>
290
                    </xsl:choose>
291

    
292
                  <!-- show the entityName value as the link -->
293
                  <xsl:value-of select="." />
294
                  </a>
295
                  <br />
296
                  </xsl:for-each>
297
                </td>
298
              
299
                <xsl:if test="$enableediting = 'true'">
300
                <td>
301
                <xsl:attribute name="class">
302
                  <xsl:choose>
303
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
304
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
305
                  </xsl:choose>
306
                </xsl:attribute>
307
          
308
                  <form action="@servlet-path@" method="POST">
309
                    <input type="hidden" name="action" value="read"/>
310
               <input type="hidden" name="qformat" value="{$qformat}"/>
311
                 <input type="hidden" name="sessionid"  value="{$sessid}"/>
312
                    <input type="hidden" name="docid">
313
                    <xsl:attribute name="value">
314
                 <xsl:value-of select="./docid"/>
315
                    </xsl:attribute>
316
                    </input>
317
                    <center>
318
                    <input type="SUBMIT"  value=" View " name="View">
319
               </input>
320
                    </center>
321
                  </form>
322
              <form action="@cgi-prefix@/register-dataset.cgi" 
323
                    method="POST">
324
                    <input type="hidden" name="stage" value="modify"/>  
325
                   <input type="hidden" name="cfg" value="{$qformat}"/>
326
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
327
                <input type="hidden" name="docid">
328
                  <xsl:attribute name="value">
329
                    <xsl:value-of select="./docid"/>
330
                  </xsl:attribute>
331
                </input>
332
                    <input type="SUBMIT"  value=" Edit " name="Edit">
333
                 </input>
334
                  </form>
335
              <form action="@cgi-prefix@/register-dataset.cgi" 
336
                    method="POST">
337
                    <input type="hidden" name="stage" value="delete"/>  
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="Delete" name="Delete">
346
                 </input>
347
                  </form>
348
                </td>    
349
                </xsl:if>
350
                </tr>
351
             </xsl:for-each>
352
             </table>
353
           </xsl:if>
354

    
355
         </div>  <!-- end data-catalog-area -->
356
        </div>
357
        <!-- end content area -->
358

    
359
        <!-- begin the right sidebar area -->
360
        <xsl:call-template name="page_rightsidebar" />
361
        <!-- end the right sidebar area -->
362

    
363
        <!-- begin the footer area -->
364
        <xsl:call-template name="pagefooter" />
365
        <!-- end the footer area -->
366

    
367
      </body>
368
    </html>
369
  </xsl:template>
370
  <xsl:template name="data_use_agreement_form">
371
      <xsl:param name="entity_name"/>
372
      <xsl:param name="URL1"/>
373
         <!-- create form to pass url to data agreement page with the entity's name and url sent along as param. form name must be unique/dynamic -->
374
           <!-- <form action="@cgi-prefix@/" method="POST"> -->
375
      <form action="http://sbcdata.lternet.edu/cgi-bin/data-use-agreement.cgi" method="POST">    
376
      	<xsl:attribute name="name">
377
					<xsl:value-of select="translate($entity_name,'()-.' ,'')" />
378
        </xsl:attribute>
379
        <input type="hidden" name="qformat" />
380
        <input type="hidden" name="sessionid" />
381
        <xsl:if test="$enableediting = 'true'">
382
						<input type="hidden" name="enableediting" 		value="{$enableediting}"/>
383
        </xsl:if>
384
				<input type="hidden" name="url">
385
							<xsl:attribute name="value">
386
              	 	<xsl:value-of select="$URL1"/>
387
              	</xsl:attribute>
388
        </input>   
389
        <input type="hidden" name="entityName">
390
             <xsl:attribute name="value">
391
               <xsl:value-of select="$entity_name"/>
392
             </xsl:attribute>
393
        </input>
394
        <a>      
395
        		<xsl:attribute name="href">javascript:view_entity(document.<xsl:value-of select="translate($entity_name,'()-.' ,'')" />)</xsl:attribute>
396
						<xsl:value-of select="$entity_name"/>     <!-- the entity name forms the anchor text --> 
397
			 </a>                           
398
			 <br/>                     
399
    </form>
400
  </xsl:template>
401
</xsl:stylesheet>
(11-11/14)