Project

General

Profile

1 4823 daigle
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile$'
4
  *      Authors: Matthew Brooke
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: 2006-11-17 13:37:07 -0800 (Fri, 17 Nov 2006) $'
11
  * '$Revision: 3094 $'
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 that is valid with respect to the eml-variable.dtd
29
  * module of the Ecological Metadata Language (EML) into an HTML format
30
  * suitable for rendering with modern web browsers.
31
-->
32
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33
  <xsl:import href="eml-text.xsl" />
34
  <xsl:output method="html" encoding="iso-8859-1"
35
              doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
36
              doctype-system="http://www.w3.org/TR/html4/loose.dtd"
37
              indent="yes" />
38
39
40
<!-- This module is for distribution and it is self-contained-->
41
42
  <xsl:template name="distribution">
43
      <xsl:param name="disfirstColStyle"/>
44
      <xsl:param name="dissubHeaderStyle"/>
45
      <xsl:param name="docid"/>
46
      <xsl:param name="level">entitylevel</xsl:param>
47
      <xsl:param name="entitytype"/>
48
      <xsl:param name="entityindex"/>
49
      <xsl:param name="physicalindex"/>
50
      <xsl:param name="distributionindex"/>
51
      <table class="{$tabledefaultStyle}">
52
       <xsl:choose>
53
         <xsl:when test="references!=''">
54
          <xsl:variable name="ref_id" select="references"/>
55
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
56
          <xsl:for-each select="$references">
57
            <xsl:apply-templates select="online">
58
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
59
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
60
            </xsl:apply-templates>
61
            <xsl:apply-templates select="offline">
62
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
63
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
64
            </xsl:apply-templates>
65
            <xsl:apply-templates select="inline">
66
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
67
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
68
               <xsl:with-param name="docid" select="$docid"/>
69
               <xsl:with-param name="level" select="$level"/>
70
               <xsl:with-param name="entitytype" select="$entitytype"/>
71
               <xsl:with-param name="entityindex" select="$entityindex"/>
72
               <xsl:with-param name="physicalindex" select="$physicalindex"/>
73
               <xsl:with-param name="distributionindex" select="$distributionindex"/>
74
             </xsl:apply-templates>
75
          </xsl:for-each>
76
        </xsl:when>
77
        <xsl:otherwise>
78
            <xsl:apply-templates select="online">
79
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
80
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
81
            </xsl:apply-templates>
82
            <xsl:apply-templates select="offline">
83
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
84
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
85
            </xsl:apply-templates>
86
            <xsl:apply-templates select="inline">
87
              <xsl:with-param name="dissubHeaderStyle" select="$dissubHeaderStyle"/>
88
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
89
               <xsl:with-param name="docid" select="$docid"/>
90
               <xsl:with-param name="level" select="$level"/>
91
               <xsl:with-param name="entitytype" select="$entitytype"/>
92
               <xsl:with-param name="entityindex" select="$entityindex"/>
93
               <xsl:with-param name="physicalindex" select="$physicalindex"/>
94
               <xsl:with-param name="distributionindex" select="$distributionindex"/>
95
            </xsl:apply-templates>
96
        </xsl:otherwise>
97
       </xsl:choose>
98
      </table>
99
  </xsl:template>
100
101
  <!-- ********************************************************************* -->
102
  <!-- *******************************  Online data  *********************** -->
103
  <!-- ********************************************************************* -->
104
  <xsl:template match="online">
105
    <xsl:param name="disfirstColStyle"/>
106
    <xsl:param name="dissubHeaderStyle"/>
107
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
108
        <xsl:text>Online Distribution Info:</xsl:text>
109
    </td></tr>
110
    <xsl:apply-templates select="url">
111
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
112
    </xsl:apply-templates>
113
    <xsl:apply-templates select="connection">
114
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
115
    </xsl:apply-templates>
116
    <xsl:apply-templates select="connectionDefinition">
117
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
118
    </xsl:apply-templates>
119
  </xsl:template>
120
121
  <xsl:template match="url">
122
    <xsl:param name="disfirstColStyle"/>
123
    <xsl:variable name="URL" select="."/>
124
    <tr>
125
      <td class="{$disfirstColStyle}">
126
        <xsl:text>&#160;</xsl:text>
127
      </td>
128
      <td class="{$secondColStyle}">
129
         <a>
130
           <xsl:choose>
131
           <xsl:when test="starts-with($URL,'ecogrid')">
132
		<xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
133
		<xsl:variable name="docID" select="substring-after($URL1, '/')"/>
134
		<xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docID"/></xsl:attribute>
135
           </xsl:when>
136
           <xsl:otherwise>
137
		<xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>
138
           </xsl:otherwise>
139
          </xsl:choose>
140
          <xsl:attribute name="target">_blank</xsl:attribute>
141
          <xsl:value-of select="."/>
142
        </a>
143 5702 leinfelder
        <!-- stats for hosted documents loaded with ajax call -->
144
        <xsl:if test="starts-with($URL,'ecogrid')">
145
			<xsl:variable name="URL1" select="substring-after($URL, 'ecogrid://')"/>
