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

    
73
      <body>
74
        <!-- begin the header area -->
75
        <xsl:call-template name="pageheader" />
76
        <!-- end the header area -->
77
   
78
        <!-- begin the left sidebar area -->
79
        <xsl:call-template name="page_leftsidebar" />
80
        <!-- end the left sidebar area -->
81
   
82
        <!-- begin the content area -->
83
        <div id="content">
84

    
85
          <!-- begin login form area -->
86
          <xsl:call-template name="loginbox" />
87
          <!-- end login form area -->
88

    
89
          <!-- begin search form area -->
90
          <xsl:call-template name="searchbox" />
91
          <!-- end search form area --> 
92
         
93

    
94
          <!-- begin results section (XSLT generated) -->
95
          <div id="data-catalog-area">
96

    
97
          <!-- State how many package hits were returned -->
98
          <xsl:choose>
99
            <xsl:when test="count(resultset/document)=1">
100
              <p>
101
              <xsl:number value="count(resultset/document)" /> data package found:
102
              </p>
103
            </xsl:when>
104
            <xsl:otherwise>
105
              <p>
106
              <xsl:number value="count(resultset/document)" /> data packages found:
107
              </p>
108
            </xsl:otherwise>
109
          </xsl:choose>
110
          
111
          <!-- This tests to see if there are returned documents,
112
          if there are not then don't show the query results -->
113
          <xsl:if test="count(resultset/document) &gt; 0">
114

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

    
166
              <!-- Create the link on the title column -->
167
              <a>
168
                <xsl:attribute name="href">javascript:submitform('read',document.<xsl:value-of select="translate(./docid, '()-.', '')"/>)</xsl:attribute>
169
                <xsl:choose>
170
                  <xsl:when test="./param[@name='dataset/title']!=''">
171
               <xsl:value-of select="./param[@name='dataset/title']"/>
172
                  </xsl:when>
173
                  <xsl:otherwise>
174
                    <xsl:value-of select="./param[@name='citation/title']"/>
175
                    <xsl:value-of select="./param[@name='software/title']"/>
176
                    <xsl:value-of select="./param[@name='protocol/title']"/>
177
                  </xsl:otherwise>
178
                </xsl:choose>
179
              </a>
180

    
181
              <!-- Include the docid in the title output -->
182
              <xsl:text>(</xsl:text>
183
                <xsl:value-of select="./docid"/>
184
              <xsl:text>)</xsl:text>
185
                  </form>
186
                </td>
187
          
188
              <!-- style the contacts returned -->
189
                <td>
190
                <xsl:attribute name="class">
191
                  <xsl:choose>
192
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
193
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
194
                  </xsl:choose>
195
                </xsl:attribute>
196
          
197
                  <xsl:for-each select="./param[@name='originator/individualName/surName']" >
198
              <xsl:value-of select="." />
199
                  <br />
200
             </xsl:for-each>
201
                  <xsl:for-each select="./param[@name='creator/individualName/surName']" >
202
              <xsl:value-of select="." />
203
                  <br />
204
                  </xsl:for-each>
205
                </td>
206

    
207
              <!-- style the contacts returned -->
208
                <td>
209
                <xsl:attribute name="class">
210
                  <xsl:choose>
211
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
212
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
213
                  </xsl:choose>
214
                </xsl:attribute>
215
          
216
              <xsl:value-of select="./param[@name='originator/organizationName']" />
217
              <xsl:value-of select="./param[@name='creator/organizationName']" />
218
                </td>
219
          
220
              <!-- style the keywords returned -->
221
              <!--
222
                <td>
223
                <xsl:attribute name="class">
224
                  <xsl:choose>
225
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
226
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
227
                  </xsl:choose>
228
                </xsl:attribute>
229
          
230
                  <xsl:for-each select="./param[@name='keyword']">
231
                  <xsl:value-of select="." />
232
                  <br />
233
                  </xsl:for-each>
234
                </td>
235
              -->
236

    
237
              <!-- create links to each of the associated raw data entities -->
238
                <td>
239
                <xsl:attribute name="class">
240
                  <xsl:choose>
241
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
242
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
243
                  </xsl:choose>
244
                </xsl:attribute>
