File: cmd_website.xsl

package info (click to toggle)
chemical-mime-data 0.1.94-7
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 1,036 kB
  • sloc: sh: 457; makefile: 169
file content (482 lines) | stat: -rw-r--r-- 19,710 bytes parent folder | download
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
	<!ENTITY % _cmd_entities SYSTEM "cmd_entities.dtd">
	%_cmd_entities;
]>

<!--
  Document  $Id: cmd_website.xsl,v 1.13 2007/01/27 20:21:34 dleidert Exp $
  Summary   XSLT stylesheet that contains templates used to create the
            projects website.
  
  Copyright (C) 2006,2007 Daniel Leidert <daniel.leidert@wgdd.de>.

  This file is free software. The copyright owner gives unlimited
  permission to copy, distribute and modify it.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:date="http://exslt.org/dates-and-times"
                version="1.0"
                extension-element-prefixes="date"
                exclude-result-prefixes="date">


<!-- ********************************************************************* -->
<!-- * Import XSL stylesheets. Define output options.                      -->
<!-- ********************************************************************* -->

<xsl:import href="cmd_common.xsl"/>
<xsl:output method="html"
            encoding="UTF-8"
            indent="yes"
            omit-xml-declaration="yes"
            doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>


<!-- ********************************************************************* -->
<!-- * Space-stripped and -preserved elements/tokens.                      -->
<!-- ********************************************************************* -->

<xsl:strip-space elements="*"/>


<!-- ********************************************************************* -->
<!-- * xsl:template match (modes) section                                  -->
<!-- ********************************************************************* -->

<xsl:template match="/">
  <!-- * Output content to 'chemical-mime-data.html'.                      -->
  <!-- * Then process the whole file.                                      -->
	<xsl:call-template name="common.write.chunk">
		<xsl:with-param name="filename" select="'chemical-mime-data.html'"/>
		<xsl:with-param name="method" select="'xml'"/>
		<xsl:with-param name="indent" select="'yes'"/>
		<xsl:with-param name="omit-xml-declaration" select="'yes'"/>
		<xsl:with-param name="doctype-public" select="'-//W3C//DTD XHTML 1.0 Strict//EN'"/>
		<xsl:with-param name="doctype-system" select="'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'"/>
		<xsl:with-param name="content">
			<xsl:call-template name="html.content"/>
		</xsl:with-param>
	</xsl:call-template>
</xsl:template>

<xsl:template match="alias|sub-class-of">
	<dd>
		<span class="{local-name(.)}">
			<xsl:value-of select="@type"/>
		</span>
	</dd>
</xsl:template>

<xsl:template match="comment">
	<xsl:variable name="content" select="."/>
	<xsl:choose>
		<xsl:when test="following-sibling::acronym">
			<xsl:call-template name="comment.acronym.check">
				<xsl:with-param name="content" select="$content"/>
				<xsl:with-param name="acronym.position" select="1"/>
			</xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
			<xsl:call-template name="comment.acronym.output">
				<xsl:with-param name="content" select="$content"/>
			</xsl:call-template>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="glob">
	<code><xsl:value-of select="@pattern"/></code>
	<xsl:if test="following-sibling::glob">
		<xsl:text>, </xsl:text>
	</xsl:if>
</xsl:template>

<xsl:template match="magic|match|root-XML">
	<xsl:variable name="local.name" select="local-name()"/>
	<xsl:for-each select="ancestor::*[self::magic or self::match]">
		<xsl:text>    </xsl:text>
	</xsl:for-each>
	<xsl:text>&lt;</xsl:text>
	<xsl:value-of select="local-name()"/>
	<xsl:for-each select="@*">
		<xsl:text> </xsl:text>
		<xsl:value-of select="local-name()"/>
		<xsl:text>="</xsl:text>
		<xsl:value-of select="." />
		<xsl:text>"</xsl:text>
	</xsl:for-each>
	<xsl:choose>
		<xsl:when test="child::*">
			<xsl:text>&gt;</xsl:text>
			<br/>
			<xsl:apply-templates/>
			<xsl:for-each select="ancestor::*[self::magic or self::match]">
				<xsl:text>    </xsl:text>
			</xsl:for-each>
			<xsl:text>&lt;/</xsl:text>
			<xsl:value-of select="local-name()"/>
			<xsl:text>&gt;</xsl:text>
			<br/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:text>/&gt;</xsl:text>
			<br/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="mime-type">
	<tr class="{local-name(.)}">
		<xsl:choose>
			<xsl:when test="child::magic and child::root-XML and child::specification">
				<xsl:call-template name="mimetype.output">
					<xsl:with-param name="rowspan" select="4"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="(child::magic and child::root-XML and not(child::specification))
			                or (child::magic and not(child::root-XML) and child::specification)
			                or (not(child::magic) and child::root-XML and child::specification)">
				<xsl:call-template name="mimetype.output">
					<xsl:with-param name="rowspan" select="3"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="(child::magic and not(child::root-XML) and not(child::specification))
			                or (not(child::magic) and not(child::root-XML) and child::specification)
			                or (not(child::magic) and child::root-XML and not(child::specification))">
				<xsl:call-template name="mimetype.output">
					<xsl:with-param name="rowspan" select="2"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="mimetype.output"/>
			</xsl:otherwise>
		</xsl:choose>
		<td class="comment">
			<xsl:for-each select="comment[not(@xml:lang)]">
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</td>
		<td class="glob">
			<xsl:for-each select="glob">
				<xsl:apply-templates select="."/>
			</xsl:for-each>
		</td>
	</tr>
	<xsl:if test="child::magic">
		<tr>
			<td colspan="2" class="magic">
				<pre>
					<xsl:apply-templates select="magic"/>
				</pre>
			</td>
		</tr>
	</xsl:if>
	<xsl:if test="child::root-XML">
		<tr>
			<td colspan="2" class="root-XML">
				<pre>
					<xsl:apply-templates select="root-XML"/>
				</pre>
			</td>
		</tr>
	</xsl:if>
	<xsl:if test="child::specification">
		<tr>
			<td colspan="2" class="specification">
				<xsl:apply-templates select="specification"/>
			</td>
		</tr>
	</xsl:if>
