forked from TEIC/Stylesheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_tagdocs.xsl
403 lines (364 loc) · 12 KB
/
html_tagdocs.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
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
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:teix="http://www.tei-c.org/ns/Examples" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="html a fo rng tei teix xs" version="3.0">
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
<desc>
<p> TEI stylesheet dealing with elements from the tagdocs module,
making HTML output. </p>
<p>This software is dual-licensed:
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
Unported License http://creativecommons.org/licenses/by-sa/3.0/
2. http://www.opensource.org/licenses/BSD-2-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
This software is provided by the copyright holders and contributors
"as is" and any express or implied warranties, including, but not
limited to, the implied warranties of merchantability and fitness for
a particular purpose are disclaimed. In no event shall the copyright
holder or contributors be liable for any direct, indirect, incidental,
special, exemplary, or consequential damages (including, but not
limited to, procurement of substitute goods or services; loss of use,
data, or profits; or business interruption) however caused and on any
theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use
of this software, even if advised of the possibility of such damage.
</p>
<p>Author: See AUTHORS</p>
<p>Copyright: 2013, TEI Consortium</p>
</desc>
</doc>
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
<desc>Process element ident</desc>
</doc>
<xsl:template match="tei:ident">
<xsl:choose>
<xsl:when test="@type">
<span class="ident-{@type}">
<xsl:apply-templates/>
</span>
</xsl:when>
<xsl:otherwise>
<span class="ident">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
<desc>Process element gi</desc>
</doc>
<xsl:template match="tei:gi">
<span class="gi">
<xsl:text><</xsl:text>
<xsl:apply-templates/>
<xsl:text>></xsl:text>
</span>
</xsl:template>
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
<desc>
<p>Process element att</p>
</desc>
</doc>
<xsl:template match="tei:att">
<span>
<xsl:call-template name="makeRendition"/>
<!-- JT (2023-09-28): At present, att's delimiter (@)
is generated in CSS; if that changes, then the following
should be included to be consistent -->
<!--
<xsl:call-template name="makeDelimiter">
<xsl:with-param name="string" as="xs:string">@</xsl:with-param>
</xsl:call-template>
-->
<xsl:apply-templates/>
</span>
</xsl:template>
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
<desc>
<p>Process element val</p>
</desc>
</doc>
<xsl:template match="tei:val">
<span>
<xsl:call-template name="makeRendition"/>
<xsl:call-template name="makeDelimiter">
<xsl:with-param name="string" as="xs:string">"</xsl:with-param>
<xsl:with-param name="classes" select="'start'"/>
</xsl:call-template>
<xsl:apply-templates/>
<xsl:call-template name="makeDelimiter">
<xsl:with-param name="string" as="xs:string">"</xsl:with-param>
<xsl:with-param name="classes" select="'end'"/>
</xsl:call-template>
</span>
</xsl:template>
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
<desc>
<p>Process element tag</p>
</desc>
</doc>
<xsl:template match="tei:tag">
<xsl:variable name="delims" as="xs:string*">
<xsl:choose>
<xsl:when test="empty(@type)">
<xsl:sequence select="( '<', '>' )"/>
</xsl:when>
<xsl:when test="@type = 'start'">
<xsl:sequence select="( '<', '>' )"/>
</xsl:when>
<xsl:when test="@type = 'end'">
<xsl:sequence select="( '</', '>' )"/>
</xsl:when>
<xsl:when test="@type eq 'empty'">
<xsl:sequence select="( '<', '/>' )"/>
</xsl:when>
<xsl:when test="@type eq 'pi'">
<xsl:sequence select="( '<?', '?>' )"/>
</xsl:when>
<xsl:when test="@type eq 'comment'">
<xsl:sequence select="( '<!--', '-->' )"/>
</xsl:when>
<xsl:when test="@type eq 'ms'">
<xsl:sequence select="( '<[CDATA[', ']]>' )"/>
</xsl:when>
<!--start, end, empty, pi, comment, and ms are the only
legal values (as of 4.6.0); if a different type
value is used, then this will break-->
<xsl:otherwise>
<xsl:message>Unhandled @type value of tei:tag: <xsl:value-of select="@type"/></xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<span>
<xsl:attribute name="class" select="string-join( ( local-name(), @type, @scheme ),' ' )"/>
<xsl:call-template name="makeRendition">
<xsl:with-param name="default" select="'false'"/>
</xsl:call-template>
<xsl:call-template name="makeDelimiter">
<xsl:with-param name="string" select="$delims[1]" as="xs:string"/>
<xsl:with-param name="classes" select="'start'"/>
</xsl:call-template>
<xsl:apply-templates/>
<xsl:call-template name="makeDelimiter">
<xsl:with-param name="string" select="$delims[2]" as="xs:string"/>
<xsl:with-param name="classes" select="'end'"/>
</xsl:call-template>
</span>
</xsl:template>
<xsl:template match="tei:specGrp">
<p><b>Specification group [<xsl:value-of select="@xml:id"/>]</b></p>
<table class="border">
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tei:schemaSpec">
<p><b>Specification [<xsl:value-of select="@xml:id"/>]</b></p>
<table class="border">
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tei:classSpec">
<tr>
<td><xsl:sequence select="tei:showMode(@ident,@mode)"/></td>
<td>
<xsl:if test="*">
<table class="border">
<xsl:apply-templates/>
</table>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template match="tei:elementSpec">
<tr>
<td><<xsl:sequence
select="tei:showMode(@ident,@mode)"/>></td>
<td>
<xsl:if test="*">
<table class="border">
<xsl:if test="tei:desc or tei:gloss">
<tr><td colspan="3">
<xsl:apply-templates select="tei:desc |tei:gloss"/>
</td></tr>
</xsl:if>
<xsl:apply-templates select="*[not(self::tei:desc or self::tei:gloss)]"/>
</table>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template match="tei:attDef">
<tr>
<td>@<xsl:sequence select="tei:showMode(@ident,@mode)"/></td>
<td>
<xsl:if test="*">
<table class="border">
<xsl:if test="tei:desc or tei:gloss">
<tr><td colspan="3">
<xsl:apply-templates select="tei:desc |tei:gloss"/>
</td></tr>
</xsl:if>
<xsl:apply-templates select="*[not(self::tei:desc or self::tei:gloss)]"/>
</table>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template match="tei:valItem">
<tr>
<td><xsl:sequence select="tei:showMode(@ident,@mode)"/>
<xsl:if test="tei:paramList">
<xsl:text> (</xsl:text>
<xsl:value-of select="tei:paramList/tei:paramSpec/@ident" separator=","/>
<xsl:text>)</xsl:text>
</xsl:if>
</td>
<td><xsl:value-of select="tei:desc"/> </td>
</tr>
</xsl:template>
<xsl:template match="tei:elementSpec[@mode='change' and not(*)]"/>
<xsl:template match="tei:model">
<tr>
<td>[model] <i><xsl:value-of select="tei:desc"/></i></td>
<td><xsl:value-of
select="(@predicate,@behaviour,@class,@output)" separator=" ; "/>
<xsl:apply-templates select="tei:rendition"/>
</td>
</tr>
</xsl:template>
<xsl:template match="tei:modelGrp">
<tr>
<td>[modelGrp] <xsl:value-of select="tei:desc"/></td>
<td><xsl:value-of
select="(@predicate,@behaviour,@class,@output)" separator=" ; "/></td>
<xsl:apply-templates select="tei:rendition"/>
</tr>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="tei:model/tei:rendition|tei:modelGrp/tei:rendition">
(<tt><xsl:apply-templates/></tt>)
</xsl:template>
<xsl:template match="tei:constraintSpec">
<tr>
<td>[#<xsl:value-of select="@ident"/>]</td>
<td>
<xsl:variable name="c">
<egXML xmlns="http://www.tei-c.org/ns/Examples">
<xsl:copy-of select="tei:constraint"/>
</egXML>
</xsl:variable>
<xsl:for-each select="$c">
<xsl:apply-templates/>
</xsl:for-each>
</td>
</tr>
</xsl:template>
<xsl:template match="tei:elementRef">
<tr>
<td>+ <<xsl:value-of select="@key"/>></td>
</tr>
</xsl:template>
<xsl:template match="tei:classRef">
<tr>
<td>+ <xsl:value-of select="@key"/></td>
</tr>
</xsl:template>
<xsl:template match="tei:macroRef">
<tr>
<td>+ <xsl:value-of select="@key"/></td>
</tr>
</xsl:template>
<xsl:template match="tei:specGrp/tei:p">
<tr>
<td colspan="3" class="norules"><xsl:apply-templates/></td>
</tr>
</xsl:template>
<xsl:template match="tei:moduleRef">
<tr>
<td>Module: <xsl:value-of select="@key"/></td>
</tr>
</xsl:template>
<xsl:template match="tei:content">
<tr>
<td colspan="3">
<div class="pre"><xsl:apply-templates mode="verbatim"/></div></td>
</tr>
</xsl:template>
<xsl:template match="tei:exemplum">
<tr>
<td colspan="3"><xsl:apply-templates/></td>
</tr>
</xsl:template>
<doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
<desc>Process elements teix:egXML</desc>
</doc>
<xsl:template match="teix:egXML">
<xsl:param name="simple">false</xsl:param>
<xsl:param name="highlight"/>
<div>
<xsl:attribute name="id">
<xsl:apply-templates mode="ident" select="."/>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:text>pre</xsl:text>
<xsl:if test="not(*)">
<xsl:text> cdata</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="@valid='feasible'">
<xsl:text> egXML_feasible</xsl:text>
</xsl:when>
<xsl:when test="@valid='false'">
<xsl:text> egXML_invalid</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> egXML_valid</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:choose>
<xsl:when test="$simple='true'">
<xsl:apply-templates mode="verbatim">
<xsl:with-param name="highlight">
<xsl:value-of select="$highlight"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="egXMLStartHook"/>
<xsl:apply-templates mode="verbatim">
<xsl:with-param name="highlight">
<xsl:value-of select="$highlight"/>
</xsl:with-param>
</xsl:apply-templates>
<xsl:call-template name="egXMLEndHook"/>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
<xsl:template match="tei:classes">
<tr>
<td>Classes</td>
<td colspan="2">
<ul>
<xsl:for-each select="tei:memberOf">
<xsl:value-of select="@key"/>
</xsl:for-each>
</ul>
</td>
</tr>
</xsl:template>
<xsl:function name="tei:showMode">
<xsl:param name="value"/>
<xsl:param name="mode"/>
<span class="{if ($mode='delete') then 'red del' else if ($mode='change')
then 'orange' else 'green'}">
<xsl:value-of select="$value"/>
</span>
</xsl:function>
</xsl:stylesheet>