245
                  <!-- take each entity name and link it to the physical object url-->
246
                  <xsl:for-each select="./param[@name='dataTable/entityName']">
247
                  <a>
248
                  <xsl:variable name="URL"
249
                    select="following-sibling::param[@name='dataTable/physical/distribution/online/url']" />
250

    
251
                    <xsl:choose>
252
                      <!-- if contents is a url to external data table -->
253
                      <xsl:when test="starts-with($URL,'http')">
254
                        <xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
255
                      </xsl:when>
256

    
257
                      <!-- strip out the ecogrid:// syntax if it's there, and the rest is in metacat -->
258
                      <xsl:when test="starts-with($URL,'ecogrid')">
259
                        <xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
260
                        <xsl:variable name="docID" select="substring-after($URL1, '/')"/>
261
                        <xsl:attribute name="href">
262
                          <!-- this needs to be on one line ... -->
263
                          <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"/>
264
                        </xsl:attribute>
265
                      </xsl:when>
266
                      
267
                      <!-- otherwise, assume the url field names a metacat table -->
268
                      <xsl:otherwise>
269
                        <xsl:attribute name="href">
270
                          <!-- this needs to be on one line -->
271
                          <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"/>
272
                        </xsl:attribute>
273
                      </xsl:otherwise>
274
                    </xsl:choose>
275

    
276
                  <!-- show the entityName value as the link -->
277
                  <xsl:value-of select="." />
278
                  </a>
279
                  <br />
280
                  </xsl:for-each>
281
                </td>
282
              
283
                <xsl:if test="$enableediting = 'true'">
284
                <td>
285
                <xsl:attribute name="class">
286
                  <xsl:choose>
287
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
288
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
289
                  </xsl:choose>
290
                </xsl:attribute>
291
          
292
                  <form action="@servlet-path@" method="POST">
293
                    <input type="hidden" name="action" value="read"/>
294
               <input type="hidden" name="qformat" value="{$qformat}"/>
295
                 <input type="hidden" name="sessionid"  value="{$sessid}"/>
296
                    <input type="hidden" name="docid">
297
                    <xsl:attribute name="value">
298
                 <xsl:value-of select="./docid"/>
299
                    </xsl:attribute>
300
                    </input>
301
                    <center>
302
                    <input type="SUBMIT"  value=" View " name="View">
303
               </input>
304
                    </center>
305
                  </form>
306
              <form action="@cgi-prefix@/register-dataset.cgi" 
307
                    method="POST">
308
                    <input type="hidden" name="stage" value="modify"/>  
309
                   <input type="hidden" name="cfg" value="{$qformat}"/>
310
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
311
                <input type="hidden" name="docid">
312
                  <xsl:attribute name="value">
313
                    <xsl:value-of select="./docid"/>
314
                  </xsl:attribute>
315
                </input>
316
                    <input type="SUBMIT"  value=" Edit " name="Edit">
317
                 </input>
318
                  </form>
319
              <form action="@cgi-prefix@/register-dataset.cgi" 
320
                    method="POST">
321
                    <input type="hidden" name="stage" value="delete"/>  
322
                   <input type="hidden" name="cfg" value="{$qformat}"/>
323
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
324
                <input type="hidden" name="docid">
325
                  <xsl:attribute name="value">
326
                    <xsl:value-of select="./docid"/>
327
                  </xsl:attribute>
328
                </input>
329
                    <input type="submit"  value="Delete" name="Delete">
330
                 </input>
331
                  </form>
332
                </td>    
333
                </xsl:if>
334
                </tr>
335
             </xsl:for-each>
336
             </table>
337
           </xsl:if>
338

    
339
         </div>  <!-- end data-catalog-area -->
340
        </div>
341
        <!-- end content area -->
342

    
343
        <!-- begin the right sidebar area -->
344
        <xsl:call-template name="page_rightsidebar" />
345
        <!-- end the right sidebar area -->
346

    
347
        <!-- begin the footer area -->
348
        <xsl:call-template name="pagefooter" />
349
        <!-- end the footer area -->
350

    
351
      </body>
352
    </html>
353
  </xsl:template>
354

    
355
</xsl:stylesheet>
(9-9/14)