</xsl:template>

<xsl:template match="specification">
	<a href="{@url}">
		<xsl:if test="string-length(@title)">
			<xsl:attribute name="title">
				<xsl:value-of select="@title"/>
			</xsl:attribute>
		</xsl:if>
		<xsl:value-of select="@url"/>
	</a>
	<xsl:if test="following-sibling::specification">
		<xsl:text>,</xsl:text>
		<br/>
	</xsl:if>
</xsl:template>

<xsl:template match="acronym|application|expanded-acronym|icon|supported-by"/>


<!-- ********************************************************************* -->
<!-- * Named templates for special processing and functions.               -->
<!-- ********************************************************************* -->

<xsl:template name="html.content">
  <!-- * Outputs the HTML site. Here we create the <head> section with all -->
  <!-- * meta tags and call the other templates to create the HTML body,   -->
  <!-- * without process anything body-related here.                       --> 
	<html>
		<head>
			<title>The chemical-mime-data Project</title>
			<meta name="generator">
				<xsl:attribute name="content">$Id: cmd_website.xsl,v 1.13 2007/01/27 20:21:34 dleidert Exp $</xsl:attribute>
			</meta>
			<meta name="author">
				<xsl:attribute name="content">Daniel Leidert</xsl:attribute>
			</meta>
			<meta name="date">
				<xsl:attribute name="content"><xsl:value-of select="date:date-time()"/></xsl:attribute>
			</meta>
			<meta name="keywords" content="chemical-mime-data, chemical MIME"/>
			<meta name="description" content="chemical-mime-data Homepage"/>
			<meta name="robots" content="index, follow"/>
			<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
			<meta http-equiv="content-style-type" content="text/css"/>
			<link rel="stylesheet" type="text/css" href="cmd.css" media="screen" title="default" />
		</head>
		<body>
			<div id="content_container">
				<xsl:call-template name="html.content.head"/>
				<xsl:call-template name="html.content.table.mime.supported"/>
				<xsl:call-template name="html.content.table.mime.unsupported"/>
				<xsl:call-template name="html.content.references"/>
			</div>
			<div id="footer">
				<xsl:call-template name="html.content.foot"/>
			</div>
		</body>
	</html>
</xsl:template>

<xsl:template name="html.content.head">
  <!-- * The template contains all static data written at the beginning of   -->
  <!-- * the HTML site(headline/title, about the project, ... such data).    -->
	<h1>chemical-mime-data</h1>
	<p>The source of <a href="index.html">this project</a> can be downloaded at the <a href="https://github.com/dleidert/chemical-mime">GitHub project page</a>.</p>
	<p>The released version is: <span class="version">&entversion;</span>.</p>
	<p>The released Database version is: <span class="version"><xsl:value-of select="chemical-mime/@id"/></span>.</p>
	<h2 id="toc">Table of Contents</h2>
	<ol>
		<li><a href="#supported">Supported MIME types</a></li>
		<li><a href="#unsupported">Unsupported but known MIME types</a></li>
		<li><a href="#references">References</a></li>
	</ol>
</xsl:template>

