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
  <xsl:param name="cgi-url" select='string("")'/>
33
  <xsl:param name="contextURL"/>
34
  <!-- This parameter gets overidden by the chosen default qformat -->
35
  <xsl:param name="qformat">default</xsl:param>
36
  <xsl:param name="servletURL"/>
37

    
38
  <!-- import the header, footer, and sidebars for customized styling -->
39
  <xsl:import href="{$contextURL}/style/skins/sbclter/templates/xsl/pageheader.xsl"/>
40
  <xsl:import href="{$contextURL}/style/skins/sbclter/templates/xsl/pagefooter.xsl"/>
41
  <xsl:import href="{$contextURL}/style/skins/sbclter/templates/xsl/page_leftsidebar.xsl"/>
42
  <xsl:import href="{$contextURL}/style/skins/sbclter/templates/xsl/page_rightsidebar.xsl"/>
43
  <xsl:import href="{$contextURL}/style/skins/sbclter/templates/xsl/loginbox.xsl"/>
44
  <xsl:import href="{$contextURL}/style/skins/sbclter/templates/xsl/searchbox.xsl"/>
45

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

    
51
  <xsl:param name="sessid"/>
52
  <xsl:param name="enableediting">false</xsl:param>
53
  <!-- This parameter gets overidden by the chosen default qformat -->
54
  <xsl:param name="qformat">default</xsl:param>
55

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

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

    
91
          <!-- begin login form area -->
92
          <xsl:call-template name="loginbox" />
93
          <!-- end login form area -->
94

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

    
100
          <!-- begin results section (XSLT generated) -->
101
          <div id="data-catalog-area">
102

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

    
121
            <!-- create the results table, and style each of the returnfield that
122
            were specified in the original query -->
123
            <table class="group group_border">
124
              <tr>
125
    
126

    
127
              <!-- create links to each of the associated raw data entities -->
128
                <td>
129
                <xsl:attribute name="class">
130
                  <xsl:choose>
131
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
132
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
133
                  </xsl:choose>
134
                </xsl:attribute>
135
                <!-- take each entity name and link it to the physical object url-->
136
		<xsl:for-each select="./param[@name='dataTable/entityName']">
137
                  <a>
138
                  <xsl:variable name="URL"
139
                    select="following-sibling::param[@name='dataTable/physical/distribution/online/url']" />
140

    
141
                    <xsl:choose>
142
                      <!-- if contents is a url to external data table -->
143
                      <xsl:when test="starts-with($URL,'http')">
144
                        <xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
145
                      </xsl:when>
146

    
147
                      <!-- strip out the ecogrid:// syntax if it's there, and the rest is in metacat -->
148
                      <xsl:when test="starts-with($URL,'ecogrid')">
149
                        <xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
150
                        <xsl:variable name="docID" select="substring-after($URL1, '/')"/>
151
                        <xsl:attribute name="href">
152
                          <!-- this needs to be on one line ... -->
153
                          <xsl:text>{$servletURL}?action=read&amp;qformat=sbclter&amp;docid=</xsl:text><xsl:value-of select="$docID"/>
154
                        </xsl:attribute>
155
                      </xsl:when>
156
                      
157
                      <!-- otherwise, assume the url field names a metacat table -->
158
                      <xsl:otherwise>
159
                        <xsl:attribute name="href">
160
                          <!-- this needs to be on one line -->
161
                          <xsl:text>{$servletURL}?action=read&amp;qformat=sbclter&amp;docid=</xsl:text><xsl:value-of select="$URL"/>
162
                        </xsl:attribute>
163
                      </xsl:otherwise>
164
                    </xsl:choose>
165

    
166
                  <!-- show the entityName value as the link -->
167
                  <xsl:value-of select="." />
168
                  </a>
169
                  <br />
170
                  </xsl:for-each>
171
                </td>
172
              
173
                <xsl:if test="$enableediting = 'true'">
174
                <td>
175
                <xsl:attribute name="class">
176
                  <xsl:choose>
177
                    <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
178
                    <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
179
                  </xsl:choose>
180
                </xsl:attribute>
181
          
182
                  <form action="{$servletURL}" method="POST">
183
                    <input type="hidden" name="action" value="read"/>
184
               <input type="hidden" name="qformat" value="sbclter"/>
185
                 <input type="hidden" name="sessionid"  value="{$sessid}"/>
186
                    <input type="hidden" name="docid">
187
                    <xsl:attribute name="value">
188
                 <xsl:value-of select="./docid"/>
189
                    </xsl:attribute>
190
                    </input>
191
                    <center>
192
                    <input type="SUBMIT"  value=" View " name="View">
193
               </input>
194
                    </center>
195
                  </form>
196
              <form action="{$cgi-url}/register-dataset.cgi" 
197
                    method="POST">
198
                    <input type="hidden" name="stage" value="modify"/>  
199
                   <input type="hidden" name="cfg" value="sbclter"/>
200
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
201
                <input type="hidden" name="docid">
202
                  <xsl:attribute name="value">
203
                    <xsl:value-of select="./docid"/>
204
                  </xsl:attribute>
205
                </input>
206
                    <input type="SUBMIT"  value=" Edit " name="Edit">
207
                 </input>
208
                  </form>
209
              <form action="{$cgi-url}/register-dataset.cgi" 
210
                    method="POST">
211
                    <input type="hidden" name="stage" value="delete"/>  
212
                   <input type="hidden" name="cfg" value="sbclter"/>
213
                   <input type="hidden" name="sessionid"  value="{$sessid}"/>
214
                <input type="hidden" name="docid">
215
                  <xsl:attribute name="value">
216
                    <xsl:value-of select="./docid"/>
217
                  </xsl:attribute>
218
                </input>
219
                    <input type="submit"  value="Delete" name="Delete">
220
                 </input>
221
                  </form>
222
                </td>    
223
                </xsl:if>
224
                </tr>
225
             </xsl:for-each>
226
             </table>
227
           </xsl:if>
228

    
229
         </div>  <!-- end data-catalog-area -->
230
        </div>
231
        <!-- end content area -->
232

    
233
        <!-- begin the right sidebar area -->
234
        <xsl:call-template name="page_rightsidebar" />
235
        <!-- end the right sidebar area -->
236

    
237
        <!-- begin the footer area -->
238
        <xsl:call-template name="pagefooter" />
239
        <!-- end the footer area -->
240

    
241
      </body>
242
    </html>
243
  </xsl:template>
244

    
245
</xsl:stylesheet>
(1-1/10)