@pretextbook/pretext-html 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +104 -4
  2. package/assets/preview-html.xsl +230 -230
  3. package/assets/upstream.json +7 -7
  4. package/assets/xsl/entities.ent +154 -154
  5. package/assets/xsl/extract-asymptote.xsl +68 -68
  6. package/assets/xsl/extract-biblio-csl.xsl +327 -327
  7. package/assets/xsl/extract-datafile.xsl +71 -71
  8. package/assets/xsl/extract-dynamic.xsl +139 -139
  9. package/assets/xsl/extract-identity.xsl +136 -136
  10. package/assets/xsl/extract-interactive.xsl +81 -81
  11. package/assets/xsl/extract-latex-image.xsl +118 -118
  12. package/assets/xsl/extract-mermaid.xsl +58 -58
  13. package/assets/xsl/extract-mom.xsl +63 -63
  14. package/assets/xsl/extract-pg.xsl +2897 -2897
  15. package/assets/xsl/extract-prefigure.xsl +157 -157
  16. package/assets/xsl/extract-qrcode.xsl +100 -100
  17. package/assets/xsl/extract-runestone-page-template.xsl +139 -139
  18. package/assets/xsl/extract-sageplot.xsl +166 -166
  19. package/assets/xsl/extract-stack.xsl +56 -56
  20. package/assets/xsl/extract-trace.xsl +134 -134
  21. package/assets/xsl/extract-youtube.xsl +63 -63
  22. package/assets/xsl/html-symbols.xsl +3344 -3344
  23. package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -56
  24. package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -148
  25. package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -317
  26. package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -76
  27. package/assets/xsl/latex/pretext-latex-guide.xsl +104 -104
  28. package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -862
  29. package/assets/xsl/localizations/af-ZA.xml +276 -276
  30. package/assets/xsl/localizations/bg-BG.xml +276 -276
  31. package/assets/xsl/localizations/ca-ES.xml +285 -285
  32. package/assets/xsl/localizations/cs-CZ.xml +280 -280
  33. package/assets/xsl/localizations/de-DE.xml +281 -281
  34. package/assets/xsl/localizations/en-US.xml +427 -427
  35. package/assets/xsl/localizations/es-ES.xml +287 -287
  36. package/assets/xsl/localizations/fi-FI.xml +275 -275
  37. package/assets/xsl/localizations/fr-CA.xml +276 -276
  38. package/assets/xsl/localizations/fr-FR.xml +280 -280
  39. package/assets/xsl/localizations/hu-HU.xml +280 -280
  40. package/assets/xsl/localizations/it-IT.xml +276 -276
  41. package/assets/xsl/localizations/ku-CKB.xml +275 -275
  42. package/assets/xsl/localizations/localizations.xml +48 -48
  43. package/assets/xsl/localizations/nl-NL.xml +275 -275
  44. package/assets/xsl/localizations/pt-BR.xml +288 -288
  45. package/assets/xsl/localizations/pt-PT.xml +292 -292
  46. package/assets/xsl/localizations/zh-HANS.xml +269 -269
  47. package/assets/xsl/pretext-assembly.xsl +4795 -4795
  48. package/assets/xsl/pretext-basic-html.xsl +86 -86
  49. package/assets/xsl/pretext-beamer.xsl +662 -662
  50. package/assets/xsl/pretext-braille-preprint.xsl +2249 -2249
  51. package/assets/xsl/pretext-common.xsl +12018 -12018
  52. package/assets/xsl/pretext-dynamic.xsl +65 -65
  53. package/assets/xsl/pretext-epub.xsl +1483 -1483
  54. package/assets/xsl/pretext-fo.xsl +4593 -4593
  55. package/assets/xsl/pretext-html.xsl +14791 -14791
  56. package/assets/xsl/pretext-json-manifest.xsl +150 -150
  57. package/assets/xsl/pretext-jupyter.xsl +868 -868
  58. package/assets/xsl/pretext-latex-classic.xsl +952 -952
  59. package/assets/xsl/pretext-latex-common.xsl +11563 -11563
  60. package/assets/xsl/pretext-latex.xsl +47 -47
  61. package/assets/xsl/pretext-litprog.xsl +105 -105
  62. package/assets/xsl/pretext-merge.xsl +41 -41
  63. package/assets/xsl/pretext-numbers.xsl +875 -875
  64. package/assets/xsl/pretext-revealjs.xsl +522 -522
  65. package/assets/xsl/pretext-runestone-fitb.xsl +1233 -1233
  66. package/assets/xsl/pretext-runestone-static.xsl +1438 -1438
  67. package/assets/xsl/pretext-runestone.xsl +3083 -3083
  68. package/assets/xsl/pretext-sage-doctest.xsl +289 -289
  69. package/assets/xsl/pretext-smc.xsl +492 -492
  70. package/assets/xsl/pretext-solution-manual-latex.xsl +323 -323
  71. package/assets/xsl/pretext-text-utilities.xsl +1217 -1217
  72. package/assets/xsl/pretext-text.xsl +392 -392
  73. package/assets/xsl/pretext-units.xsl +195 -195
  74. package/assets/xsl/pretext-view-source.xsl +157 -157
  75. package/assets/xsl/pretext-ww-problem-sets.xsl +391 -391
  76. package/assets/xsl/publisher-variables.xsl +4756 -4756
  77. package/assets/xsl/support/extract-math.xsl +256 -256
  78. package/assets/xsl/support/package-math.xsl +141 -141
  79. package/assets/xsl/support/play-button/play-button.svg +3 -3
  80. package/assets/xsl/support/pretext-pg-macros.xsl +110 -110
  81. package/assets/xsl/support/webpack_static_imports.xml +14 -14
  82. package/assets/xsl/tests/null.xml +3 -3
  83. package/assets/xsl/tests/pretext-text-utilities-test.xsl +333 -333
  84. package/assets/xsl/utilities/author-report.xsl +107 -107
  85. package/assets/xsl/utilities/deprecate-autoname.sed +18 -18
  86. package/assets/xsl/utilities/deprecate-index.sed +33 -33
  87. package/assets/xsl/utilities/fix-deprecations.xsl +663 -663
  88. package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -112
  89. package/assets/xsl/utilities/report-publisher-variables.xsl +162 -162
  90. package/assets/xsl/xml-to-json.xsl +326 -326
  91. package/assets/xsl/xml-to-string.xsl +328 -328
  92. package/assets/xsl-bundle.json +1 -0
  93. package/dist/{cli-C6tfAVvi.js → cli-B2LiKunq.js} +268 -233
  94. package/dist/cli.js +1 -1
  95. package/dist/host.browser.d.ts +29 -0
  96. package/dist/host.d.ts +41 -0
  97. package/dist/index.browser.d.ts +29 -0
  98. package/dist/index.browser.js +650 -0
  99. package/dist/index.d.ts +5 -0
  100. package/dist/index.js +16 -8
  101. package/dist/internal/posix-path.d.ts +59 -0
  102. package/dist/mounts.d.ts +18 -0
  103. package/dist/renderer.d.ts +14 -1
  104. package/dist/theme.d.ts +68 -0
  105. package/dist/theme.js +93 -0
  106. package/package.json +22 -4