<xsl:template name="html.content.references">
  <!-- * At least print out a list of references.                            -->
	<h2 id="references">References</h2>
	<p>The tables contain references to specifications, standards and papers, that were used. So the following list are generic resources, that were used too.</p>
	<ol>
		<li><a href="http://www.ch.ic.ac.uk/chemime/">&#187;The Chemical MIME Home Page&#171;</a> by Henry Rzepa.</li>
	</ol>
</xsl:template>

<xsl:template name="html.content.table.mime.supported">
  <!-- * Output an overview of currently (by the package) supported MIME     -->
  <!-- * types.                                                              -->
	<h2 id="supported">Supported MIME types</h2>
	<p>The following MIME types are supported by the &entpackage; package version &entversion;.</p>
	<table>
		<xsl:call-template name="html.content.table.mime.head"/>
		<xsl:for-each select=".//mime-type[@support = 'yes']">
			<xsl:sort select="@type"/>
			<xsl:apply-templates select="."/>
		</xsl:for-each>
	</table>
</xsl:template>

<xsl:template name="html.content.table.mime.unsupported">
  <!-- * Output an overview of currently (by the package) unsupported, but   -->
  <!-- * known and already added MIME types.                                 -->
	<h2 id="unsupported">Unsupported but known MIME types</h2>
	<p>The following MIME types are not supported by the &entpackage; package version &entversion;.</p>
	<table>
		<xsl:call-template name="html.content.table.mime.head"/>
		<xsl:for-each select=".//mime-type[not(@support = 'yes')]">
			<xsl:sort select="@type"/>
			<xsl:apply-templates select="."/>
		</xsl:for-each>
	</table>
	<p>There might be more MIME types, that simply were not yet added to the database. If you know one missing, just <a href="https://sourceforge.net/tracker/?func=add&amp;group_id=159685&amp;atid=812822">let us know</a>.</p>
</xsl:template>

<xsl:template name="html.content.table.mime.head">
  <!-- * Both overviews have the same table head. This template creates    -->
  <!-- * it.                                                               -->
	<tr>
		<th class="mime-type" rowspan="4">MIME type
			<br/><br/>Sub-class of <sup>[<a href="#comment_subclassof">1</a>]</sup>
			<br/><br/>Alias
		</th>
		<th class="comment">Description</th>
		<th class="glob">Filename extension</th>
	</tr>
	<tr>
		<th class="root-XML" colspan="2">Magic Pattern</th>
	</tr>
	<tr>
		<th class="comment" colspan="2">Root XML/Namespace</th>
	</tr>
	<tr>
		<th class="specification" colspan="2">Specification</th>
	</tr>
</xsl:template>

<xsl:template name="html.content.foot">
  <!-- * The template contains all static data written at the beginning of   -->
  <!-- * the HTML site(headline/title, about the project, ... such data).    -->
 	<span id="comment_subclassof"><sup><strong>[1]</strong></sup> Entries, that do not show a <cite>Sub-class of:</cite> value are binary files and therefor of type <span class="sub-class-of">application/octet-stream</span>.</span>
</xsl:template>

<xsl:template name="mimetype.output">
  <!-- * For every MIME type, create a cell with the following content:    -->
  <!-- *                                                                   -->
  <!-- * chemical/foo                                                      -->
  <!-- *                                                                   -->
  <!-- * Sub-class of:                                                     -->
  <!-- *     MIME type                                                     -->
  <!-- *                                                                   -->
  <!-- * Alias(s):                                                         -->
  <!-- *     MIME type 1                                                   -->
  <!-- *     MIME type 2                                                   -->
  <!-- *     ...                                                           -->
  <!-- *                                                                   -->
	<xsl:param name="rowspan" select="false()"/>
	
	<td class="{local-name(.)}">
		<xsl:if test="$rowspan">
			<xsl:attribute name="rowspan">
				<xsl:value-of select="$rowspan"/>
			</xsl:attribute>
		</xsl:if>
		<span class="{local-name(.)}">
			<xsl:value-of select="@type"/>
		</span>
		<xsl:if test="child::sub-class-of">
			<dl>
				<dt class="sub-class-of">Sub-class of:</dt>
				<xsl:for-each select="sub-class-of">
					<xsl:sort select="@type"/>
					<xsl:apply-templates select="."/>
				</xsl:for-each>
			</dl>
		</xsl:if>
		<xsl:if test="child::alias">
			<dl>
				<dt class="alias">Alias(s):</dt>
				<xsl:for-each select="alias">
					<xsl:sort select="@type"/>
					<xsl:apply-templates select="."/>
				</xsl:for-each>
			</dl>
		</xsl:if>
	</td>
</xsl:template>