146
			<xsl:variable name="docID" select="substring-after($URL1, '/')"/>
147
			<xsl:variable name="divID" select="replace($docID, '.', '_')"/>
148
			<span>
149
          		<xsl:attribute name="id">
150
          			<xsl:value-of select="$divID" />
151
          		</xsl:attribute>
152
			</span>
153
			<script language="JavaScript">
154
				if (window.loadStats) {
155
					loadStats('<xsl:value-of select="$divID" />', '<xsl:value-of select="$docID" />', '<xsl:value-of select="$contextURL" />/metacat');
156
				}
157
			</script>
158
		</xsl:if>
159 4823 daigle
       </td>
160
    </tr>
161
  </xsl:template>
162
163
  <xsl:template match="connection">
164
    <xsl:param name="disfirstColStyle"/>
165
    <xsl:choose>
166
      <xsl:when test="references!=''">
167
        <xsl:variable name="ref_id" select="references"/>
168
        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
169
        <xsl:for-each select="$references">
170
          <xsl:call-template name="connectionCommon">
171
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
172
          </xsl:call-template>
173
        </xsl:for-each>
174
      </xsl:when>
175
      <xsl:otherwise>
176
        <xsl:call-template name="connectionCommon">
177
          <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
178
        </xsl:call-template>
179
      </xsl:otherwise>
180
    </xsl:choose>
181
  </xsl:template>
182
183
  <!-- A template shared by connection references and connection in line-->
184
  <xsl:template name="connectionCommon">
185
    <xsl:param name="disfirstColStyle"/>
186
    <xsl:if test="parameter">
187
      <tr>
188
        <td class="{$disfirstColStyle}">
189
          <xsl:text>Parameter(s):</xsl:text>
190
        </td>
191
        <td class="{$secondColStyle}"><xsl:text>&#160;</xsl:text>
192
        </td>
193
      </tr>
194
      <xsl:call-template name="renderParameters">
195
        <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
196
      </xsl:call-template>
197
    </xsl:if>
198
    <xsl:apply-templates select="connectionDefinition">
199
      <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
200
    </xsl:apply-templates>
201
  </xsl:template>
202
203
  <xsl:template name="renderParameters">
204
    <xsl:param name="disfirstColStyle"/>
205
    <xsl:for-each select="parameter" >
206
      <tr>
207
        <td class="{$disfirstColStyle}">
208
          <xsl:text>&#160;&#160;&#160;&#160;&#160;</xsl:text><xsl:value-of select="name" />
209
        </td>
210
        <td class="{$secondColStyle}">
211
         <xsl:value-of select="value" />
212
        </td>
213
      </tr>
214
    </xsl:for-each>
215
  </xsl:template>
216
217
   <xsl:template match="connectionDefinition">
218
    <xsl:param name="disfirstColStyle"/>
219
    <xsl:choose>
220
      <xsl:when test="references!=''">
221
        <xsl:variable name="ref_id" select="references"/>
222
        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
223
        <xsl:for-each select="$references">
224
          <xsl:call-template name="connectionDefinitionCommon">
225
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
226
          </xsl:call-template>
227
        </xsl:for-each>
228
      </xsl:when>
229
      <xsl:otherwise>
230
        <xsl:call-template name="connectionDefinitionCommon">
231
          <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle"/>
232
        </xsl:call-template>
233
      </xsl:otherwise>
234
    </xsl:choose>
235
   </xsl:template>
236
237
   <!-- This template will be shared by both reference and inline connectionDefinition-->
238
   <xsl:template name="connectionDefinitionCommon">
239
    <xsl:param name="disfirstColStyle"/>
240
      <tr>
241
          <td class="{$disfirstColStyle}">
242
            <xsl:text>Schema Name:</xsl:text>
243
          </td>
244
          <td class="{$secondColStyle}">
245
            <xsl:value-of select="schemeName" />
246
          </td>
247
       </tr>
248
       <tr>
249
          <td class="{$disfirstColStyle}">
250
            <xsl:text>Description:</xsl:text>
251
          </td>
252
          <td>
253
           <xsl:apply-templates select="description">
254
              <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
255
            </xsl:apply-templates>
256
          </td>
257
       </tr>
258
       <xsl:for-each select="parameterDefinition">
259
          <xsl:call-template name="renderParameterDefinition">
260
            <xsl:with-param name="disfirstColStyle" select="$disfirstColStyle" />
261
          </xsl:call-template>
262
       </xsl:for-each>
263
   </xsl:template>
264
265
   <xsl:template match="description">
266
     <xsl:param name="disfirstColStyle"/>
267
     <xsl:call-template name="text">
268
        <xsl:with-param name="textfirstColStyle" select="$secondColStyle" />
269
     </xsl:call-template>
270
   </xsl:template>
271
272
   <xsl:template name="renderParameterDefinition">
273
     <xsl:param name="disfirstColStyle"/>
274
     <tr>
275
        <td class="{$disfirstColStyle}">
276
          <xsl:text>&#160;&#160;&#160;&#160;&#160;</xsl:text><xsl:value-of select="name" /><xsl:text>:</xsl:text>