@@ -1,663 +1,663 @@
1
- <?xml version='1.0'?>
2
-
3
- <!--********************************************************************
4
- Copyright 2017 Robert A. Beezer
5
-
6
- This file is part of MathBook XML.
7
-
8
- MathBook XML is free software: you can redistribute it and/or modify
9
- it under the terms of the GNU General Public License as published by
10
- the Free Software Foundation, either version 2 or version 3 of the
11
- License (at your option).
12
-
13
- MathBook XML is distributed in the hope that it will be useful,
14
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- GNU General Public License for more details.
17
-
18
- You should have received a copy of the GNU General Public License
19
- along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
20
- *********************************************************************-->
21
-
22
- <!-- Identify as a stylesheet -->
23
- <xsl:stylesheet
24
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
25
- exclude-result-prefixes="xsl"
26
- >
27
-
28
- <xsl:output method="xml" encoding="UTF-8" />
29
-
30
- <!-- ###################### -->
31
- <!-- Deprecations and Fixes -->
32
- <!-- ###################### -->
33
-
34
- <!-- Deprecations that can be fixed with a transformation -->
35
- <!-- In reverse chronological order, with dates -->
36
-
37
- <!-- 2020-03-13 webwork setup obsolete -->
38
- <xsl:template match="webwork/setup">
39
- <xsl:apply-templates select="@* | node()" />
40
- <xsl:call-template name="deprecation-fix-report">
41
- <xsl:with-param name="date">2020-03-13</xsl:with-param>
42
- <xsl:with-param name="message">Removing &lt;setup&gt; wrapper from a &lt;webwork&gt;, preserving contents (&lt;pg-code&gt;?)</xsl:with-param>
43
- </xsl:call-template>
44
- </xsl:template>
45
-
46
- <!-- 2019-06-28 deprecate captioned lists to be titled lists -->
47
- <xsl:template match="list[title]/caption">
48
- <xsl:comment>
49
- <xsl:text>Commented list/caption: </xsl:text>
50
- <xsl:apply-templates select="*|text()" />
51
- </xsl:comment>
52
- <xsl:call-template name="deprecation-fix-report">
53
- <xsl:with-param name="date">2019-06-28</xsl:with-param>
54
- <xsl:with-param name="message">Converting a &lt;list&gt;/&lt;caption&gt; to a source comment</xsl:with-param>
55
- </xsl:call-template>
56
- </xsl:template>
57
-
58
- <!-- 2019-06-28 deprecate captioned lists to be titled lists -->
59
- <xsl:template match="list[not(title)]/caption">
60
- <title>
61
- <xsl:apply-templates select="@* | node()" />
62
- </title>
63
- <xsl:call-template name="deprecation-fix-report">
64
- <xsl:with-param name="date">2019-06-28</xsl:with-param>
65
- <xsl:with-param name="message">Converting a &lt;list&gt;/&lt;caption&gt; to a &lt;list&gt;/&lt;title&gt;</xsl:with-param>
66
- </xsl:call-template>
67
- </xsl:template>
68
-
69
- <!-- 2019-06-28 deprecate captioned tables to be titled tables -->
70
- <xsl:template match="table/caption">
71
- <title>
72
- <xsl:apply-templates select="@* | node()" />
73
- </title>
74
- <xsl:call-template name="deprecation-fix-report">
75
- <xsl:with-param name="date">2019-06-28</xsl:with-param>
76
- <xsl:with-param name="message">Converting a &lt;table&gt;/&lt;caption&gt; to a &lt;table&gt;/&lt;title&gt;</xsl:with-param>
77
- </xsl:call-template>
78
- </xsl:template>
79
-
80
- <!-- 2019-02-10 todo element replaced by a prefixed XML comment -->
81
- <xsl:template match="todo">
82
- <xsl:comment>
83
- <xsl:text> </xsl:text>
84
- <xsl:text>ToDo: </xsl:text>
85
- <xsl:apply-templates/>
86
- <xsl:text> </xsl:text>
87
- </xsl:comment>
88
- <xsl:call-template name="deprecation-fix-report">
89
- <xsl:with-param name="date">2019-02-10</xsl:with-param>
90
- <xsl:with-param name="message">Replacing a &lt;todo&gt; with a prefixed XML comment</xsl:with-param>
91
- </xsl:call-template>
92
- </xsl:template>
93
-
94
- <!-- 2019-02-06 Nine unnecessary elements -->
95
- <!-- <, >, [, ], *, /, `, braces and brackets -->
96
- <xsl:template match="less">
97
- <xsl:text>&lt;</xsl:text>
98
- <xsl:call-template name="deprecation-fix-report">
99
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
100
- <xsl:with-param name="message">Replacing &lt;less/&gt; with &quot;&lt;&quot;</xsl:with-param>
101
- </xsl:call-template>
102
- </xsl:template>
103
- <xsl:template match="greater">
104
- <xsl:text>&gt;</xsl:text>
105
- <xsl:call-template name="deprecation-fix-report">
106
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
107
- <xsl:with-param name="message">Replacing &lt;greater/&gt; with &quot;&gt;&quot;</xsl:with-param>
108
- </xsl:call-template>
109
- </xsl:template>
110
- <xsl:template match="lbracket">
111
- <xsl:text>[</xsl:text>
112
- <xsl:call-template name="deprecation-fix-report">
113
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
114
- <xsl:with-param name="message">Replacing &lt;lbracket/&gt; with &quot;[&quot;</xsl:with-param>
115
- </xsl:call-template>
116
- </xsl:template>
117
- <xsl:template match="rbracket">
118
- <xsl:text>]</xsl:text>
119
- <xsl:call-template name="deprecation-fix-report">
120
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
121
- <xsl:with-param name="message">Replacing &lt;rbracket/&gt; with &quot;]&quot;</xsl:with-param>
122
- </xsl:call-template>
123
- </xsl:template>
124
- <xsl:template match="asterisk">
125
- <xsl:text>*</xsl:text>
126
- <xsl:call-template name="deprecation-fix-report">
127
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
128
- <xsl:with-param name="message">Replacing &lt;asterisk/&gt; with &quot;*&quot;</xsl:with-param>
129
- </xsl:call-template>
130
- </xsl:template>
131
- <xsl:template match="slash">
132
- <xsl:text>/</xsl:text>
133
- <xsl:call-template name="deprecation-fix-report">
134
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
135
- <xsl:with-param name="message">Replacing &lt;slash/&gt; with &quot;/&quot;</xsl:with-param>
136
- </xsl:call-template>
137
- </xsl:template>
138
- <xsl:template match="backtick">
139
- <xsl:text>`</xsl:text>
140
- <xsl:call-template name="deprecation-fix-report">
141
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
142
- <xsl:with-param name="message">Replacing &lt;backtick/&gt; with &quot;`&quot;</xsl:with-param>
143
- </xsl:call-template>
144
- </xsl:template>
145
- <xsl:template match="braces">
146
- <xsl:text>{</xsl:text>
147
- <xsl:apply-templates select="@* | node()" />
148
- <xsl:text>}</xsl:text>
149
- <xsl:call-template name="deprecation-fix-report">
150
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
151
- <xsl:with-param name="message">Replacing &lt;braces&gt; by {...}</xsl:with-param>
152
- </xsl:call-template>
153
- </xsl:template>
154
- <xsl:template match="brackets">
155
- <xsl:text>[</xsl:text>
156
- <xsl:apply-templates select="@* | node()" />
157
- <xsl:text>]</xsl:text>
158
- <xsl:call-template name="deprecation-fix-report">
159
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
160
- <xsl:with-param name="message">Replacing &lt;brackets&gt; by [...]</xsl:with-param>
161
- </xsl:call-template>
162
- </xsl:template>
163
-
164
- <!-- 2019-02-06 LaTeX's 10 reserved characters: # $ % ^ & _ { } ~ \ -->
165
- <xsl:template match="hash">
166
- <xsl:text>#</xsl:text>
167
- <xsl:call-template name="deprecation-fix-report">
168
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
169
- <xsl:with-param name="message">Replacing &lt;hash/&gt; with &quot;#&quot;</xsl:with-param>
170
- </xsl:call-template>
171
- </xsl:template>
172
- <xsl:template match="dollar">
173
- <xsl:text>$</xsl:text>
174
- <xsl:call-template name="deprecation-fix-report">
175
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
176
- <xsl:with-param name="message">Replacing &lt;dollar/&gt; with &quot;$&quot;</xsl:with-param>
177
- </xsl:call-template>
178
- </xsl:template>
179
- <xsl:template match="percent">
180
- <xsl:text>%</xsl:text>
181
- <xsl:call-template name="deprecation-fix-report">
182
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
183
- <xsl:with-param name="message">Replacing &lt;percent/&gt; with &quot;%&quot;</xsl:with-param>
184
- </xsl:call-template>
185
- </xsl:template>
186
- <xsl:template match="circumflex">
187
- <xsl:text>^</xsl:text>
188
- <xsl:call-template name="deprecation-fix-report">
189
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
190
- <xsl:with-param name="message">Replacing &lt;circumflex/&gt; with &quot;^&quot;</xsl:with-param>
191
- </xsl:call-template>
192
- </xsl:template>
193
- <xsl:template match="ampersand">
194
- <xsl:text>&amp;</xsl:text>
195
- <xsl:call-template name="deprecation-fix-report">
196
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
197
- <xsl:with-param name="message">Replacing &lt;ampersand/&gt; with &quot;&amp;&quot;</xsl:with-param>
198
- </xsl:call-template>
199
- </xsl:template>
200
- <xsl:template match="underscore">
201
- <xsl:text>_</xsl:text>
202
- <xsl:call-template name="deprecation-fix-report">
203
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
204
- <xsl:with-param name="message">Replacing &lt;underscore/&gt; with &quot;_&quot;</xsl:with-param>
205
- </xsl:call-template>
206
- </xsl:template>
207
- <xsl:template match="lbrace">
208
- <xsl:text>{</xsl:text>
209
- <xsl:call-template name="deprecation-fix-report">
210
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
211
- <xsl:with-param name="message">Replacing &lt;lbrace/&gt; with &quot;{&quot;</xsl:with-param>
212
- </xsl:call-template>
213
- </xsl:template>
214
- <xsl:template match="rbrace">
215
- <xsl:text>}</xsl:text>
216
- <xsl:call-template name="deprecation-fix-report">
217
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
218
- <xsl:with-param name="message">Replacing &lt;rbrace/&gt; with &quot;}&quot;</xsl:with-param>
219
- </xsl:call-template>
220
- </xsl:template>
221
- <xsl:template match="tilde">
222
- <xsl:text>~</xsl:text>
223
- <xsl:call-template name="deprecation-fix-report">
224
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
225
- <xsl:with-param name="message">Replacing &lt;tilde/&gt; with &quot;~&quot;</xsl:with-param>
226
- </xsl:call-template>
227
- </xsl:template>
228
- <xsl:template match="backslash">
229
- <xsl:text>\</xsl:text>
230
- <xsl:call-template name="deprecation-fix-report">
231
- <xsl:with-param name="date">2019-02-06</xsl:with-param>
232
- <xsl:with-param name="message">Replacing &lt;backslash/&gt; with &quot;\&quot;</xsl:with-param>
233
- </xsl:call-template>
234
- </xsl:template>
235
-
236
- <!-- 2018-12-30 circa shortened to ca -->
237
- <xsl:template match="circa">
238
- <ca/>
239
- <xsl:call-template name="deprecation-fix-report">
240
- <xsl:with-param name="date">2018-12-30</xsl:with-param>
241
- <xsl:with-param name="message">Replacing &lt;circa/&gt; by &lt;ca/&gt;</xsl:with-param>
242
- </xsl:call-template>
243
- </xsl:template>
244
-
245
- <!-- 2018-05-02 sidebyside paragraphs to stack, preserve title -->
246
- <xsl:template match="sidebyside/paragraphs">
247
- <stack>
248
- <xsl:comment> Old paragraphs title: <xsl:apply-templates select="title/node()" /> </xsl:comment>
249
- <xsl:apply-templates select="@*[not(self::title)] | node()" />
250
- </stack>
251
- <xsl:call-template name="deprecation-fix-report">
252
- <xsl:with-param name="date">2018-05-02</xsl:with-param>
253
- <xsl:with-param name="message">Replacing &lt;paragraphs&gt; inside &lt;sidebyside&gt; with &lt;stack&gt;, &quot;title&quot; preserved in a comment</xsl:with-param>
254
- </xsl:call-template>
255
- </xsl:template>
256
-
257
- <!-- 2018-02-05 booktitle to simply pubtitle -->
258
- <xsl:template match="booktitle">
259
- <pubtitle>
260
- <xsl:apply-templates select="@* | node()" />
261
- </pubtitle>
262
- <xsl:call-template name="deprecation-fix-report">
263
- <xsl:with-param name="date">2018-02-05</xsl:with-param>
264
- <xsl:with-param name="message">Replacing &lt;booktitle&gt; by &lt;pubtitle&gt;</xsl:with-param>
265
- </xsl:call-template>
266
- </xsl:template>
267
-
268
- <!-- 2017-12-07 "c" content totally escaped for LaTeX -->
269
- <xsl:template match="c/@latexsep|cd/@latexsep">
270
- <!-- do nothing, just drop it and report -->
271
- <xsl:call-template name="deprecation-fix-report">
272
- <xsl:with-param name="date">2017-12-07</xsl:with-param>
273
- <xsl:with-param name="message">Removing &lt;@latexsep&gt; from a &lt;c&gt; or &lt;cd&gt; element</xsl:with-param>
274
- </xsl:call-template>
275
- </xsl:template>
276
-
277
- <!-- 2017-08-06 wrap "program" and "console" in "sidebyside" at full width -->
278
- <xsl:template match="program[not(parent::sidebyside or parent::listing)]">
279
- <sidebyside width="100%">
280
- <program>
281
- <xsl:apply-templates select="@* | node()" />
282
- </program>
283
- </sidebyside>
284
- <xsl:call-template name="deprecation-fix-report">
285
- <xsl:with-param name="date">2017-08-06</xsl:with-param>
286
- <xsl:with-param name="message">Wrapping top-level &lt;program&gt; with full-width &lt;sidebyside&gt;</xsl:with-param>
287
- </xsl:call-template>
288
- </xsl:template>
289
- <xsl:template match="console[not(parent::sidebyside or parent::listing)]">
290
- <sidebyside width="100%">
291
- <console>
292
- <xsl:apply-templates select="@* | node()" />
293
- </console>
294
- </sidebyside>
295
- <xsl:call-template name="deprecation-fix-report">
296
- <xsl:with-param name="date">2017-08-06</xsl:with-param>
297
- <xsl:with-param name="message">Wrapping top-level &lt;console&gt; with full-width &lt;sidebyside&gt;</xsl:with-param>
298
- </xsl:call-template>
299
- </xsl:template>
300
-
301
- <!-- 2017-08-04 top-level "task" become "exploration" -->
302
- <xsl:template match="task[parent::chapter or parent::appendix or parent::section or parent::subsection or parent::subsubsection or parent::paragraphs or parent::introduction or parent::conclusion]">
303
- <exploration>
304
- <xsl:apply-templates select="@* | node()" />
305
- </exploration>
306
- <xsl:call-template name="deprecation-fix-report">
307
- <xsl:with-param name="date">2017-08-04</xsl:with-param>
308
- <xsl:with-param name="message">Replacing &lt;task&gt; by &lt;exploration&gt;</xsl:with-param>
309
- </xsl:call-template>
310
- </xsl:template>
311
-
312
- <!-- 2017-07-25 replacement of three xref/@autoname attributes by @text -->
313
- <xsl:template match="@autoname">
314
- <xsl:variable name="old-value" select="string(.)" />
315
- <xsl:attribute name="text">
316
- <xsl:choose>
317
- <xsl:when test="$old-value = 'no'">global</xsl:when>
318
- <xsl:when test="$old-value = 'yes'">type-global</xsl:when>
319
- <xsl:when test="$old-value = 'title'">title</xsl:when>
320
- </xsl:choose>
321
- </xsl:attribute>
322
- </xsl:template>
323
-
324
- <!-- 2017-07-18: cosmetic changes to WeBWorK image attribute -->
325
- <xsl:template match="@tex_size">
326
- <xsl:attribute name="tex-size">
327
- <xsl:value-of select="." />
328
- </xsl:attribute>
329
- <xsl:call-template name="deprecation-fix-report">
330
- <xsl:with-param name="date">2017-07-18</xsl:with-param>
331
- <xsl:with-param name="message">Replacing @tex_size by @tex-size in WeBWorK &lt;image&gt;</xsl:with-param>
332
- </xsl:call-template>
333
- </xsl:template>
334
- <!-- -->
335
- <!-- 2017-07-14: cosmetic changes to index specification and production -->
336
- <xsl:template match="index-part">
337
- <index>
338
- <xsl:apply-templates select="@* | node()" />
339
- </index>
340
- <xsl:call-template name="deprecation-fix-report">
341
- <xsl:with-param name="date">2017-07-14</xsl:with-param>
342
- <xsl:with-param name="message">Replacing &lt;index-part&gt; by &lt;index&gt;</xsl:with-param>
343
- </xsl:call-template>
344
- </xsl:template>
345
- <!-- -->
346
- <!-- try not to clobber new "index" division on subsequent run -->
347
- <xsl:template match="index[not(index-list)]">
348
- <idx>
349
- <xsl:apply-templates select="@* | node()" />
350
- </idx>
351
- <xsl:call-template name="deprecation-fix-report">
352
- <xsl:with-param name="date">2017-07-14</xsl:with-param>
353
- <xsl:with-param name="message">Replacing &lt;index&gt; by &lt;idx&gt;</xsl:with-param>
354
- </xsl:call-template>
355
- </xsl:template>
356
- <!-- -->
357
- <xsl:template match="index/main">
358
- <h>
359
- <xsl:apply-templates select="@* | node()" />
360
- </h>
361
- <xsl:call-template name="deprecation-fix-report">
362
- <xsl:with-param name="date">2017-07-14</xsl:with-param>
363
- <xsl:with-param name="message">Replacing &lt;index&gt;/&lt;main&gt; by &lt;idx&gt;/&lt;h&gt;</xsl:with-param>
364
- </xsl:call-template>
365
- </xsl:template>
366
- <!-- -->
367
- <xsl:template match="index/sub">
368
- <h>
369
- <xsl:apply-templates select="@* | node()" />
370
- </h>
371
- <xsl:call-template name="deprecation-fix-report">
372
- <xsl:with-param name="date">2017-07-14</xsl:with-param>
373
- <xsl:with-param name="message">Replacing &lt;index&gt;/&lt;sub&gt; by &lt;idx&gt;/&lt;h&gt;</xsl:with-param>
374
- </xsl:call-template>
375
- </xsl:template>
376
-
377
- <!-- 2017-07-05: wrap a captioned side-by-side as a captioned figure -->
378
- <xsl:template match="sidebyside[caption]">
379
- <figure>
380
- <xsl:copy-of select="@xml:id" />
381
- <!-- <xsl:apply-templates select="@*[not(self::@xml:id)]" /> -->
382
- <xsl:text>&#xa;</xsl:text>
383
- <xsl:copy-of select="caption" />
384
- <xsl:text>&#xa; </xsl:text>
385
- <sidebyside>
386
- <xsl:apply-templates select="@*[name()!='xml:id'] | node()[not(self::caption)]" />
387
- </sidebyside>
388
- <xsl:text>&#xa;</xsl:text>
389
- </figure>
390
- <!-- -->
391
- <xsl:call-template name="deprecation-fix-report">
392
- <xsl:with-param name="date">2017-07-05</xsl:with-param>
393
- <xsl:with-param name="message">Moving a &lt;<xsl:value-of select="local-name(.)" />&gt; with a &lt;caption&gt; into a new &lt;figure&gt; with the same &lt;caption&gt; and @xml:id</xsl:with-param>
394
- </xsl:call-template>
395
- </xsl:template>
396
-
397
- <!-- 2017-07-05: convert top-level caption-less figure/table/listing to a side-by-side -->
398
- <!-- 2019-06-28: removed fixes for tables, since they now have titles -->
399
- <xsl:template match="figure[not(caption) and not(parent::sidebyside)] | listing[not(caption) and not(parent::sidebyside)]">
400
- <sidebyside>
401
- <!-- migrate an image width attribute -->
402
- <xsl:if test="self::figure and image[@width]">
403
- <xsl:copy-of select="image/@width" />
404
- </xsl:if>
405
- <xsl:apply-templates select="@* | node()" />
406
- </sidebyside>
407
- <!-- -->
408
- <xsl:call-template name="deprecation-fix-report">
409
- <xsl:with-param name="date">2017-07-05</xsl:with-param>
410
- <xsl:with-param name="message">Replacing &lt;<xsl:value-of select="local-name(.)" />&gt; that is a child of a division, and has no &lt;caption&gt;, by an equivalent &lt;sidebyside&gt;</xsl:with-param>
411
- </xsl:call-template>
412
- </xsl:template>
413
- <!-- @width moves above, now trash it at origin -->
414
- <xsl:template match="figure[not(caption) and not(parent::sidebyside)]/image">
415
- <image>
416
- <xsl:apply-templates select="@*[name()!='width'] | node()" />
417
- </image>
418
- </xsl:template>
419
-
420
- <xsl:template match="figure[not(caption) and parent::sidebyside] | listing[not(caption) and parent::sidebyside]">
421
- <xsl:if test="@xml:id">
422
- <xsl:comment>NOTE: @xml:id=<xsl:value-of select="@xml:id" /> from a &lt;<xsl:value-of select="local-name(.)" />&gt; was dropped while fixing deprecations. The @xml:id may belong on an element just below, though it is unlikely a caption-less item was ever the target of a cross-reference.</xsl:comment>
423
- </xsl:if>
424
- <xsl:apply-templates select="node()" />
425
- <!-- -->
426
- <xsl:call-template name="deprecation-fix-report">
427
- <xsl:with-param name="date">2017-07-05</xsl:with-param>
428
- <xsl:with-param name="message">Replacing a &lt;<xsl:value-of select="local-name(.)" />&gt; that is a child of a division, and has no &lt;caption&gt;, by an equivalent &lt;sidebyside&gt;. NOTE: attributes, such as an @xml:id might be lost in the process, see comment in the resulting source</xsl:with-param>
429
- </xsl:call-template>
430
- </xsl:template>
431
-
432
- <!-- 2017-02-05: replace hyphen element by hyphen-minus element -->
433
- <xsl:template match="hyphen">
434
- <hyphen-minus/>
435
- <!-- -->
436
- <xsl:call-template name="deprecation-fix-report">
437
- <xsl:with-param name="date">2017-02-05</xsl:with-param>
438
- <xsl:with-param name="message">Replacing &lt;hyphen/&gt; by &lt;hyphen-minus/&gt;</xsl:with-param>
439
- </xsl:call-template>
440
- </xsl:template>
441
-
442
- <!-- 2016-07-31: requiring @width attribute to be a percentage, -->
443
- <!-- no easy way to fix this, so warnings will have to suffice -->
444
-
445
- <!-- 2016-07-31: withdrew @height attribute on image element -->
446
- <xsl:template match="image/@height[not(ancestor::*[self::webwork])]">
447
- <!-- -->
448
- <xsl:call-template name="deprecation-fix-report">
449
- <xsl:with-param name="date">2016-07-31</xsl:with-param>
450
- <xsl:with-param name="message">Removing @height attribute of &lt;image&gt; (outside of a WeBWorK exercise)</xsl:with-param>
451
- </xsl:call-template>
452
- </xsl:template>
453
-
454
- <!-- 2016-05-23: empty "br" elements for multiline output are banned -->
455
- <!-- No easy way to uniformly fix this, so warnings will have to suffice -->
456
-
457
- <!-- 2016-05-23: parts of a letter or memorandum suggest -->
458
- <!-- they *must* be structured with "line" elements -->
459
- <!-- Perhaps more accurate to just warn about misuse of "br", -->
460
- <!-- as we can go with mixed-content or structured versions -->
461
-
462
- <!-- 2016-04-27: withdrew pluralizing prefix names in xref link text -->
463
- <xsl:template match="xref/@autoname[. = 'plural']">
464
- <!-- -->
465
- <xsl:call-template name="deprecation-fix-report">
466
- <xsl:with-param name="date">2016-04-27</xsl:with-param>
467
- <xsl:with-param name="message">Removing @autoname attribute of &lt;xref&gt; set to obsolete value 'plural'</xsl:with-param>
468
- </xsl:call-template>
469
- </xsl:template>
470
-
471
- <!-- 2015-12-12: an ordered list with blank labels -->
472
- <!-- should be an unordered list with blank labels -->
473
- <xsl:template match="ol[@label='']">
474
- <ul>
475
- <xsl:apply-templates select="@* | node()" />
476
- </ul>
477
- <!-- -->
478
- <xsl:call-template name="deprecation-fix-report">
479
- <xsl:with-param name="date">2015-12-12</xsl:with-param>
480
- <xsl:with-param name="message">Replacing &lt;ol&gt; with empty labels by a &lt;ul&gt;</xsl:with-param>
481
- </xsl:call-template>
482
- </xsl:template>
483
-
484
- <!-- 2015-03-17: tables are very different -->
485
- <!-- Some automated fixing, will -->
486
- <!-- need attention by hand also -->
487
- <!-- -->
488
- <!-- enclosing tgroup becomes a tabular -->
489
- <xsl:template match="tgroup">
490
- <tabular>
491
- <xsl:apply-templates select="@* | node()" />
492
- </tabular>
493
- <!-- -->
494
- <xsl:call-template name="deprecation-fix-report">
495
- <xsl:with-param name="date">2015-03-17</xsl:with-param>
496
- <xsl:with-param name="message">Replacing &lt;tgroup&gt; by &lt;tabular&gt;, tables are now very different</xsl:with-param>
497
- </xsl:call-template>
498
- </xsl:template>
499
- <!-- alignment is different, will require a hand-fix -->
500
- <xsl:template match="tgroup/@align|tgroup/@cols">
501
- <!-- -->
502
- <xsl:call-template name="deprecation-fix-report">
503
- <xsl:with-param name="date">2015-03-17</xsl:with-param>
504
- <xsl:with-param name="message">Removing obsolete @align and @cols attributes, adjust alignment of contents of tabular by hand</xsl:with-param>
505
- </xsl:call-template>
506
- </xsl:template>
507
- <!-- drop intermediate thead and tbody -->
508
- <xsl:template match="thead|tbody">
509
- <xsl:apply-templates select="@* | node()" />
510
- <!-- -->
511
- <xsl:call-template name="deprecation-fix-report">
512
- <xsl:with-param name="date">2015-03-17</xsl:with-param>
513
- <xsl:with-param name="message">Removing intermediate &lt;thead&gt; and &lt;tbody&gt;</xsl:with-param>
514
- </xsl:call-template>
515
- </xsl:template>
516
- <!-- maybe we'll recycle entry for something else, so protect it -->
517
- <xsl:template match="row/entry">
518
- <cell>
519
- <xsl:apply-templates select="@* | node()" />
520
- </cell>
521
- <!-- -->
522
- <xsl:call-template name="deprecation-fix-report">
523
- <xsl:with-param name="date">2015-03-17</xsl:with-param>
524
- <xsl:with-param name="message">Replacing &lt;entry&gt; by &lt;cell&gt; in a &lt;row&gt;</xsl:with-param>
525
- </xsl:call-template>
526
- </xsl:template>
527
-
528
- <!-- 2015-03-13: the paragraph lightweight sectioning is better in plural -->
529
- <xsl:template match="paragraph">
530
- <paragraphs>
531
- <xsl:apply-templates select="@* | node()" />
532
- </paragraphs>
533
- <!-- -->
534
- <xsl:call-template name="deprecation-fix-report">
535
- <xsl:with-param name="date">2015-03-13</xsl:with-param>
536
- <xsl:with-param name="message">Replacing &lt;paragraph&gt; by &lt;paragraphs&gt;</xsl:with-param>
537
- </xsl:call-template>
538
- </xsl:template>
539
-
540
- <!-- 2015-01-28: <circum /> is gone, <circumflex /> won -->
541
- <xsl:template match="circum">
542
- <circumflex>
543
- <xsl:apply-templates select="@* | node()" />
544
- </circumflex>
545
- <!-- -->
546
- <xsl:call-template name="deprecation-fix-report">
547
- <xsl:with-param name="date">2014-06-25</xsl:with-param>
548
- <xsl:with-param name="message">Replacing &lt;circumflex/&gt; by &lt;circum/&gt;</xsl:with-param>
549
- </xsl:call-template>
550
- </xsl:template>
551
-
552
- <!-- 2014-06-25: <cite> gone, replace directly with <xref> -->
553
- <xsl:template match="cite">
554
- <xref>
555
- <xsl:apply-templates select="@* | node()" />
556
- </xref>
557
- <!-- -->
558
- <xsl:call-template name="deprecation-fix-report">
559
- <xsl:with-param name="date">2014-06-25</xsl:with-param>
560
- <xsl:with-param name="message">Replacing &lt;cite&gt; by &lt;xref&gt;</xsl:with-param>
561
- </xsl:call-template>
562
- </xsl:template>
563
-
564
- <!-- 2014-05-04: @filebase attributes is obsolete, we drop it -->
565
- <!-- Author's responsibility to introduce/adjust an @xml:id -->
566
- <xsl:template match="@filebase">
567
- <!-- -->
568
- <xsl:call-template name="deprecation-fix-report">
569
- <xsl:with-param name="date">2014-05-04</xsl:with-param>
570
- <xsl:with-param name="message">Removing obsolete @filebase attribute, introduce or adjust an @xml:id to play this role</xsl:with-param>
571
- </xsl:call-template>
572
- </xsl:template>
573
-
574
- <!-- ######################### -->
575
- <!-- Stylesheet Infrastructure -->
576
- <!-- ######################### -->
577
-
578
- <!-- We place these templates at the end, -->
579
- <!-- the deprecations above are the items of -->
580
- <!-- interest, in reverse chronological order -->
581
-
582
- <!-- We do a few things to get started -->
583
- <!-- We override matching the root element of the -->
584
- <!-- imported worksheet with the identity template, -->
585
- <!-- and then resume walking the tree -->
586
-
587
- <!-- Switch to prevent naive use -->
588
- <xsl:param name="fix" select="'no'" />
589
-
590
- <xsl:template match="/">
591
- <xsl:choose>
592
- <!-- print to console and quit -->
593
- <xsl:when test="$fix = 'no'">
594
- <xsl:call-template name="instructions" />
595
- </xsl:when>
596
- <!-- modal run on root to just change source cosmetically -->
597
- <xsl:when test="$fix = 'normalize'">
598
- <xsl:apply-templates select="." mode="normalize"/>
599
- </xsl:when>
600
- <!-- default templates on children to actually change source -->
601
- <xsl:when test="$fix = 'all'">
602
- <xsl:copy>
603
- <xsl:apply-templates select="@* | node()" />
604
- </xsl:copy>
605
- </xsl:when>
606
- <xsl:otherwise>
607
- <xsl:message>The parameter "fix" must be set to 'no', 'normalize', or 'all'. Assuming 'no'.</xsl:message>
608
- </xsl:otherwise>
609
- </xsl:choose>
610
- </xsl:template>
611
-
612
- <xsl:template name="instructions">
613
- <xsl:message terminate="yes">
614
- <text>* *&#xa;</text>
615
- <text>* The "fix-deprecations" stylesheet will change your source files *&#xa;</text>
616
- <text>* *&#xa;</text>
617
- <text>* 1. Experiment on copies and keep good backups *&#xa;</text>
618
- <text>* 2. Send output to a file in some other directory than originals *&#xa;</text>
619
- <text>* 3. Do not enable xinclude processing if you want modular files *&#xa;</text>
620
- <text>* 4. Indentation and whitespace will be preserved *&#xa;</text>
621
- <text>* 5. Attributes will likely be re-ordered, with normalized spacing *&#xa;</text>
622
- <text>* 6. Empty elements will have spaces removed from the tag *&#xa;</text>
623
- <text>* 7. Elements with no content may be written with a single empty tag *&#xa;</text>
624
- <text>* 8. CDATA sections will have some characters replaced by entities *&#xa;</text>
625
- <text>* 9. The output files will be labeled as having UTF-8 encoding *&#xa;</text>
626
- <text>* 10. It might be necessary to run this more than once *&#xa;</text>
627
- <text>* 11. Be sure to inspect the results, perhaps using a "diff" tool *&#xa;</text>
628
- <text>* 12. It should be safe to run this repeatedly, even after updates *&#xa;</text>
629
- <text>* *&#xa;</text>
630
- <text>* Quitting now. Instructions: *&#xa;</text>
631
- <text>* *&#xa;</text>
632
- <text>* To use, and confirm you have read this far, use a parameter on the *&#xa;</text>
633
- <text>* command line that sets the parameter "fix" to the value 'all' *&#xa;</text>
634
- <text>* *&#xa;</text>
635
- <text>* Set the parameter "fix" to 'normalize' to only adjust source format *&#xa;</text>
636
- <text>* (This might be a useful first step the first time you use this) *&#xa;</text>
637
- <text>* *&#xa;</text>
638
- </xsl:message>
639
- </xsl:template>
640
-
641
- <!-- A template to report to console, so we can adjust later -->
642
- <xsl:template name="deprecation-fix-report">
643
- <xsl:param name="message" select="''" />
644
- <xsl:param name="date" select="''" />
645
- <xsl:message><xsl:value-of select="$message" /> (from <xsl:value-of select="$date" />)</xsl:message>
646
- </xsl:template>
647
-
648
- <!-- Walk the tree, copying everything as-is -->
649
- <!-- with templates above as exceptions -->
650
- <xsl:template match="@* | node()">
651
- <xsl:copy>
652
- <xsl:apply-templates select="@* | node()" />
653
- </xsl:copy>
654
- </xsl:template>
655
-
656
- <!-- Walk the tree, copying everything *exactly* -->
657
- <xsl:template match="@* | node()" mode="normalize">
658
- <xsl:copy>
659
- <xsl:apply-templates select="@* | node()" mode="normalize" />
660
- </xsl:copy>
661
- </xsl:template>
662
-
663
- </xsl:stylesheet>
1
+ <?xml version='1.0'?>
2
+
3
+ <!--********************************************************************
4
+ Copyright 2017 Robert A. Beezer
5
+
6
+ This file is part of MathBook XML.
7
+
8
+ MathBook XML is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 2 or version 3 of the
11
+ License (at your option).
12
+
13
+ MathBook XML is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
20
+ *********************************************************************-->
21
+
22
+ <!-- Identify as a stylesheet -->
23
+ <xsl:stylesheet
24
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
25
+ exclude-result-prefixes="xsl"
26
+ >
27
+
28
+ <xsl:output method="xml" encoding="UTF-8" />
29
+
30
+ <!-- ###################### -->
31
+ <!-- Deprecations and Fixes -->
32
+ <!-- ###################### -->
33
+
34
+ <!-- Deprecations that can be fixed with a transformation -->
35
+ <!-- In reverse chronological order, with dates -->
36
+
37
+ <!-- 2020-03-13 webwork setup obsolete -->
38
+ <xsl:template match="webwork/setup">
39
+ <xsl:apply-templates select="@* | node()" />
40
+ <xsl:call-template name="deprecation-fix-report">
41
+ <xsl:with-param name="date">2020-03-13</xsl:with-param>
42
+ <xsl:with-param name="message">Removing &lt;setup&gt; wrapper from a &lt;webwork&gt;, preserving contents (&lt;pg-code&gt;?)</xsl:with-param>
43
+ </xsl:call-template>
44
+ </xsl:template>
45
+
46
+ <!-- 2019-06-28 deprecate captioned lists to be titled lists -->
47
+ <xsl:template match="list[title]/caption">
48
+ <xsl:comment>
49
+ <xsl:text>Commented list/caption: </xsl:text>
50
+ <xsl:apply-templates select="*|text()" />
51
+ </xsl:comment>
52
+ <xsl:call-template name="deprecation-fix-report">
53
+ <xsl:with-param name="date">2019-06-28</xsl:with-param>
54
+ <xsl:with-param name="message">Converting a &lt;list&gt;/&lt;caption&gt; to a source comment</xsl:with-param>
55
+ </xsl:call-template>
56
+ </xsl:template>
57
+
58
+ <!-- 2019-06-28 deprecate captioned lists to be titled lists -->
59
+ <xsl:template match="list[not(title)]/caption">
60
+ <title>
61
+ <xsl:apply-templates select="@* | node()" />
62
+ </title>
63
+ <xsl:call-template name="deprecation-fix-report">
64
+ <xsl:with-param name="date">2019-06-28</xsl:with-param>
65
+ <xsl:with-param name="message">Converting a &lt;list&gt;/&lt;caption&gt; to a &lt;list&gt;/&lt;title&gt;</xsl:with-param>
66
+ </xsl:call-template>
67
+ </xsl:template>
68
+
69
+ <!-- 2019-06-28 deprecate captioned tables to be titled tables -->
70
+ <xsl:template match="table/caption">
71
+ <title>
72
+ <xsl:apply-templates select="@* | node()" />
73
+ </title>
74
+ <xsl:call-template name="deprecation-fix-report">
75
+ <xsl:with-param name="date">2019-06-28</xsl:with-param>
76
+ <xsl:with-param name="message">Converting a &lt;table&gt;/&lt;caption&gt; to a &lt;table&gt;/&lt;title&gt;</xsl:with-param>
77
+ </xsl:call-template>
78
+ </xsl:template>
79
+
80
+ <!-- 2019-02-10 todo element replaced by a prefixed XML comment -->
81
+ <xsl:template match="todo">
82
+ <xsl:comment>
83
+ <xsl:text> </xsl:text>
84
+ <xsl:text>ToDo: </xsl:text>
85
+ <xsl:apply-templates/>
86
+ <xsl:text> </xsl:text>
87
+ </xsl:comment>
88
+ <xsl:call-template name="deprecation-fix-report">
89
+ <xsl:with-param name="date">2019-02-10</xsl:with-param>
90
+ <xsl:with-param name="message">Replacing a &lt;todo&gt; with a prefixed XML comment</xsl:with-param>
91
+ </xsl:call-template>
92
+ </xsl:template>
93
+
94
+ <!-- 2019-02-06 Nine unnecessary elements -->
95
+ <!-- <, >, [, ], *, /, `, braces and brackets -->
96
+ <xsl:template match="less">
97
+ <xsl:text>&lt;</xsl:text>
98
+ <xsl:call-template name="deprecation-fix-report">
99
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
100
+ <xsl:with-param name="message">Replacing &lt;less/&gt; with &quot;&lt;&quot;</xsl:with-param>
101
+ </xsl:call-template>
102
+ </xsl:template>
103
+ <xsl:template match="greater">
104
+ <xsl:text>&gt;</xsl:text>
105
+ <xsl:call-template name="deprecation-fix-report">
106
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
107
+ <xsl:with-param name="message">Replacing &lt;greater/&gt; with &quot;&gt;&quot;</xsl:with-param>
108
+ </xsl:call-template>
109
+ </xsl:template>
110
+ <xsl:template match="lbracket">
111
+ <xsl:text>[</xsl:text>
112
+ <xsl:call-template name="deprecation-fix-report">
113
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
114
+ <xsl:with-param name="message">Replacing &lt;lbracket/&gt; with &quot;[&quot;</xsl:with-param>
115
+ </xsl:call-template>
116
+ </xsl:template>
117
+ <xsl:template match="rbracket">
118
+ <xsl:text>]</xsl:text>
119
+ <xsl:call-template name="deprecation-fix-report">
120
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
121
+ <xsl:with-param name="message">Replacing &lt;rbracket/&gt; with &quot;]&quot;</xsl:with-param>
122
+ </xsl:call-template>
123
+ </xsl:template>
124
+ <xsl:template match="asterisk">
125
+ <xsl:text>*</xsl:text>
126
+ <xsl:call-template name="deprecation-fix-report">
127
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
128
+ <xsl:with-param name="message">Replacing &lt;asterisk/&gt; with &quot;*&quot;</xsl:with-param>
129
+ </xsl:call-template>
130
+ </xsl:template>
131
+ <xsl:template match="slash">
132
+ <xsl:text>/</xsl:text>
133
+ <xsl:call-template name="deprecation-fix-report">
134
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
135
+ <xsl:with-param name="message">Replacing &lt;slash/&gt; with &quot;/&quot;</xsl:with-param>
136
+ </xsl:call-template>
137
+ </xsl:template>
138
+ <xsl:template match="backtick">
139
+ <xsl:text>`</xsl:text>
140
+ <xsl:call-template name="deprecation-fix-report">
141
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
142
+ <xsl:with-param name="message">Replacing &lt;backtick/&gt; with &quot;`&quot;</xsl:with-param>
143
+ </xsl:call-template>
144
+ </xsl:template>
145
+ <xsl:template match="braces">
146
+ <xsl:text>{</xsl:text>
147
+ <xsl:apply-templates select="@* | node()" />
148
+ <xsl:text>}</xsl:text>
149
+ <xsl:call-template name="deprecation-fix-report">
150
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
151
+ <xsl:with-param name="message">Replacing &lt;braces&gt; by {...}</xsl:with-param>
152
+ </xsl:call-template>
153
+ </xsl:template>
154
+ <xsl:template match="brackets">
155
+ <xsl:text>[</xsl:text>
156
+ <xsl:apply-templates select="@* | node()" />
157
+ <xsl:text>]</xsl:text>
158
+ <xsl:call-template name="deprecation-fix-report">
159
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
160
+ <xsl:with-param name="message">Replacing &lt;brackets&gt; by [...]</xsl:with-param>
161
+ </xsl:call-template>
162
+ </xsl:template>
163
+
164
+ <!-- 2019-02-06 LaTeX's 10 reserved characters: # $ % ^ & _ { } ~ \ -->
165
+ <xsl:template match="hash">
166
+ <xsl:text>#</xsl:text>
167
+ <xsl:call-template name="deprecation-fix-report">
168
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
169
+ <xsl:with-param name="message">Replacing &lt;hash/&gt; with &quot;#&quot;</xsl:with-param>
170
+ </xsl:call-template>
171
+ </xsl:template>
172
+ <xsl:template match="dollar">
173
+ <xsl:text>$</xsl:text>
174
+ <xsl:call-template name="deprecation-fix-report">
175
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
176
+ <xsl:with-param name="message">Replacing &lt;dollar/&gt; with &quot;$&quot;</xsl:with-param>
177
+ </xsl:call-template>
178
+ </xsl:template>
179
+ <xsl:template match="percent">
180
+ <xsl:text>%</xsl:text>
181
+ <xsl:call-template name="deprecation-fix-report">
182
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
183
+ <xsl:with-param name="message">Replacing &lt;percent/&gt; with &quot;%&quot;</xsl:with-param>
184
+ </xsl:call-template>
185
+ </xsl:template>
186
+ <xsl:template match="circumflex">
187
+ <xsl:text>^</xsl:text>
188
+ <xsl:call-template name="deprecation-fix-report">
189
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
190
+ <xsl:with-param name="message">Replacing &lt;circumflex/&gt; with &quot;^&quot;</xsl:with-param>
191
+ </xsl:call-template>
192
+ </xsl:template>
193
+ <xsl:template match="ampersand">
194
+ <xsl:text>&amp;</xsl:text>
195
+ <xsl:call-template name="deprecation-fix-report">
196
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
197
+ <xsl:with-param name="message">Replacing &lt;ampersand/&gt; with &quot;&amp;&quot;</xsl:with-param>
198
+ </xsl:call-template>
199
+ </xsl:template>
200
+ <xsl:template match="underscore">
201
+ <xsl:text>_</xsl:text>
202
+ <xsl:call-template name="deprecation-fix-report">
203
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
204
+ <xsl:with-param name="message">Replacing &lt;underscore/&gt; with &quot;_&quot;</xsl:with-param>
205
+ </xsl:call-template>
206
+ </xsl:template>
207
+ <xsl:template match="lbrace">
208
+ <xsl:text>{</xsl:text>
209
+ <xsl:call-template name="deprecation-fix-report">
210
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
211
+ <xsl:with-param name="message">Replacing &lt;lbrace/&gt; with &quot;{&quot;</xsl:with-param>
212
+ </xsl:call-template>
213
+ </xsl:template>
214
+ <xsl:template match="rbrace">
215
+ <xsl:text>}</xsl:text>
216
+ <xsl:call-template name="deprecation-fix-report">
217
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
218
+ <xsl:with-param name="message">Replacing &lt;rbrace/&gt; with &quot;}&quot;</xsl:with-param>
219
+ </xsl:call-template>
220
+ </xsl:template>
221
+ <xsl:template match="tilde">
222
+ <xsl:text>~</xsl:text>
223
+ <xsl:call-template name="deprecation-fix-report">
224
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
225
+ <xsl:with-param name="message">Replacing &lt;tilde/&gt; with &quot;~&quot;</xsl:with-param>
226
+ </xsl:call-template>
227
+ </xsl:template>
228
+ <xsl:template match="backslash">
229
+ <xsl:text>\</xsl:text>
230
+ <xsl:call-template name="deprecation-fix-report">
231
+ <xsl:with-param name="date">2019-02-06</xsl:with-param>
232
+ <xsl:with-param name="message">Replacing &lt;backslash/&gt; with &quot;\&quot;</xsl:with-param>
233
+ </xsl:call-template>
234
+ </xsl:template>
235
+
236
+ <!-- 2018-12-30 circa shortened to ca -->
237
+ <xsl:template match="circa">
238
+ <ca/>
239
+ <xsl:call-template name="deprecation-fix-report">
240
+ <xsl:with-param name="date">2018-12-30</xsl:with-param>
241
+ <xsl:with-param name="message">Replacing &lt;circa/&gt; by &lt;ca/&gt;</xsl:with-param>
242
+ </xsl:call-template>
243
+ </xsl:template>
244
+
245
+ <!-- 2018-05-02 sidebyside paragraphs to stack, preserve title -->
246
+ <xsl:template match="sidebyside/paragraphs">
247
+ <stack>
248
+ <xsl:comment> Old paragraphs title: <xsl:apply-templates select="title/node()" /> </xsl:comment>
249
+ <xsl:apply-templates select="@*[not(self::title)] | node()" />
250
+ </stack>
251
+ <xsl:call-template name="deprecation-fix-report">
252
+ <xsl:with-param name="date">2018-05-02</xsl:with-param>
253
+ <xsl:with-param name="message">Replacing &lt;paragraphs&gt; inside &lt;sidebyside&gt; with &lt;stack&gt;, &quot;title&quot; preserved in a comment</xsl:with-param>
254
+ </xsl:call-template>
255
+ </xsl:template>
256
+
257
+ <!-- 2018-02-05 booktitle to simply pubtitle -->
258
+ <xsl:template match="booktitle">
259
+ <pubtitle>
260
+ <xsl:apply-templates select="@* | node()" />
261
+ </pubtitle>
262
+ <xsl:call-template name="deprecation-fix-report">
263
+ <xsl:with-param name="date">2018-02-05</xsl:with-param>
264
+ <xsl:with-param name="message">Replacing &lt;booktitle&gt; by &lt;pubtitle&gt;</xsl:with-param>
265
+ </xsl:call-template>
266
+ </xsl:template>
267
+
268
+ <!-- 2017-12-07 "c" content totally escaped for LaTeX -->
269
+ <xsl:template match="c/@latexsep|cd/@latexsep">
270
+ <!-- do nothing, just drop it and report -->
271
+ <xsl:call-template name="deprecation-fix-report">
272
+ <xsl:with-param name="date">2017-12-07</xsl:with-param>
273
+ <xsl:with-param name="message">Removing &lt;@latexsep&gt; from a &lt;c&gt; or &lt;cd&gt; element</xsl:with-param>
274
+ </xsl:call-template>
275
+ </xsl:template>
276
+
277
+ <!-- 2017-08-06 wrap "program" and "console" in "sidebyside" at full width -->
278
+ <xsl:template match="program[not(parent::sidebyside or parent::listing)]">
279
+ <sidebyside width="100%">
280
+ <program>
281
+ <xsl:apply-templates select="@* | node()" />
282
+ </program>
283
+ </sidebyside>
284
+ <xsl:call-template name="deprecation-fix-report">
285
+ <xsl:with-param name="date">2017-08-06</xsl:with-param>
286
+ <xsl:with-param name="message">Wrapping top-level &lt;program&gt; with full-width &lt;sidebyside&gt;</xsl:with-param>
287
+ </xsl:call-template>
288
+ </xsl:template>
289
+ <xsl:template match="console[not(parent::sidebyside or parent::listing)]">
290
+ <sidebyside width="100%">
291
+ <console>
292
+ <xsl:apply-templates select="@* | node()" />
293
+ </console>
294
+ </sidebyside>
295
+ <xsl:call-template name="deprecation-fix-report">
296
+ <xsl:with-param name="date">2017-08-06</xsl:with-param>
297
+ <xsl:with-param name="message">Wrapping top-level &lt;console&gt; with full-width &lt;sidebyside&gt;</xsl:with-param>
298
+ </xsl:call-template>
299
+ </xsl:template>
300
+
301
+ <!-- 2017-08-04 top-level "task" become "exploration" -->
302
+ <xsl:template match="task[parent::chapter or parent::appendix or parent::section or parent::subsection or parent::subsubsection or parent::paragraphs or parent::introduction or parent::conclusion]">
303
+ <exploration>
304
+ <xsl:apply-templates select="@* | node()" />
305
+ </exploration>
306
+ <xsl:call-template name="deprecation-fix-report">
307
+ <xsl:with-param name="date">2017-08-04</xsl:with-param>
308
+ <xsl:with-param name="message">Replacing &lt;task&gt; by &lt;exploration&gt;</xsl:with-param>
309
+ </xsl:call-template>
310
+ </xsl:template>
311
+
312
+ <!-- 2017-07-25 replacement of three xref/@autoname attributes by @text -->
313
+ <xsl:template match="@autoname">
314
+ <xsl:variable name="old-value" select="string(.)" />
315
+ <xsl:attribute name="text">
316
+ <xsl:choose>
317
+ <xsl:when test="$old-value = 'no'">global</xsl:when>
318
+ <xsl:when test="$old-value = 'yes'">type-global</xsl:when>
319
+ <xsl:when test="$old-value = 'title'">title</xsl:when>
320
+ </xsl:choose>
321
+ </xsl:attribute>
322
+ </xsl:template>
323
+
324
+ <!-- 2017-07-18: cosmetic changes to WeBWorK image attribute -->
325
+ <xsl:template match="@tex_size">
326
+ <xsl:attribute name="tex-size">
327
+ <xsl:value-of select="." />
328
+ </xsl:attribute>
329
+ <xsl:call-template name="deprecation-fix-report">
330
+ <xsl:with-param name="date">2017-07-18</xsl:with-param>
331
+ <xsl:with-param name="message">Replacing @tex_size by @tex-size in WeBWorK &lt;image&gt;</xsl:with-param>
332
+ </xsl:call-template>
333
+ </xsl:template>
334
+ <!-- -->
335
+ <!-- 2017-07-14: cosmetic changes to index specification and production -->
336
+ <xsl:template match="index-part">
337
+ <index>
338
+ <xsl:apply-templates select="@* | node()" />
339
+ </index>
340
+ <xsl:call-template name="deprecation-fix-report">
341
+ <xsl:with-param name="date">2017-07-14</xsl:with-param>
342
+ <xsl:with-param name="message">Replacing &lt;index-part&gt; by &lt;index&gt;</xsl:with-param>
343
+ </xsl:call-template>
344
+ </xsl:template>
345
+ <!-- -->
346
+ <!-- try not to clobber new "index" division on subsequent run -->
347
+ <xsl:template match="index[not(index-list)]">
348
+ <idx>
349
+ <xsl:apply-templates select="@* | node()" />
350
+ </idx>
351
+ <xsl:call-template name="deprecation-fix-report">
352
+ <xsl:with-param name="date">2017-07-14</xsl:with-param>
353
+ <xsl:with-param name="message">Replacing &lt;index&gt; by &lt;idx&gt;</xsl:with-param>
354
+ </xsl:call-template>
355
+ </xsl:template>
356
+ <!-- -->
357
+ <xsl:template match="index/main">
358
+ <h>
359
+ <xsl:apply-templates select="@* | node()" />
360
+ </h>
361
+ <xsl:call-template name="deprecation-fix-report">
362
+ <xsl:with-param name="date">2017-07-14</xsl:with-param>
363
+ <xsl:with-param name="message">Replacing &lt;index&gt;/&lt;main&gt; by &lt;idx&gt;/&lt;h&gt;</xsl:with-param>
364
+ </xsl:call-template>
365
+ </xsl:template>
366
+ <!-- -->
367
+ <xsl:template match="index/sub">
368
+ <h>
369
+ <xsl:apply-templates select="@* | node()" />
370
+ </h>
371
+ <xsl:call-template name="deprecation-fix-report">
372
+ <xsl:with-param name="date">2017-07-14</xsl:with-param>
373
+ <xsl:with-param name="message">Replacing &lt;index&gt;/&lt;sub&gt; by &lt;idx&gt;/&lt;h&gt;</xsl:with-param>
374
+ </xsl:call-template>
375
+ </xsl:template>
376
+
377
+ <!-- 2017-07-05: wrap a captioned side-by-side as a captioned figure -->
378
+ <xsl:template match="sidebyside[caption]">
379
+ <figure>
380
+ <xsl:copy-of select="@xml:id" />
381
+ <!-- <xsl:apply-templates select="@*[not(self::@xml:id)]" /> -->
382
+ <xsl:text>&#xa;</xsl:text>
383
+ <xsl:copy-of select="caption" />
384
+ <xsl:text>&#xa; </xsl:text>
385
+ <sidebyside>
386
+ <xsl:apply-templates select="@*[name()!='xml:id'] | node()[not(self::caption)]" />
387
+ </sidebyside>
388
+ <xsl:text>&#xa;</xsl:text>
389
+ </figure>
390
+ <!-- -->
391
+ <xsl:call-template name="deprecation-fix-report">
392
+ <xsl:with-param name="date">2017-07-05</xsl:with-param>
393
+ <xsl:with-param name="message">Moving a &lt;<xsl:value-of select="local-name(.)" />&gt; with a &lt;caption&gt; into a new &lt;figure&gt; with the same &lt;caption&gt; and @xml:id</xsl:with-param>
394
+ </xsl:call-template>
395
+ </xsl:template>
396
+
397
+ <!-- 2017-07-05: convert top-level caption-less figure/table/listing to a side-by-side -->
398
+ <!-- 2019-06-28: removed fixes for tables, since they now have titles -->
399
+ <xsl:template match="figure[not(caption) and not(parent::sidebyside)] | listing[not(caption) and not(parent::sidebyside)]">
400
+ <sidebyside>
401
+ <!-- migrate an image width attribute -->
402
+ <xsl:if test="self::figure and image[@width]">
403
+ <xsl:copy-of select="image/@width" />
404
+ </xsl:if>
405
+ <xsl:apply-templates select="@* | node()" />
406
+ </sidebyside>
407
+ <!-- -->
408
+ <xsl:call-template name="deprecation-fix-report">
409
+ <xsl:with-param name="date">2017-07-05</xsl:with-param>
410
+ <xsl:with-param name="message">Replacing &lt;<xsl:value-of select="local-name(.)" />&gt; that is a child of a division, and has no &lt;caption&gt;, by an equivalent &lt;sidebyside&gt;</xsl:with-param>
411
+ </xsl:call-template>
412
+ </xsl:template>
413
+ <!-- @width moves above, now trash it at origin -->
414
+ <xsl:template match="figure[not(caption) and not(parent::sidebyside)]/image">
415
+ <image>
416
+ <xsl:apply-templates select="@*[name()!='width'] | node()" />
417
+ </image>
418
+ </xsl:template>
419
+
420
+ <xsl:template match="figure[not(caption) and parent::sidebyside] | listing[not(caption) and parent::sidebyside]">
421
+ <xsl:if test="@xml:id">
422
+ <xsl:comment>NOTE: @xml:id=<xsl:value-of select="@xml:id" /> from a &lt;<xsl:value-of select="local-name(.)" />&gt; was dropped while fixing deprecations. The @xml:id may belong on an element just below, though it is unlikely a caption-less item was ever the target of a cross-reference.</xsl:comment>
423
+ </xsl:if>
424
+ <xsl:apply-templates select="node()" />
425
+ <!-- -->
426
+ <xsl:call-template name="deprecation-fix-report">
427
+ <xsl:with-param name="date">2017-07-05</xsl:with-param>
428
+ <xsl:with-param name="message">Replacing a &lt;<xsl:value-of select="local-name(.)" />&gt; that is a child of a division, and has no &lt;caption&gt;, by an equivalent &lt;sidebyside&gt;. NOTE: attributes, such as an @xml:id might be lost in the process, see comment in the resulting source</xsl:with-param>
429
+ </xsl:call-template>
430
+ </xsl:template>
431
+
432
+ <!-- 2017-02-05: replace hyphen element by hyphen-minus element -->
433
+ <xsl:template match="hyphen">
434
+ <hyphen-minus/>
435
+ <!-- -->
436
+ <xsl:call-template name="deprecation-fix-report">
437
+ <xsl:with-param name="date">2017-02-05</xsl:with-param>
438
+ <xsl:with-param name="message">Replacing &lt;hyphen/&gt; by &lt;hyphen-minus/&gt;</xsl:with-param>
439
+ </xsl:call-template>
440
+ </xsl:template>
441
+
442
+ <!-- 2016-07-31: requiring @width attribute to be a percentage, -->
443
+ <!-- no easy way to fix this, so warnings will have to suffice -->
444
+
445
+ <!-- 2016-07-31: withdrew @height attribute on image element -->
446
+ <xsl:template match="image/@height[not(ancestor::*[self::webwork])]">
447
+ <!-- -->
448
+ <xsl:call-template name="deprecation-fix-report">
449
+ <xsl:with-param name="date">2016-07-31</xsl:with-param>
450
+ <xsl:with-param name="message">Removing @height attribute of &lt;image&gt; (outside of a WeBWorK exercise)</xsl:with-param>
451
+ </xsl:call-template>
452
+ </xsl:template>
453
+
454
+ <!-- 2016-05-23: empty "br" elements for multiline output are banned -->
455
+ <!-- No easy way to uniformly fix this, so warnings will have to suffice -->
456
+
457
+ <!-- 2016-05-23: parts of a letter or memorandum suggest -->
458
+ <!-- they *must* be structured with "line" elements -->
459
+ <!-- Perhaps more accurate to just warn about misuse of "br", -->
460
+ <!-- as we can go with mixed-content or structured versions -->
461
+
462
+ <!-- 2016-04-27: withdrew pluralizing prefix names in xref link text -->
463
+ <xsl:template match="xref/@autoname[. = 'plural']">
464
+ <!-- -->
465
+ <xsl:call-template name="deprecation-fix-report">
466
+ <xsl:with-param name="date">2016-04-27</xsl:with-param>
467
+ <xsl:with-param name="message">Removing @autoname attribute of &lt;xref&gt; set to obsolete value 'plural'</xsl:with-param>
468
+ </xsl:call-template>
469
+ </xsl:template>
470
+
471
+ <!-- 2015-12-12: an ordered list with blank labels -->
472
+ <!-- should be an unordered list with blank labels -->
473
+ <xsl:template match="ol[@label='']">
474
+ <ul>
475
+ <xsl:apply-templates select="@* | node()" />
476
+ </ul>
477
+ <!-- -->
478
+ <xsl:call-template name="deprecation-fix-report">
479
+ <xsl:with-param name="date">2015-12-12</xsl:with-param>
480
+ <xsl:with-param name="message">Replacing &lt;ol&gt; with empty labels by a &lt;ul&gt;</xsl:with-param>
481
+ </xsl:call-template>
482
+ </xsl:template>
483
+
484
+ <!-- 2015-03-17: tables are very different -->
485
+ <!-- Some automated fixing, will -->
486
+ <!-- need attention by hand also -->
487
+ <!-- -->
488
+ <!-- enclosing tgroup becomes a tabular -->
489
+ <xsl:template match="tgroup">
490
+ <tabular>
491
+ <xsl:apply-templates select="@* | node()" />
492
+ </tabular>
493
+ <!-- -->
494
+ <xsl:call-template name="deprecation-fix-report">
495
+ <xsl:with-param name="date">2015-03-17</xsl:with-param>
496
+ <xsl:with-param name="message">Replacing &lt;tgroup&gt; by &lt;tabular&gt;, tables are now very different</xsl:with-param>
497
+ </xsl:call-template>
498
+ </xsl:template>
499
+ <!-- alignment is different, will require a hand-fix -->
500
+ <xsl:template match="tgroup/@align|tgroup/@cols">
501
+ <!-- -->
502
+ <xsl:call-template name="deprecation-fix-report">
503
+ <xsl:with-param name="date">2015-03-17</xsl:with-param>
504
+ <xsl:with-param name="message">Removing obsolete @align and @cols attributes, adjust alignment of contents of tabular by hand</xsl:with-param>
505
+ </xsl:call-template>
506
+ </xsl:template>
507
+ <!-- drop intermediate thead and tbody -->
508
+ <xsl:template match="thead|tbody">
509
+ <xsl:apply-templates select="@* | node()" />
510
+ <!-- -->
511
+ <xsl:call-template name="deprecation-fix-report">
512
+ <xsl:with-param name="date">2015-03-17</xsl:with-param>
513
+ <xsl:with-param name="message">Removing intermediate &lt;thead&gt; and &lt;tbody&gt;</xsl:with-param>
514
+ </xsl:call-template>
515
+ </xsl:template>
516
+ <!-- maybe we'll recycle entry for something else, so protect it -->
517
+ <xsl:template match="row/entry">
518
+ <cell>
519
+ <xsl:apply-templates select="@* | node()" />
520
+ </cell>
521
+ <!-- -->
522
+ <xsl:call-template name="deprecation-fix-report">
523
+ <xsl:with-param name="date">2015-03-17</xsl:with-param>
524
+ <xsl:with-param name="message">Replacing &lt;entry&gt; by &lt;cell&gt; in a &lt;row&gt;</xsl:with-param>
525
+ </xsl:call-template>
526
+ </xsl:template>
527
+
528
+ <!-- 2015-03-13: the paragraph lightweight sectioning is better in plural -->
529
+ <xsl:template match="paragraph">
530
+ <paragraphs>
531
+ <xsl:apply-templates select="@* | node()" />
532
+ </paragraphs>
533
+ <!-- -->
534
+ <xsl:call-template name="deprecation-fix-report">
535
+ <xsl:with-param name="date">2015-03-13</xsl:with-param>
536
+ <xsl:with-param name="message">Replacing &lt;paragraph&gt; by &lt;paragraphs&gt;</xsl:with-param>
537
+ </xsl:call-template>
538
+ </xsl:template>
539
+
540
+ <!-- 2015-01-28: <circum /> is gone, <circumflex /> won -->
541
+ <xsl:template match="circum">
542
+ <circumflex>
543
+ <xsl:apply-templates select="@* | node()" />
544
+ </circumflex>
545
+ <!-- -->
546
+ <xsl:call-template name="deprecation-fix-report">
547
+ <xsl:with-param name="date">2014-06-25</xsl:with-param>
548
+ <xsl:with-param name="message">Replacing &lt;circumflex/&gt; by &lt;circum/&gt;</xsl:with-param>
549
+ </xsl:call-template>
550
+ </xsl:template>
551
+
552
+ <!-- 2014-06-25: <cite> gone, replace directly with <xref> -->
553
+ <xsl:template match="cite">
554
+ <xref>
555
+ <xsl:apply-templates select="@* | node()" />
556
+ </xref>
557
+ <!-- -->
558
+ <xsl:call-template name="deprecation-fix-report">
559
+ <xsl:with-param name="date">2014-06-25</xsl:with-param>
560
+ <xsl:with-param name="message">Replacing &lt;cite&gt; by &lt;xref&gt;</xsl:with-param>
561
+ </xsl:call-template>
562
+ </xsl:template>
563
+
564
+ <!-- 2014-05-04: @filebase attributes is obsolete, we drop it -->
565
+ <!-- Author's responsibility to introduce/adjust an @xml:id -->
566
+ <xsl:template match="@filebase">
567
+ <!-- -->
568
+ <xsl:call-template name="deprecation-fix-report">
569
+ <xsl:with-param name="date">2014-05-04</xsl:with-param>
570
+ <xsl:with-param name="message">Removing obsolete @filebase attribute, introduce or adjust an @xml:id to play this role</xsl:with-param>
571
+ </xsl:call-template>
572
+ </xsl:template>
573
+
574
+ <!-- ######################### -->
575
+ <!-- Stylesheet Infrastructure -->
576
+ <!-- ######################### -->
577
+
578
+ <!-- We place these templates at the end, -->
579
+ <!-- the deprecations above are the items of -->
580
+ <!-- interest, in reverse chronological order -->
581
+
582
+ <!-- We do a few things to get started -->
583
+ <!-- We override matching the root element of the -->
584
+ <!-- imported worksheet with the identity template, -->
585
+ <!-- and then resume walking the tree -->
586
+
587
+ <!-- Switch to prevent naive use -->
588
+ <xsl:param name="fix" select="'no'" />
589
+
590
+ <xsl:template match="/">
591
+ <xsl:choose>
592
+ <!-- print to console and quit -->
593
+ <xsl:when test="$fix = 'no'">
594
+ <xsl:call-template name="instructions" />
595
+ </xsl:when>
596
+ <!-- modal run on root to just change source cosmetically -->
597
+ <xsl:when test="$fix = 'normalize'">
598
+ <xsl:apply-templates select="." mode="normalize"/>
599
+ </xsl:when>
600
+ <!-- default templates on children to actually change source -->
601
+ <xsl:when test="$fix = 'all'">
602
+ <xsl:copy>
603
+ <xsl:apply-templates select="@* | node()" />
604
+ </xsl:copy>
605
+ </xsl:when>
606
+ <xsl:otherwise>
607
+ <xsl:message>The parameter "fix" must be set to 'no', 'normalize', or 'all'. Assuming 'no'.</xsl:message>
608
+ </xsl:otherwise>
609
+ </xsl:choose>
610
+ </xsl:template>
611
+
612
+ <xsl:template name="instructions">
613
+ <xsl:message terminate="yes">
614
+ <text>* *&#xa;</text>
615
+ <text>* The "fix-deprecations" stylesheet will change your source files *&#xa;</text>
616
+ <text>* *&#xa;</text>
617
+ <text>* 1. Experiment on copies and keep good backups *&#xa;</text>
618
+ <text>* 2. Send output to a file in some other directory than originals *&#xa;</text>
619
+ <text>* 3. Do not enable xinclude processing if you want modular files *&#xa;</text>
620
+ <text>* 4. Indentation and whitespace will be preserved *&#xa;</text>
621
+ <text>* 5. Attributes will likely be re-ordered, with normalized spacing *&#xa;</text>
622
+ <text>* 6. Empty elements will have spaces removed from the tag *&#xa;</text>
623
+ <text>* 7. Elements with no content may be written with a single empty tag *&#xa;</text>
624
+ <text>* 8. CDATA sections will have some characters replaced by entities *&#xa;</text>
625
+ <text>* 9. The output files will be labeled as having UTF-8 encoding *&#xa;</text>
626
+ <text>* 10. It might be necessary to run this more than once *&#xa;</text>
627
+ <text>* 11. Be sure to inspect the results, perhaps using a "diff" tool *&#xa;</text>
628
+ <text>* 12. It should be safe to run this repeatedly, even after updates *&#xa;</text>
629
+ <text>* *&#xa;</text>
630
+ <text>* Quitting now. Instructions: *&#xa;</text>
631
+ <text>* *&#xa;</text>
632
+ <text>* To use, and confirm you have read this far, use a parameter on the *&#xa;</text>
633
+ <text>* command line that sets the parameter "fix" to the value 'all' *&#xa;</text>
634
+ <text>* *&#xa;</text>
635
+ <text>* Set the parameter "fix" to 'normalize' to only adjust source format *&#xa;</text>
636
+ <text>* (This might be a useful first step the first time you use this) *&#xa;</text>
637
+ <text>* *&#xa;</text>
638
+ </xsl:message>
639
+ </xsl:template>
640
+
641
+ <!-- A template to report to console, so we can adjust later -->
642
+ <xsl:template name="deprecation-fix-report">
643
+ <xsl:param name="message" select="''" />
644
+ <xsl:param name="date" select="''" />
645
+ <xsl:message><xsl:value-of select="$message" /> (from <xsl:value-of select="$date" />)</xsl:message>
646
+ </xsl:template>
647
+
648
+ <!-- Walk the tree, copying everything as-is -->
649
+ <!-- with templates above as exceptions -->
650
+ <xsl:template match="@* | node()">
651
+ <xsl:copy>
652
+ <xsl:apply-templates select="@* | node()" />
653
+ </xsl:copy>
654
+ </xsl:template>
655
+
656
+ <!-- Walk the tree, copying everything *exactly* -->
657
+ <xsl:template match="@* | node()" mode="normalize">
658
+ <xsl:copy>
659
+ <xsl:apply-templates select="@* | node()" mode="normalize" />
660
+ </xsl:copy>
661
+ </xsl:template>
662
+
663
+ </xsl:stylesheet>