<xsl:template name="comment.acronym.check">
  <!-- * Process the content of a <comment> and check, if the comment      -->
  <!-- * contains the content of a <acronym>/<expanded-acronym> combo of   -->
  <!-- * the currently processed <mime-type> element. If an a known        -->
  <!-- * <acronym> is found, it's pure text is replaced with the acronym   -->
  <!-- * HTML tag. Ditto, if the <expanded-acronym> content fits a part of -->
  <!-- * the currently processed <comment> content.                        -->
	<xsl:param name="content"/>
	<xsl:param name="acronym.position"/>

	<xsl:variable name="acronym.content"
	              select="following-sibling::acronym[not(@xml:lang)][$acronym.position]"/>
	<xsl:variable name="expanded.acronym.content"
	              select="following-sibling::expanded-acronym[not(@xml:lang)][$acronym.position]"/>

	<xsl:choose>
    <!-- * Check if we find a known <acronym> inside <comment>. If yes,    -->
    <!-- * use the <acronym> HTML tag with the contents of <acronym> and   -->
    <!-- * <expanded-acronym> of our database.                             -->
		<xsl:when test="contains($content, $acronym.content)">
			<xsl:variable name="content.new.before" select="substring-before($content, $acronym.content)"/>
			<xsl:variable name="content.new.acronym">
				<![CDATA[<acronym title="]]><xsl:value-of select="$expanded.acronym.content"/>
				<![CDATA[">]]><xsl:value-of select="$acronym.content"/><![CDATA[</acronym>]]>
			</xsl:variable>
			<xsl:variable name="content.new.middle" select="normalize-space($content.new.acronym)"/>
			<xsl:variable name="content.new.after" select="substring-after($content, $acronym.content)"/>
			<xsl:variable name="content.new" select="concat($content.new.before, $content.new.middle, $content.new.after)"/>
			<xsl:choose>
				<xsl:when test="following-sibling::acronym[not(@xml:lang)][$acronym.position + 1]">
					<xsl:call-template name="comment.acronym.check">
						<xsl:with-param name="content" select="$content.new"/>
						<xsl:with-param name="acronym.position" select="$acronym.position + 1"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="comment.acronym.output">
						<xsl:with-param name="content" select="$content.new"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>			
    <!-- * Check, if maybe a part of the comment fits the content of an    -->
    <!-- * <expanded-acronym>. If yes, output the related <acronym>        -->
    <!-- * directly behind the (expanded) substring inside braces, using   -->
    <!-- * the <acronym> HTML tag.                                         -->
		<xsl:when test="contains($content, $expanded.acronym.content)">
			<xsl:variable name="content.new.before" select="concat(substring-before($content, $expanded.acronym.content), $expanded.acronym.content)"/>
			<xsl:variable name="content.new.acronym">
				<![CDATA[<acronym title="]]><xsl:value-of select="$expanded.acronym.content"/>
				<![CDATA[">]]><xsl:value-of select="$acronym.content"/><![CDATA[</acronym>]]>
			</xsl:variable>
			<xsl:variable name="content.new.middle.before" select="' ('"/>
			<xsl:variable name="content.new.middle.temp" select="normalize-space($content.new.acronym)"/>
			<xsl:variable name="content.new.middle.after" select="') '"/>
			<xsl:variable name="content.new.middle" select="concat($content.new.middle.before, $content.new.middle.temp, $content.new.middle.after)"/>
			<xsl:variable name="content.new.after" select="substring-after($content, $expanded.acronym.content)"/>
			<xsl:variable name="content.new" select="concat($content.new.before, $content.new.middle, $content.new.after)"/>
			<xsl:choose>
				<xsl:when test="following-sibling::acronym[not(@xml:lang)][$acronym.position + 1]">
					<xsl:call-template name="comment.acronym.check">
						<xsl:with-param name="content" select="$content.new"/>
						<xsl:with-param name="acronym.position" select="$acronym.position + 1"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="comment.acronym.output">
						<xsl:with-param name="content" select="$content.new"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:when>
    <!-- * And if nothing fits, just step to the next <acronym> position   -->
    <!-- * in our database.                                                -->
		<xsl:otherwise>
			<xsl:variable name="content.new" select="$content"/>
			<xsl:choose>
				<xsl:when test="following-sibling::acronym[not(@xml:lang)][$acronym.position + 1]">
					<xsl:call-template name="comment.acronym.check">
						<xsl:with-param name="content" select="$content.new"/>
						<xsl:with-param name="acronym.position" select="$acronym.position + 1"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="comment.acronym.output">
						<xsl:with-param name="content" select="$content.new"/>
					</xsl:call-template>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="comment.acronym.output">
  <!-- * Just output the completely processed and (maybe) extended output  -->
  <!-- * without escaping the content. This saves added acronym templates  -->
  <!-- * tags.                                                             -->
	<xsl:param name="content"/>

	<xsl:value-of select="$content" disable-output-escaping="yes"/>
</xsl:template>

</xsl:stylesheet>