277
        </td>
278
        <td>
279
          <table class="{$tabledefaultStyle}">
280
            <tr>
281
              <td class="{$disfirstColStyle}">
282
                <xsl:choose>
283
                  <xsl:when test="defaultValue">
284
                    <xsl:value-of select="defaultValue" />
285
                  </xsl:when>
286
                  <xsl:otherwise>
287
                    &#160;
288
                  </xsl:otherwise>
289
                </xsl:choose>
290
291
              </td>
292
              <td class="{$secondColStyle}">
293
                <xsl:value-of select="definition" />
294
              </td>
295
            </tr>
296
          </table>
297
        </td>
298
      </tr>
299
   </xsl:template>
300
301
  <!-- ********************************************************************* -->
302
  <!-- *******************************  Offline data  ********************** -->
303
  <!-- ********************************************************************* -->
304
305
  <xsl:template match="offline">
306
    <xsl:param name="disfirstColStyle"/>
307
    <xsl:param name="dissubHeaderStyle"/>
308
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
309
        <xsl:text>Offline Distribution Info:</xsl:text>
310
    </td></tr>
311
    <xsl:if test="(mediumName) and normalize-space(mediumName)!=''">
312
      <tr><td class="{$disfirstColStyle}"><xsl:text>Medium:</xsl:text></td>
313
      <td class="{$secondColStyle}"><xsl:value-of select="mediumName"/></td></tr>
314
    </xsl:if>
315
    <xsl:if test="(mediumDensity) and normalize-space(mediumDensity)!=''">
316
    <tr><td class="{$disfirstColStyle}"><xsl:text>Medium Density:</xsl:text></td>
317
    <td class="{$secondColStyle}"><xsl:value-of select="mediumDensity"/>
318
    <xsl:if test="(mediumDensityUnits) and normalize-space(mediumDensityUnits)!=''">
319
    <xsl:text> (</xsl:text><xsl:value-of select="mediumDensityUnits"/><xsl:text>)</xsl:text>
320
    </xsl:if>
321
    </td></tr>
322
    </xsl:if>
323
    <xsl:if test="(mediumVol) and normalize-space(mediumVol)!=''">
324
    <tr><td class="{$disfirstColStyle}"><xsl:text>Volume:</xsl:text></td>
325
    <td class="{$secondColStyle}"><xsl:value-of select="mediumVol"/></td></tr>
326
    </xsl:if>
327
    <xsl:if test="(mediumFormat) and normalize-space(mediumFormat)!=''">
328
    <tr><td class="{$disfirstColStyle}"><xsl:text>Format:</xsl:text></td>
329
    <td class="{$secondColStyle}"><xsl:value-of select="mediumFormat"/></td></tr>
330
    </xsl:if>
331
    <xsl:if test="(mediumNote) and normalize-space(mediumNote)!=''">
332
    <tr><td class="{$disfirstColStyle}"><xsl:text>Notes:</xsl:text></td>
333
    <td class="{$secondColStyle}"><xsl:value-of select="mediumNote"/></td></tr>
334
    </xsl:if>
335
  </xsl:template>
336
337
  <!-- ********************************************************************* -->
338
  <!-- *******************************  Inline data  *********************** -->
339
  <!-- ********************************************************************* -->
340
341
342
  <xsl:template match="inline">
343
    <xsl:param name="disfirstColStyle"/>
344
    <xsl:param name="dissubHeaderStyle"/>
345
    <xsl:param name="docid"/>
346
    <xsl:param name="level">entity</xsl:param>
347
    <xsl:param name="entitytype"/>
348
    <xsl:param name="entityindex"/>
349
    <xsl:param name="physicalindex"/>
350
    <xsl:param name="distributionindex"/>
351
352
    <tr><td class="{$dissubHeaderStyle}" colspan="2">
353
        <xsl:text>Inline Data:</xsl:text>
354
    </td></tr>
355
    <tr><td class="{$disfirstColStyle}">
356
      <xsl:text>&#160;</xsl:text></td>
357
      <td class="{$secondColStyle}">
358
      <!-- for top top distribution-->
359
      <xsl:if test="$level='toplevel'">
360
        <a><xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&amp;displaymodule=inlinedata&amp;distributionlevel=<xsl:value-of select="$level"/>&amp;distributionindex=<xsl:value-of select="$distributionindex"/></xsl:attribute>
361
        <b>Inline Data</b></a>
362
      </xsl:if>
363
      <xsl:if test="$level='entitylevel'">
364
        <a><xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&amp;displaymodule=inlinedata&amp;distributionlevel=<xsl:value-of select="$level"/>&amp;entitytype=<xsl:value-of select="$entitytype"/>&amp;entityindex=<xsl:value-of select="$entityindex"/>&amp;physicalindex=<xsl:value-of select="$physicalindex"/>&amp;distributionindex=<xsl:value-of select="$distributionindex"/></xsl:attribute>
365
        <b>Inline Data</b></a>
366
      </xsl:if>
367
     </td></tr>
368
  </xsl:template>
369
370
371
</xsl:stylesheet>