Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
*  '$RCSfile$'
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$'
10
*     '$Date$'
11
* '$Revision$'
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="./pageheader.xsl"/>
35
  <xsl:import href="./pagefooter.xsl"/>
36
  <xsl:import href="./page_leftsidebar.xsl"/>
37
  <xsl:import href="./page_rightsidebar.xsl"/>
38
  <xsl:import href="./loginbox.xsl"/>
39
  <xsl:import href="./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="cgi-prefix"/>
47
  <xsl:param name="sessid"/>
48
  <xsl:param name="enableediting">false</xsl:param>
49
  <xsl:param name="contextURL"/>
50
  <!-- This parameter gets overidden by the chosen default qformat -->
51
  <xsl:param name="qformat">default</xsl:param>
52
  <xsl:param name="servletURL"/>
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="{$contextURL}/style/skins/{$qformat}/{$qformat}.css" />
60
        <script language="Javascript" type="text/JavaScript"
61
          src="{$contextURL}/style/skins/{$qformat}/{$qformat}.js" />
62
        <script language="Javascript" type="text/JavaScript"
63
          src="{$contextURL}/style/common/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
      </head>
75

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

    
88
          <!-- begin login form area -->
89
          <xsl:call-template name="loginbox" />
90
          <!-- end login form area -->
91

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

    
96
          <!-- begin results section (XSLT generated) -->
97

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

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

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

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

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

    
238
              <!-- create links to each of the associated raw data entities -->
239
                <td>
240
                <xsl:attribute name="class">
241
                  <xsl:choose>
242
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
243
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
244
                  </xsl:choose>
245
                </xsl:attribute>
246
                  <!-- take each entity name and link it to the physical object url-->
247
                  <xsl:for-each select="./param[@name='dataTable/entityName']">
248
                  <a>
249
                  <xsl:variable name="URL"
250
                    select="following-sibling::param[@name='dataTable/physical/distribution/online/url']" />
251
                    <!-- strip out the ecogrid:// syntax if it's there -->
252
                    <xsl:choose>
253
                      <xsl:when test="starts-with($URL,'ecogrid')">
254
                        <xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
255
                        <xsl:variable name="docID" select="substring-after($URL1, '/')"/>
256
                        <xsl:attribute name="href">
257
                          <!-- this needs to be on one line ... -->
258
                          <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"/>
259
                        </xsl:attribute>
260
                      </xsl:when>
261
                      <xsl:otherwise>
262
                        <xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
263
                      </xsl:otherwise>
264
                    </xsl:choose>
265
                  <!-- show the entityName value as the link -->
266
                  <xsl:value-of select="." />
267
                  </a>
268
                  <br />
269
                  </xsl:for-each>
270
                </td>
271
              
272
                <xsl:if test="$enableediting = 'true'">
273
                <td>
274
                <xsl:attribute name="class">
275
                  <xsl:choose>
276
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
277
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
278
                  </xsl:choose>
279
                </xsl:attribute>
280
          
281
                  <form action="{$servletURL}" method="POST">
282
                    <input type="hidden" name="action" value="read"/>
283
               <input type="hidden" name="qformat" value="{$qformat}"/>
284
                 <input type="hidden" name="sessionid"  value="{$sessid}"/>
285
                    <input type="hidden" name="docid">
286
                    <xsl:attribute name="value">
287
                 <xsl:value-of select="./docid"/>
288
                    </xsl:attribute>
289
                    </input>
290
                    <center>
291
                    <input type="SUBMIT"  value=" View " name="View">
292
               </input>
293
                    </center>
294
                  </form>
295
              <form action="{$cgi-prefix}/register-dataset.cgi" 
296
                    method="POST">
297
                    <input type="hidden" name="stage" value="modify"/>  
298
                   <input type="hidden" name="cfg" value="{$qformat}"/>
299
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
300
                <input type="hidden" name="docid">
301
                  <xsl:attribute name="value">
302
                    <xsl:value-of select="./docid"/>
303
                  </xsl:attribute>
304
                </input>
305
                    <input type="SUBMIT"  value=" Edit " name="Edit">
306
                 </input>
307
                  </form>
308
              <form action="{$cgi-prefix}/register-dataset.cgi" 
309
                    method="POST">
310
                    <input type="hidden" name="stage" value="delete"/>  
311
                   <input type="hidden" name="cfg" value="{$qformat}"/>
312
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
313
                <input type="hidden" name="docid">
314
                  <xsl:attribute name="value">
315
                    <xsl:value-of select="./docid"/>
316
                  </xsl:attribute>
317
                </input>
318
                    <input type="submit"  value="Delete" name="Delete">
319
                 </input>
320
                  </form>
321
                </td>    
322
                </xsl:if>
323
                </tr>
324
             </xsl:for-each>
325
             </table>
326
           </xsl:if>
327

    
328
        </div>
329
        <!-- end content area -->
330

    
331
        <!-- begin the right sidebar area -->
332
        <xsl:call-template name="page_rightsidebar" />
333
        <!-- end the right sidebar area -->
334

    
335
        <!-- begin the footer area -->
336
        <xsl:call-template name="pagefooter" />
337
        <!-- end the footer area -->
338

    
339
      </body>
340
    </html>
341
  </xsl:template>
342

    
343
</xsl:stylesheet>
(6-6/7)