-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcscdb.xsl
350 lines (279 loc) · 9.28 KB
/
cscdb.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet>
<!--*
* Convert an XML web page into an HTML one
*-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:extfuncs="http://hea-www.harvard.edu/~dburke/xsl/extfuncs"
extension-element-prefixes="exsl extfuncs">
<!--* Change this if the filename changes *-->
<xsl:variable name="hack-import-cscdb" select="extfuncs:register-import-dependency('cscdb.xsl')"/>
<xsl:output method="text"/>
<!--* we place this here to see if it works (was in header.xsl and wasn't working
* - and it seems to
*-->
<!--* a template to output a new line (useful after a comment) *-->
<xsl:template name="newline">
<xsl:text>
</xsl:text>
</xsl:template>
<!--* load in the set of "global" parameters *-->
<xsl:include href="globalparams.xsl"/>
<!--* include the stylesheets AFTER defining the variables *-->
<xsl:include href="helper.xsl"/>
<xsl:include href="links.xsl"/>
<xsl:include href="myhtml.xsl"/>
<!--*
* top level: create
* index.html
*
*-->
<xsl:template match="/">
<!--* check the params are okay *-->
<xsl:call-template name="is-site-valid"/>
<xsl:call-template name="check-param-ends-in-a-slash">
<xsl:with-param name="pname" select="'install'"/>
<xsl:with-param name="pvalue" select="$install"/>
</xsl:call-template>
<xsl:call-template name="check-param-ends-in-a-slash">
<xsl:with-param name="pname" select="'canonicalbase'"/>
<xsl:with-param name="pvalue" select="$canonicalbase"/>
</xsl:call-template>
<!--* what do we create *-->
<xsl:apply-templates select="cscdb"/>
<xsl:apply-templates select="cscdb" mode="alphabet"/>
</xsl:template> <!--* match=/ *-->
<!--*
* create: <page>.html
*-->
<xsl:template match="cscdb">
<xsl:variable name="filename"><xsl:value-of select="$install"/><xsl:value-of select="$pagename"/>.html</xsl:variable>
<!--* output filename to stdout *-->
<xsl:value-of select="$filename"/><xsl:call-template name="newline"/>
<!--* create document *-->
<xsl:document href="{$filename}" method="html" media-type="text/html"
doctype-system="about:legacy-compat"
version="5.0">
<!--* we start processing the XML file here *-->
<html lang="en-US">
<!--* make the HTML head node *-->
<xsl:call-template name="add-htmlhead-standard"/>
<!--
let's drop the navbar here
<xsl:call-template name="add-body-withnavbar">
-->
<xsl:call-template name="add-body-nonavbar">
<xsl:with-param name="contents">
<!--* add the intro text *-->
<xsl:if test="intro">
<xsl:apply-templates select="intro"/>
<!--// add links //-->
<span class="qlinkbar">Switch to:
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat($pagename,'_alpha.html')"/>
</xsl:attribute>
Columns listed alphabetically
</a>
</span>
<hr/>
</xsl:if>
<!--// start database column table //-->
<table id="dbtable" class="csctable">
<thead>
<tr>
<th>Context</th>
<th>Column Name</th>
<th>Type</th>
<th>Units</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="//objgrp">
<xsl:for-each select="group">
<xsl:variable name="rowcount"><xsl:value-of select="count(cols/col)"/></xsl:variable>
<tr id="{@id}">
<td rowspan="{$rowcount}" class="context">
<xsl:choose>
<xsl:when test="@link">
<xsl:variable name="grplink">
<xsl:value-of select="@link"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="@section">
<xsl:variable name="grpsection">
<xsl:value-of select="@section"/>
</xsl:variable>
<a class="grouptitle" href="{$grplink}.html#{$grpsection}">
<strong><xsl:value-of select="title"/></strong>
</a>
</xsl:when>
<xsl:otherwise>
<a class="grouptitle" href="{$grplink}.html">
<strong><xsl:value-of select="title"/></strong>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<span class="grouptitle"><strong><xsl:value-of select="title"/></strong></span>
</xsl:otherwise>
</xsl:choose>
</td>
<!--// if first row, don't include open "tr" tag //-->
<xsl:for-each select="cols/col">
<xsl:if test="position() = 1">
<xsl:call-template name="add-dbcols"/>
</xsl:if>
</xsl:for-each>
</tr>
<xsl:for-each select="cols/col">
<xsl:if test="position() != 1">
<tr>
<xsl:call-template name="add-dbcols"/>
</tr>
</xsl:if>
</xsl:for-each>
<xsl:if test="last()">
<tr><td colspan="5" class="separator"><hr/></td></tr>
</xsl:if>
</xsl:for-each> <!--// end select="group" //-->
</xsl:for-each> <!--// end select="objgroup" //-->
</tbody>
</table>
<!--// end database column table //-->
</xsl:with-param>
<!-- this is ignored now
<xsl:with-param name="navbar">
<xsl:call-template name="add-navbar">
<xsl:with-param name="name" select="info/navbar"/>
</xsl:call-template>
</xsl:with-param>
-->
<!-- uses default //info/breadcrumbs -->
<xsl:with-param name="location" select="$filename"/>
</xsl:call-template>
</html>
</xsl:document>
</xsl:template> <!--* match=cscdb *-->
<!--*
* create: <page>_alpha.html
*-->
<xsl:template match="cscdb" mode="alphabet">
<xsl:variable name="alphapagename"><xsl:value-of select="$pagename"/>_alpha</xsl:variable>
<xsl:variable name="filename"><xsl:value-of select="$install"/><xsl:value-of select="$alphapagename"/>.html</xsl:variable>
<!--* output filename to stdout *-->
<xsl:value-of select="$filename"/><xsl:call-template name="newline"/>
<!--* create document *-->
<xsl:document href="{$filename}" method="html" media-type="text/html"
doctype-system="about:legacy-compat"
version="5.0">
<!--* we start processing the XML file here *-->
<html lang="en-US">
<!--* make the HTML head node *-->
<xsl:call-template name="add-htmlhead-standard">
<xsl:with-param name="page" select="concat($alphapagename, '.html')"/>
</xsl:call-template>
<!--
let's drop the navbar here
<xsl:call-template name="add-body-withnavbar">
-->
<xsl:call-template name="add-body-nonavbar">
<xsl:with-param name="contents">
<!--* add the intro text *-->
<xsl:if test="intro">
<xsl:apply-templates select="intro"/>
<!--// add links //-->
<span class="qlinkbar">Switch to:
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat($pagename,'.html')"/>
</xsl:attribute>
Columns listed by Context
</a>
</span>
<hr/>
</xsl:if>
<!--// start database column table //-->
<table id="dbtable" class="csctable">
<thead>
<tr>
<th>Column Name</th>
<th>Type</th>
<th>Units</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="//objgrp/group/cols/col">
<xsl:sort select="@name"/>
<!--// don't include anything marked as '@hide="abc"' //-->
<xsl:if test="(contains(@hide,'abc') != true()) or (@hide != 'abc')">
<tr>
<xsl:call-template name="add-dbcols"/>
</tr>
</xsl:if>
</xsl:for-each>
</tbody>
</table>
<!--// end database column table //-->
</xsl:with-param>
<!-- this is ignored now
<xsl:with-param name="navbar">
<xsl:call-template name="add-navbar">
<xsl:with-param name="name" select="info/navbar"/>
</xsl:call-template>
</xsl:with-param>
-->
<!-- uses default //info/breadcrumbs -->
<xsl:with-param name="location" select="$filename"/>
</xsl:call-template>
</html>
</xsl:document>
</xsl:template> <!--* match=cscdb mode=alphabet *-->
<!-- the name value is taken to be a link unless it contains a space -->
<xsl:template name="add-dbcols">
<td>
<xsl:if test="not(contains(@name, ' '))">
<xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:if test="@type">
<xsl:value-of select="@type"/>
</xsl:if>
</td>
<td>
<xsl:if test="@units">
<xsl:choose>
<xsl:when test="@units='counts-s'">
counts s<sup>-1</sup>
</xsl:when>
<xsl:when test="@units='ergs-s-cm'">
ergs s<sup>-1</sup> cm<sup>-2</sup>
</xsl:when>
<xsl:when test="@units='photons-s-cm'">
photons s<sup>-1</sup> cm<sup>-2</sup>
</xsl:when>
<xsl:when test="@units='n-hi-cm'">
N <sub>HI atoms</sub> 10<sup>20</sup> cm<sup>-2</sup>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@units"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</td>
<td>
<xsl:apply-templates/>
</td>
</xsl:template> <!--* name:add-cols *-->
<!--* remove the 'whatever' tag, process the contents *-->
<xsl:template match="intro|desc">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>