@pretextbook/pretext-html 0.1.0 → 0.1.1
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.
- package/README.md +42 -3
- package/assets/preview-html.xsl +230 -230
- package/assets/upstream.json +7 -7
- package/assets/xsl/README.md +0 -0
- package/assets/xsl/entities.ent +154 -154
- package/assets/xsl/extract-asymptote.xsl +68 -68
- package/assets/xsl/extract-biblio-csl.xsl +327 -327
- package/assets/xsl/extract-datafile.xsl +71 -71
- package/assets/xsl/extract-dynamic.xsl +139 -139
- package/assets/xsl/extract-identity.xsl +136 -136
- package/assets/xsl/extract-interactive.xsl +81 -81
- package/assets/xsl/extract-latex-image.xsl +118 -118
- package/assets/xsl/extract-mermaid.xsl +58 -58
- package/assets/xsl/extract-mom.xsl +63 -63
- package/assets/xsl/extract-pg.xsl +2897 -2897
- package/assets/xsl/extract-prefigure.xsl +157 -157
- package/assets/xsl/extract-qrcode.xsl +100 -100
- package/assets/xsl/extract-runestone-page-template.xsl +139 -139
- package/assets/xsl/extract-sageplot.xsl +166 -166
- package/assets/xsl/extract-stack.xsl +56 -56
- package/assets/xsl/extract-trace.xsl +134 -134
- package/assets/xsl/extract-youtube.xsl +63 -63
- package/assets/xsl/html-symbols.xsl +3344 -3344
- package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -56
- package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -148
- package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -317
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -76
- package/assets/xsl/latex/pretext-latex-guide.xsl +104 -104
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -862
- package/assets/xsl/localizations/README.md +0 -0
- package/assets/xsl/localizations/af-ZA.xml +276 -276
- package/assets/xsl/localizations/bg-BG.xml +276 -276
- package/assets/xsl/localizations/ca-ES.xml +285 -285
- package/assets/xsl/localizations/cs-CZ.xml +280 -280
- package/assets/xsl/localizations/de-DE.xml +281 -281
- package/assets/xsl/localizations/en-US.xml +427 -427
- package/assets/xsl/localizations/es-ES.xml +287 -287
- package/assets/xsl/localizations/fi-FI.xml +275 -275
- package/assets/xsl/localizations/fr-CA.xml +276 -276
- package/assets/xsl/localizations/fr-FR.xml +280 -280
- package/assets/xsl/localizations/hu-HU.xml +280 -280
- package/assets/xsl/localizations/it-IT.xml +276 -276
- package/assets/xsl/localizations/ku-CKB.xml +275 -275
- package/assets/xsl/localizations/localizations.xml +48 -48
- package/assets/xsl/localizations/nl-NL.xml +275 -275
- package/assets/xsl/localizations/pt-BR.xml +288 -288
- package/assets/xsl/localizations/pt-PT.xml +292 -292
- package/assets/xsl/localizations/zh-HANS.xml +269 -269
- package/assets/xsl/pretext-assembly.xsl +4795 -4795
- package/assets/xsl/pretext-basic-html.xsl +86 -86
- package/assets/xsl/pretext-beamer.xsl +662 -662
- package/assets/xsl/pretext-braille-preprint.xsl +2249 -2249
- package/assets/xsl/pretext-common.xsl +12018 -12018
- package/assets/xsl/pretext-dynamic.xsl +65 -65
- package/assets/xsl/pretext-epub.xsl +1483 -1483
- package/assets/xsl/pretext-fo.xsl +4593 -4593
- package/assets/xsl/pretext-html.xsl +14791 -14791
- package/assets/xsl/pretext-json-manifest.xsl +150 -150
- package/assets/xsl/pretext-jupyter.xsl +868 -868
- package/assets/xsl/pretext-latex-classic.xsl +952 -952
- package/assets/xsl/pretext-latex-common.xsl +11563 -11563
- package/assets/xsl/pretext-latex.xsl +47 -47
- package/assets/xsl/pretext-litprog.xsl +105 -105
- package/assets/xsl/pretext-merge.xsl +41 -41
- package/assets/xsl/pretext-numbers.xsl +875 -875
- package/assets/xsl/pretext-revealjs.xsl +522 -522
- package/assets/xsl/pretext-runestone-fitb.xsl +1233 -1233
- package/assets/xsl/pretext-runestone-static.xsl +1438 -1438
- package/assets/xsl/pretext-runestone.xsl +3083 -3083
- package/assets/xsl/pretext-sage-doctest.xsl +289 -289
- package/assets/xsl/pretext-smc.xsl +492 -492
- package/assets/xsl/pretext-solution-manual-latex.xsl +323 -323
- package/assets/xsl/pretext-text-utilities.xsl +1217 -1217
- package/assets/xsl/pretext-text.xsl +392 -392
- package/assets/xsl/pretext-units.xsl +195 -195
- package/assets/xsl/pretext-view-source.xsl +157 -157
- package/assets/xsl/pretext-ww-problem-sets.xsl +391 -391
- package/assets/xsl/publisher-variables.xsl +4756 -4756
- package/assets/xsl/support/README.md +0 -0
- package/assets/xsl/support/extract-math.xsl +256 -256
- package/assets/xsl/support/package-math.xsl +141 -141
- package/assets/xsl/support/play-button/README.md +0 -0
- package/assets/xsl/support/play-button/play-button.png +0 -0
- package/assets/xsl/support/play-button/play-button.svg +3 -3
- package/assets/xsl/support/pretext-pg-macros.xsl +110 -110
- package/assets/xsl/support/webpack_static_imports.xml +14 -14
- package/assets/xsl/tests/README.md +0 -0
- package/assets/xsl/tests/null.xml +3 -3
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +333 -333
- package/assets/xsl/utilities/README.md +0 -0
- package/assets/xsl/utilities/author-report.xsl +107 -107
- package/assets/xsl/utilities/deprecate-autoname.sed +18 -18
- package/assets/xsl/utilities/deprecate-index.sed +33 -33
- package/assets/xsl/utilities/fix-deprecations.xsl +663 -663
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -112
- package/assets/xsl/utilities/report-publisher-variables.xsl +162 -162
- package/assets/xsl/xml-to-json.xsl +326 -326
- package/assets/xsl/xml-to-string.xsl +328 -328
- package/dist/{cli-C6tfAVvi.js → cli-BQizBK0N.js} +74 -72
- package/dist/cli.d.ts +0 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -6
- package/dist/mounts.d.ts +0 -0
- package/dist/publication.d.ts +0 -0
- package/dist/renderer.d.ts +10 -0
- package/dist/sourcemap.d.ts +0 -0
- package/dist/theme.d.ts +68 -0
- package/dist/theme.js +93 -0
- package/dist/xinclude.d.ts +0 -0
- package/package.json +14 -2
|
@@ -1,875 +1,875 @@
|
|
|
1
|
-
<?xml version='1.0'?>
|
|
2
|
-
|
|
3
|
-
<!DOCTYPE xsl:stylesheet [
|
|
4
|
-
<!ENTITY % entities SYSTEM "entities.ent">
|
|
5
|
-
%entities;
|
|
6
|
-
]>
|
|
7
|
-
|
|
8
|
-
<!--********************************************************************
|
|
9
|
-
Copyright 2020 Robert A. Beezer
|
|
10
|
-
|
|
11
|
-
This file is part of PreTeXt.
|
|
12
|
-
|
|
13
|
-
PreTeXt is free software: you can redistribute it and/or modify
|
|
14
|
-
it under the terms of the GNU General Public License as published by
|
|
15
|
-
the Free Software Foundation, either version 2 or version 3 of the
|
|
16
|
-
License (at your option).
|
|
17
|
-
|
|
18
|
-
PreTeXt is distributed in the hope that it will be useful,
|
|
19
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
GNU General Public License for more details.
|
|
22
|
-
|
|
23
|
-
You should have received a copy of the GNU General Public License
|
|
24
|
-
along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
25
|
-
*********************************************************************-->
|
|
26
|
-
|
|
27
|
-
<xsl:stylesheet
|
|
28
|
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
29
|
-
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
30
|
-
xmlns:pi="http://pretextbook.org/2020/pretext/internal"
|
|
31
|
-
xmlns:exsl="http://exslt.org/common"
|
|
32
|
-
xmlns:date="http://exslt.org/dates-and-times"
|
|
33
|
-
extension-element-prefixes="exsl date"
|
|
34
|
-
exclude-result-prefixes="pi"
|
|
35
|
-
>
|
|
36
|
-
|
|
37
|
-
<!-- Intend output as plain text (numbers) -->
|
|
38
|
-
<xsl:output method="text" encoding="UTF-8"/>
|
|
39
|
-
|
|
40
|
-
<!-- Read documentation in the "-assembly" stylesheet to understand -->
|
|
41
|
-
<!-- employment/purpose of these templates there. -->
|
|
42
|
-
<!-- -->
|
|
43
|
-
<!-- 2021-12-22: moving the computation of serial numbers out of -->
|
|
44
|
-
<!-- the "-common" stylesheet, so as to be pre-computed. -->
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<!-- ######################## -->
|
|
48
|
-
<!-- Block Structure Numbers -->
|
|
49
|
-
<!-- ######################## -->
|
|
50
|
-
|
|
51
|
-
<!-- Given a block element, produce its structure number prefix -->
|
|
52
|
-
<!-- by reading the pre-computed @block-struct from the nearest -->
|
|
53
|
-
<!-- ancestor division, then truncating or padding to the configured -->
|
|
54
|
-
<!-- number of levels. The @block-struct chain already excludes -->
|
|
55
|
-
<!-- parts (they are squelched in assembly), so when parts are -->
|
|
56
|
-
<!-- present the caller's $levels (which counts from "part" depth) -->
|
|
57
|
-
<!-- must be reduced by one to match the shorter chain. -->
|
|
58
|
-
<xsl:template name="block-structure-number">
|
|
59
|
-
<xsl:param name="levels"/>
|
|
60
|
-
<xsl:variable name="raw-struct"
|
|
61
|
-
select="ancestor::*[@block-struct][1]/@block-struct"/>
|
|
62
|
-
<!-- The @block-struct chain already excludes parts, so when -->
|
|
63
|
-
<!-- parts are present the $levels count (which includes the -->
|
|
64
|
-
<!-- part depth) must be reduced by one. But only for -->
|
|
65
|
-
<!-- blocks actually inside a part or backmatter — blocks -->
|
|
66
|
-
<!-- in frontmatter have no part ancestor and should use -->
|
|
67
|
-
<!-- $levels unmodified. -->
|
|
68
|
-
<xsl:variable name="effective-levels">
|
|
69
|
-
<xsl:choose>
|
|
70
|
-
<xsl:when test="not($parts = 'absent') and ancestor::*[self::part or self::backmatter]">
|
|
71
|
-
<xsl:choose>
|
|
72
|
-
<xsl:when test="$levels > 0">
|
|
73
|
-
<xsl:value-of select="$levels - 1"/>
|
|
74
|
-
</xsl:when>
|
|
75
|
-
<xsl:otherwise>
|
|
76
|
-
<xsl:value-of select="0"/>
|
|
77
|
-
</xsl:otherwise>
|
|
78
|
-
</xsl:choose>
|
|
79
|
-
</xsl:when>
|
|
80
|
-
<xsl:otherwise>
|
|
81
|
-
<xsl:value-of select="$levels"/>
|
|
82
|
-
</xsl:otherwise>
|
|
83
|
-
</xsl:choose>
|
|
84
|
-
</xsl:variable>
|
|
85
|
-
<xsl:call-template name="truncate-pad-struct">
|
|
86
|
-
<xsl:with-param name="struct" select="$raw-struct"/>
|
|
87
|
-
<xsl:with-param name="levels" select="$effective-levels"/>
|
|
88
|
-
</xsl:call-template>
|
|
89
|
-
</xsl:template>
|
|
90
|
-
|
|
91
|
-
<!-- Truncate a dotted-number string to a given number of -->
|
|
92
|
-
<!-- components, padding with ".0" if fewer components exist. -->
|
|
93
|
-
<xsl:template name="truncate-pad-struct">
|
|
94
|
-
<xsl:param name="struct"/>
|
|
95
|
-
<xsl:param name="levels"/>
|
|
96
|
-
<xsl:param name="count" select="0"/>
|
|
97
|
-
|
|
98
|
-
<xsl:choose>
|
|
99
|
-
<!-- Emitted enough levels, halt -->
|
|
100
|
-
<xsl:when test="$count = $levels"/>
|
|
101
|
-
<!-- Components remaining in the string -->
|
|
102
|
-
<xsl:when test="$struct != ''">
|
|
103
|
-
<xsl:if test="$count > 0">
|
|
104
|
-
<xsl:text>.</xsl:text>
|
|
105
|
-
</xsl:if>
|
|
106
|
-
<xsl:choose>
|
|
107
|
-
<xsl:when test="contains($struct, '.')">
|
|
108
|
-
<xsl:value-of select="substring-before($struct, '.')"/>
|
|
109
|
-
<xsl:call-template name="truncate-pad-struct">
|
|
110
|
-
<xsl:with-param name="struct"
|
|
111
|
-
select="substring-after($struct, '.')"/>
|
|
112
|
-
<xsl:with-param name="levels" select="$levels"/>
|
|
113
|
-
<xsl:with-param name="count" select="$count + 1"/>
|
|
114
|
-
</xsl:call-template>
|
|
115
|
-
</xsl:when>
|
|
116
|
-
<xsl:otherwise>
|
|
117
|
-
<xsl:value-of select="$struct"/>
|
|
118
|
-
<xsl:call-template name="truncate-pad-struct">
|
|
119
|
-
<xsl:with-param name="struct" select="''"/>
|
|
120
|
-
<xsl:with-param name="levels" select="$levels"/>
|
|
121
|
-
<xsl:with-param name="count" select="$count + 1"/>
|
|
122
|
-
</xsl:call-template>
|
|
123
|
-
</xsl:otherwise>
|
|
124
|
-
</xsl:choose>
|
|
125
|
-
</xsl:when>
|
|
126
|
-
<!-- Out of components, pad with zero -->
|
|
127
|
-
<xsl:otherwise>
|
|
128
|
-
<xsl:if test="$count > 0">
|
|
129
|
-
<xsl:text>.</xsl:text>
|
|
130
|
-
</xsl:if>
|
|
131
|
-
<xsl:text>0</xsl:text>
|
|
132
|
-
<xsl:call-template name="truncate-pad-struct">
|
|
133
|
-
<xsl:with-param name="struct" select="''"/>
|
|
134
|
-
<xsl:with-param name="levels" select="$levels"/>
|
|
135
|
-
<xsl:with-param name="count" select="$count + 1"/>
|
|
136
|
-
</xsl:call-template>
|
|
137
|
-
</xsl:otherwise>
|
|
138
|
-
</xsl:choose>
|
|
139
|
-
</xsl:template>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<!-- ##### Division levels ##### -->
|
|
143
|
-
<!-- 2021-12-22: we are transitioning to selected (and eventually universal) -->
|
|
144
|
-
<!-- use of levels computed during the "assembly" phase. So we use careful -->
|
|
145
|
-
<!-- matches and we use careful choices for application. At every -->
|
|
146
|
-
<!-- application we compute the "old" level to test for consistency. -->
|
|
147
|
-
|
|
148
|
-
<!-- ####################################################################### -->
|
|
149
|
-
<xsl:template match="part|chapter|appendix|section|subsection|subsubsection|exercises|solutions|reading-questions|references|glossary|worksheet|handout" mode="new-level">
|
|
150
|
-
<xsl:variable name="old-level">
|
|
151
|
-
<xsl:apply-templates select="." mode="level"/>
|
|
152
|
-
</xsl:variable>
|
|
153
|
-
<xsl:if test="not($old-level = @level)">
|
|
154
|
-
<xsl:message>PTX:BUG: development bug, new level does not match old level for "<xsl:value-of select="local-name(.)"/>"</xsl:message>
|
|
155
|
-
<xsl:apply-templates select="." mode="location-report" />
|
|
156
|
-
</xsl:if>
|
|
157
|
-
<!-- actual value here, above is debugging -->
|
|
158
|
-
<xsl:value-of select="@level"/>
|
|
159
|
-
</xsl:template>
|
|
160
|
-
|
|
161
|
-
<xsl:template match="*" mode="new-level">
|
|
162
|
-
<xsl:message>PTX:BUG: an element ("<xsl:value-of select="local-name(.)"/>") does not know its *new* level</xsl:message>
|
|
163
|
-
<xsl:apply-templates select="." mode="location-report" />
|
|
164
|
-
</xsl:template>
|
|
165
|
-
<!-- ####################################################################### -->
|
|
166
|
-
|
|
167
|
-
<!-- Specific top-level divisions -->
|
|
168
|
-
<!-- article/frontmatter, article/backmatter are faux divisions, but -->
|
|
169
|
-
<!-- will function as a terminating condition in recursive count below -->
|
|
170
|
-
<xsl:template match="book|article|slideshow|letter|memo|article/frontmatter|article/backmatter" mode="level">
|
|
171
|
-
<xsl:value-of select="0"/>
|
|
172
|
-
</xsl:template>
|
|
173
|
-
|
|
174
|
-
<!-- A book/part will divide the mainmatter, so a "chapter" is at -->
|
|
175
|
-
<!-- level 2, so we also put the faux divisions at level 1 in the -->
|
|
176
|
-
<!-- case of parts, to again terminate recursive count -->
|
|
177
|
-
<xsl:template match="book/part|book/frontmatter|book/backmatter" mode="level">
|
|
178
|
-
<xsl:choose>
|
|
179
|
-
<xsl:when test="$b-has-parts">
|
|
180
|
-
<xsl:value-of select="1"/>
|
|
181
|
-
</xsl:when>
|
|
182
|
-
<xsl:otherwise>
|
|
183
|
-
<xsl:value-of select="0"/>
|
|
184
|
-
</xsl:otherwise>
|
|
185
|
-
</xsl:choose>
|
|
186
|
-
</xsl:template>
|
|
187
|
-
|
|
188
|
-
<!-- Remaining divisions will follow a strict progression from their -->
|
|
189
|
-
<!-- parents. We have front matter divisions of a book first, which -->
|
|
190
|
-
<!-- will have the same level as a chapter, then traditional divisions, -->
|
|
191
|
-
<!-- which may structure a chapter of a book, section of an article, -->
|
|
192
|
-
<!-- or an appendix (structured as a chapter in a book or a sections -->
|
|
193
|
-
<!-- in an article). Then follows specialized divisions of the back -->
|
|
194
|
-
<!-- matter, which are peers of an appendix. Finally we have the -->
|
|
195
|
-
<!-- "specialized divisions" of PreTeXt, which can be descendants of -->
|
|
196
|
-
<!-- chapters of books, sections of articles, or in the case of -->
|
|
197
|
-
<!-- solutions or references, children of an appendix. -->
|
|
198
|
-
|
|
199
|
-
<xsl:template match="colophon|biography|dedication|acknowledgement|preface|chapter|section|subsection|subsubsection|slide|appendix|index|colophon|exercises|reading-questions|references|solutions|glossary|worksheet|handout" mode="level">
|
|
200
|
-
<xsl:variable name="level-above">
|
|
201
|
-
<xsl:apply-templates select="parent::*" mode="level"/>
|
|
202
|
-
</xsl:variable>
|
|
203
|
-
<xsl:value-of select="$level-above + 1"/>
|
|
204
|
-
</xsl:template>
|
|
205
|
-
|
|
206
|
-
<xsl:template match="*" mode="level">
|
|
207
|
-
<xsl:message>PTX:BUG: an element ("<xsl:value-of select="local-name(.)"/>") does not know its level</xsl:message>
|
|
208
|
-
<xsl:apply-templates select="." mode="location-report" />
|
|
209
|
-
</xsl:template>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
<!-- Enclosing Level -->
|
|
213
|
-
|
|
214
|
-
<!-- ##### Serial / structure / full number ##### -->
|
|
215
|
-
<!-- Backmatter references and glossary are unique and un-numbered, -->
|
|
216
|
-
<!-- so an empty serial number. These matches supersede the above. -->
|
|
217
|
-
<xsl:template match="backmatter/references" mode="serial-number" />
|
|
218
|
-
<xsl:template match="backmatter/glossary" mode="serial-number" />
|
|
219
|
-
|
|
220
|
-
<!-- Serial number of a block: read the @serial that the assembly -->
|
|
221
|
-
<!-- "serial-stamp" pass stamped. That pass decides, from the -->
|
|
222
|
-
<!-- publication "@distinct" switches, whether a group shares the -->
|
|
223
|
-
<!-- overall blocks counter or runs on its own distinct counter. -->
|
|
224
|
-
<xsl:template match="&DEFINITION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;|&PROJECT-LIKE;|&FIGURE-LIKE;|&OPENPROBLEM-LIKE;|exercise" mode="serial-number">
|
|
225
|
-
<xsl:value-of select="@serial"/>
|
|
226
|
-
</xsl:template>
|
|
227
|
-
|
|
228
|
-
<!-- Proofs may be numbered (for cross-reference knowls) -->
|
|
229
|
-
<xsl:template match="&PROOF-LIKE;" mode="serial-number">
|
|
230
|
-
<xsl:number count="&PROOF-LIKE;"/>
|
|
231
|
-
</xsl:template>
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
<!-- Serial Numbers: Equations -->
|
|
235
|
-
<!-- The assembly equation-serial pass stamps @serial on every numbered -->
|
|
236
|
-
<!-- <mrow>; here we just read it back. Scope rules and pad/truncate -->
|
|
237
|
-
<!-- behaviour live in the assembly pass. -->
|
|
238
|
-
<xsl:template match="mrow[@pi:numbered = 'yes']" mode="serial-number">
|
|
239
|
-
<xsl:value-of select="@serial"/>
|
|
240
|
-
</xsl:template>
|
|
241
|
-
|
|
242
|
-
<!-- An authored bare "md" may carry an @xml:id, and so may be cross-referenced. -->
|
|
243
|
-
<!-- We consider its number, as a target of a cross-reference to be that of the -->
|
|
244
|
-
<!-- contained, single "mrow". This may be an actual number or may be an empty -->
|
|
245
|
-
<!-- string, depending on how the "md" was meant to be numbered. -->
|
|
246
|
-
<xsl:template match="md[@pi:authored-one-line]" mode="serial-number">
|
|
247
|
-
<xsl:apply-templates select="mrow" mode="serial-number"/>
|
|
248
|
-
</xsl:template>
|
|
249
|
-
|
|
250
|
-
<!-- Serial Numbers: Exercises in Exercises or Worksheet or Reading Question Divisions -->
|
|
251
|
-
<!-- Note: numbers may be hard-coded for longevity -->
|
|
252
|
-
<!-- exercisegroups and future lightweight divisions may -->
|
|
253
|
-
<!-- be intermediate, but should not hinder the count -->
|
|
254
|
-
<!-- NB: there are three historical "apply-templates" -->
|
|
255
|
-
<!-- here which might now be written as "value-of", -->
|
|
256
|
-
<!-- but perhaps it is irrelevant -->
|
|
257
|
-
<xsl:template match="exercises//exercise" mode="serial-number">
|
|
258
|
-
<xsl:number from="exercises" level="any" count="exercise" />
|
|
259
|
-
</xsl:template>
|
|
260
|
-
|
|
261
|
-
<xsl:template match="exercises//exercise[@number]" mode="serial-number">
|
|
262
|
-
<xsl:apply-templates select="@number" />
|
|
263
|
-
</xsl:template>
|
|
264
|
-
|
|
265
|
-
<xsl:template match="worksheet//exercise" mode="serial-number">
|
|
266
|
-
<xsl:number from="worksheet" level="any" count="exercise" />
|
|
267
|
-
</xsl:template>
|
|
268
|
-
|
|
269
|
-
<xsl:template match="worksheet//exercise[@number]" mode="serial-number">
|
|
270
|
-
<xsl:apply-templates select="@number" />
|
|
271
|
-
</xsl:template>
|
|
272
|
-
|
|
273
|
-
<xsl:template match="reading-questions//exercise" mode="serial-number">
|
|
274
|
-
<xsl:number from="reading-questions" level="any" count="exercise" />
|
|
275
|
-
</xsl:template>
|
|
276
|
-
|
|
277
|
-
<xsl:template match="reading-questions//exercise[@number]" mode="serial-number">
|
|
278
|
-
<xsl:apply-templates select="@number" />
|
|
279
|
-
</xsl:template>
|
|
280
|
-
|
|
281
|
-
<!-- Serial Numbers: Solutions -->
|
|
282
|
-
<!-- Hints, answers, solutions may be numbered (for cross-reference knowls) -->
|
|
283
|
-
<xsl:template match="&SOLUTION-LIKE;" mode="serial-number">
|
|
284
|
-
<xsl:number />
|
|
285
|
-
</xsl:template>
|
|
286
|
-
|
|
287
|
-
<!-- Serial Numbers: Bibliographic Items -->
|
|
288
|
-
<!-- Always sequential within a References section -->
|
|
289
|
-
<xsl:template match="biblio" mode="serial-number">
|
|
290
|
-
<xsl:number from="references" level="any" count="biblio" />
|
|
291
|
-
</xsl:template>
|
|
292
|
-
<!-- Notes may be numbered (for cross-reference knowls) -->
|
|
293
|
-
<xsl:template match="biblio/note" mode="serial-number">
|
|
294
|
-
<xsl:number />
|
|
295
|
-
</xsl:template>
|
|
296
|
-
|
|
297
|
-
<!-- Hints, answers, solutions, notes are often singletons. -->
|
|
298
|
-
<!-- This utility returns the serial number, or if a singleton, -->
|
|
299
|
-
<!-- returns an empty string. Employing templates will need -->
|
|
300
|
-
<!-- to check if they want to react accordingly, or they should -->
|
|
301
|
-
<!-- just ask for the serial number itself if they don't care. -->
|
|
302
|
-
<xsl:template match="&SOLUTION-LIKE;|biblio/note" mode="non-singleton-number">
|
|
303
|
-
<xsl:variable name="the-number">
|
|
304
|
-
<xsl:apply-templates select="." mode="serial-number" />
|
|
305
|
-
</xsl:variable>
|
|
306
|
-
<xsl:choose>
|
|
307
|
-
<!-- non-singletons always of interest/use -->
|
|
308
|
-
<xsl:when test="not($the-number = 1)">
|
|
309
|
-
<xsl:value-of select="$the-number" />
|
|
310
|
-
</xsl:when>
|
|
311
|
-
<!-- now being careful with "1" -->
|
|
312
|
-
<xsl:otherwise>
|
|
313
|
-
<xsl:variable name="elt-name" select="local-name(.)" />
|
|
314
|
-
<!-- We go to the parent, get all like children, then -->
|
|
315
|
-
<!-- filter by name, since hints and answers, etc all mix -->
|
|
316
|
-
<xsl:variable name="siblings-and-self" select="parent::*/*[local-name(.) = $elt-name]" />
|
|
317
|
-
<!-- maybe "1" is interesting too -->
|
|
318
|
-
<!-- if not, no result whatsoever -->
|
|
319
|
-
<xsl:if test="count($siblings-and-self) > 1">
|
|
320
|
-
<xsl:value-of select="$the-number" />
|
|
321
|
-
</xsl:if>
|
|
322
|
-
</xsl:otherwise>
|
|
323
|
-
</xsl:choose>
|
|
324
|
-
</xsl:template>
|
|
325
|
-
|
|
326
|
-
<!-- Serial Numbers: Footnotes -->
|
|
327
|
-
<!-- We determine the appropriate subtree to count within -->
|
|
328
|
-
<!-- given the document root and the configured depth -->
|
|
329
|
-
<!-- @serial is stamped on every fn during assembly; here we read it back. -->
|
|
330
|
-
<xsl:template match="fn" mode="serial-number">
|
|
331
|
-
<xsl:value-of select="@serial"/>
|
|
332
|
-
</xsl:template>
|
|
333
|
-
|
|
334
|
-
<!-- Serial Numbers: Subfigures, Subtables, Sublisting-->
|
|
335
|
-
<!-- Subnumbering only happens with figures -->
|
|
336
|
-
<!-- or tables arranged in a sidebyside, which -->
|
|
337
|
-
<!-- is again contained inside a figure, the -->
|
|
338
|
-
<!-- element providing the overall caption -->
|
|
339
|
-
<!-- The serial number is a sub-number, (a), (b), (c), -->
|
|
340
|
-
<!-- *Always* with the parenthetical formatting -->
|
|
341
|
-
<!-- Debatable if parentheses should come from here -->
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
<!-- In this case the structure number is the -->
|
|
345
|
-
<!-- full number of the enclosing figure -->
|
|
346
|
-
|
|
347
|
-
<!-- a lone sidebyside, not in a sbsgroup -->
|
|
348
|
-
<xsl:template match="figure/sidebyside/figure | figure/sidebyside/table | figure/sidebyside/listing | figure/sidebyside/list" mode="serial-number">
|
|
349
|
-
<xsl:text>(</xsl:text>
|
|
350
|
-
<xsl:number format="a" count="&FIGURE-LIKE;"/>
|
|
351
|
-
<xsl:text>)</xsl:text>
|
|
352
|
-
</xsl:template>
|
|
353
|
-
|
|
354
|
-
<!-- when inside a sbsgroup, subnumbers range across entire group -->
|
|
355
|
-
<xsl:template match="figure/sbsgroup/sidebyside/figure | figure/sbsgroup/sidebyside/table | figure/sbsgroup/sidebyside/listing | figure/sbsgroup/sidebyside/list" mode="serial-number">
|
|
356
|
-
<xsl:text>(</xsl:text>
|
|
357
|
-
<xsl:number format="a" count="&FIGURE-LIKE;" level="any" from="sbsgroup"/>
|
|
358
|
-
<xsl:text>)</xsl:text>
|
|
359
|
-
</xsl:template>
|
|
360
|
-
|
|
361
|
-
<!-- Serial Numbers: List Items -->
|
|
362
|
-
|
|
363
|
-
<!-- First, the number of a list item within its own ordered list. This -->
|
|
364
|
-
<!-- trades on the PTX format codes being identical to the XSLT codes. -->
|
|
365
|
-
<xsl:template match="ol/li" mode="item-number">
|
|
366
|
-
<xsl:variable name="code" select="../@format-code" />
|
|
367
|
-
<xsl:number format="{$code}" />
|
|
368
|
-
</xsl:template>
|
|
369
|
-
|
|
370
|
-
<!-- Second, the serial number computed recursively. The -->
|
|
371
|
-
<!-- entire hierarchy should be ordered lists, since otherwise, -->
|
|
372
|
-
<!-- the template just below will apply instead. -->
|
|
373
|
-
<xsl:template match="ol/li" mode="serial-number">
|
|
374
|
-
<xsl:if test="ancestor::li">
|
|
375
|
-
<xsl:apply-templates select="ancestor::li[1]" mode="serial-number" />
|
|
376
|
-
<xsl:text>.</xsl:text>
|
|
377
|
-
</xsl:if>
|
|
378
|
-
<xsl:apply-templates select="." mode="item-number" />
|
|
379
|
-
</xsl:template>
|
|
380
|
-
|
|
381
|
-
<!-- If any ancestor of a list item is not ordered, this -->
|
|
382
|
-
<!-- template should match first, and the serial number -->
|
|
383
|
-
<!-- will be empty, the signal that an object has no number. -->
|
|
384
|
-
<xsl:template match="ul//li|dl//li" mode="serial-number" />
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
<!-- Serial Numbers: Exercise Groups -->
|
|
388
|
-
<!-- We provide the range of the -->
|
|
389
|
-
<!-- group as its serial number. -->
|
|
390
|
-
<xsl:template match="exercisegroup" mode="serial-number">
|
|
391
|
-
<xsl:apply-templates select="exercise[1]" mode="serial-number" />
|
|
392
|
-
<xsl:call-template name="ndash-character"/>
|
|
393
|
-
<xsl:apply-templates select="exercise[last()]" mode="serial-number" />
|
|
394
|
-
</xsl:template>
|
|
395
|
-
|
|
396
|
-
<!-- Serial Numbers: Tasks (in Projects) -->
|
|
397
|
-
<!-- Tasks have "list" numbers, which we use on labels -->
|
|
398
|
-
<!-- (we could use serial numbers for a more complex look) -->
|
|
399
|
-
<xsl:template match="task" mode="list-number">
|
|
400
|
-
<xsl:number format="a" />
|
|
401
|
-
</xsl:template>
|
|
402
|
-
<xsl:template match="task/task" mode="list-number">
|
|
403
|
-
<xsl:number format="i" />
|
|
404
|
-
</xsl:template>
|
|
405
|
-
<xsl:template match="task/task/task" mode="list-number">
|
|
406
|
-
<xsl:number format="A" />
|
|
407
|
-
</xsl:template>
|
|
408
|
-
<!-- concatenate list numbers to get serial numbers, eg a.i.A -->
|
|
409
|
-
<xsl:template match="task" mode="serial-number">
|
|
410
|
-
<xsl:apply-templates select="." mode="list-number" />
|
|
411
|
-
</xsl:template>
|
|
412
|
-
<xsl:template match="task/task" mode="serial-number">
|
|
413
|
-
<xsl:apply-templates select="parent::task" mode="serial-number" />
|
|
414
|
-
<xsl:text>.</xsl:text>
|
|
415
|
-
<xsl:apply-templates select="." mode="list-number" />
|
|
416
|
-
</xsl:template>
|
|
417
|
-
<xsl:template match="task/task/task" mode="serial-number">
|
|
418
|
-
<xsl:apply-templates select="parent::task" mode="serial-number" />
|
|
419
|
-
<xsl:text>.</xsl:text>
|
|
420
|
-
<xsl:apply-templates select="." mode="list-number" />
|
|
421
|
-
</xsl:template>
|
|
422
|
-
|
|
423
|
-
<!-- Serial Numbers: fragments -->
|
|
424
|
-
<!-- Simply numbered sequentially, globally. -->
|
|
425
|
-
<xsl:template match="fragment" mode="serial-number">
|
|
426
|
-
<xsl:number level="any"/>
|
|
427
|
-
</xsl:template>
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
<!-- Serial Numbers: the unnumbered -->
|
|
431
|
-
<!-- Empty string signifies not numbered -->
|
|
432
|
-
|
|
433
|
-
<!-- We choose not to number unique, or semi-unique -->
|
|
434
|
-
<!-- (eg prefaces, colophons), elements. Other elements -->
|
|
435
|
-
<!-- are meant as local commentary, and may also carry -->
|
|
436
|
-
<!-- a title for identification and cross-referencing. -->
|
|
437
|
-
<xsl:template match="book|article|letter|memo|paragraphs|blockquote|preface|abstract|acknowledgement|biography|foreword|dedication|contributors|index-part|index[index-list]|colophon|webwork|p|assemblage|aside|biographical|historical|case|contributor" mode="serial-number" />
|
|
438
|
-
|
|
439
|
-
<!-- Some divisions, like "exercises", "solutions", "references", -->
|
|
440
|
-
<!-- are part of the hierarchical numbering scheme, and look simply -->
|
|
441
|
-
<!-- to their parent. Which could be the top-level when in th main -->
|
|
442
|
-
<!-- matter (we handle cases of children of "backmatter" carefully -->
|
|
443
|
-
<!-- elsewhere or it does not happen). So we need an empty structure -->
|
|
444
|
-
<!-- number for these cases. -->
|
|
445
|
-
<xsl:template match="book|article|letter|memo" mode="structure-number" />
|
|
446
|
-
|
|
447
|
-
<!-- Some items are "containers". They are not numbered, you -->
|
|
448
|
-
<!-- cannot point to them, they are invisible to the reader -->
|
|
449
|
-
<!-- in a way. We kill their serial numbers explicitly here. -->
|
|
450
|
-
<!-- Lists live in paragraphs, exercises, objectives, so -->
|
|
451
|
-
<!-- should be referenced as part of some enclosing element. -->
|
|
452
|
-
<!-- "mathbook" helps some tree-climbing routines halt -->
|
|
453
|
-
<xsl:template match="mathbook|pretext|introduction|conclusion|frontmatter|backmatter|sidebyside|sbsgroup|ol|ul|dl|statement" mode="serial-number" />
|
|
454
|
-
|
|
455
|
-
<!-- Poems go by their titles, not numbers -->
|
|
456
|
-
<xsl:template match="poem" mode="serial-number" />
|
|
457
|
-
|
|
458
|
-
<!-- Preformatted ("pre") appear in search results by name -->
|
|
459
|
-
<xsl:template match="pre" mode="serial-number" />
|
|
460
|
-
|
|
461
|
-
<!-- List items, subordinate to an unordered list, or a description -->
|
|
462
|
-
<!-- list, will have numbers that are especically ambiguous, perhaps -->
|
|
463
|
-
<!-- even very clsoe within a multi-level list. They are unnumbered -->
|
|
464
|
-
<!-- in the vicinity of computing serial numbers of list items in -->
|
|
465
|
-
<!-- ordered lists. -->
|
|
466
|
-
|
|
467
|
-
<!-- Every displayed equation eventually lands inside an "mrow" and -->
|
|
468
|
-
<!-- the pre-processor identifies it as numbered or not, so the -->
|
|
469
|
-
<!-- unnumbered ones are straightforward. A local tag (@tag) -->
|
|
470
|
-
<!-- authored on an "mrow" is considered an unnumbered equation. -->
|
|
471
|
-
<xsl:template match="mrow[@pi:numbered = 'no']" mode="serial-number"/>
|
|
472
|
-
|
|
473
|
-
<!-- WeBWorK problems are never numbered, because they live -->
|
|
474
|
-
<!-- in (numbered) exercises. But they have identically named -->
|
|
475
|
-
<!-- components of exercises, so we might need to explicitly -->
|
|
476
|
-
<!-- make webwork/solution, etc to be unnumbered. -->
|
|
477
|
-
|
|
478
|
-
<!-- Glossary items ("gi"), in a "glossary", are known by their title -->
|
|
479
|
-
<xsl:template match="gi" mode="serial-number"/>
|
|
480
|
-
|
|
481
|
-
<!-- GOAL-LIKE are one-per-subdivision, -->
|
|
482
|
-
<!-- and so get their serial number from their parent -->
|
|
483
|
-
<xsl:template match="&GOAL-LIKE;" mode="serial-number">
|
|
484
|
-
<xsl:apply-templates select="parent::*" mode="serial-number" />
|
|
485
|
-
</xsl:template>
|
|
486
|
-
|
|
487
|
-
<!-- A subexercises is meant to be minimal, and does not have a number -->
|
|
488
|
-
<xsl:template match="subexercises" mode="serial-number"/>
|
|
489
|
-
|
|
490
|
-
<!-- We only allow one "instructions" for an "interactive" -->
|
|
491
|
-
<xsl:template match="interactive/instructions" mode="serial-number"/>
|
|
492
|
-
|
|
493
|
-
<!-- Multi-part WeBWorK problems have PTX elements -->
|
|
494
|
-
<!-- called "stage" which typically render as "Part..." -->
|
|
495
|
-
<!-- Their serial numbers are useful, there is no attempt -->
|
|
496
|
-
<!-- above to integrate these into our general scheme -->
|
|
497
|
-
<!-- These are just counted among enclosing "webwork" -->
|
|
498
|
-
<xsl:template match="webwork/stage" mode="serial-number">
|
|
499
|
-
<xsl:number count="stage" from="webwork" />
|
|
500
|
-
</xsl:template>
|
|
501
|
-
|
|
502
|
-
<!-- But when a problem is part of the OPL and is retrieved -->
|
|
503
|
-
<!-- from the server, then we don't see the "stage" element -->
|
|
504
|
-
<!-- until we merge in the "static" version as part of the -->
|
|
505
|
-
<!-- "webwork-reps" collection -->
|
|
506
|
-
<xsl:template match="webwork-reps/static/stage" mode="serial-number">
|
|
507
|
-
<xsl:number count="stage" from="static" />
|
|
508
|
-
</xsl:template>
|
|
509
|
-
|
|
510
|
-
<!-- OPENPROBLEM-LIKE are blocks: their serial number is read from @serial, -->
|
|
511
|
-
<!-- alongside the other block families above. Their structure number -->
|
|
512
|
-
<!-- follows the figure/project pattern: the open-problem level when they -->
|
|
513
|
-
<!-- run on a distinct counter, otherwise the shared "blocks" level. -->
|
|
514
|
-
<xsl:template match="&OPENPROBLEM-LIKE;" mode="structure-number">
|
|
515
|
-
<xsl:variable name="openproblem-levels">
|
|
516
|
-
<xsl:choose>
|
|
517
|
-
<xsl:when test="$b-number-openproblem-distinct">
|
|
518
|
-
<xsl:value-of select="$numbering-openproblems" />
|
|
519
|
-
</xsl:when>
|
|
520
|
-
<xsl:otherwise>
|
|
521
|
-
<xsl:value-of select="$numbering-blocks" />
|
|
522
|
-
</xsl:otherwise>
|
|
523
|
-
</xsl:choose>
|
|
524
|
-
</xsl:variable>
|
|
525
|
-
<xsl:call-template name="block-structure-number">
|
|
526
|
-
<xsl:with-param name="levels" select="$openproblem-levels"/>
|
|
527
|
-
</xsl:call-template>
|
|
528
|
-
</xsl:template>
|
|
529
|
-
|
|
530
|
-
<!-- DISCUSSION-LIKE are appendages; their number is inherited from the parent. -->
|
|
531
|
-
<xsl:template match="&DISCUSSION-LIKE;" mode="serial-number">
|
|
532
|
-
<xsl:number select="parent::*" count="&DISCUSSION-LIKE;"/>
|
|
533
|
-
</xsl:template>
|
|
534
|
-
<xsl:template match="&DISCUSSION-LIKE;" mode="structure-number">
|
|
535
|
-
<xsl:apply-templates select="parent::*" mode="number"/>
|
|
536
|
-
</xsl:template>
|
|
537
|
-
|
|
538
|
-
<!-- No numbers on pages of worksheets -->
|
|
539
|
-
<xsl:template match="page" mode="serial-number"/>
|
|
540
|
-
|
|
541
|
-
<!-- Should not drop in here. Ever. -->
|
|
542
|
-
<xsl:template match="*" mode="serial-number">
|
|
543
|
-
<xsl:text>[NUM]</xsl:text>
|
|
544
|
-
<xsl:message>PTX:ERROR: An object (<xsl:value-of select="local-name(.)" />) lacks a serial number, search output for "[NUM]"</xsl:message>
|
|
545
|
-
<xsl:apply-templates select="." mode="location-report" />
|
|
546
|
-
</xsl:template>
|
|
547
|
-
|
|
548
|
-
<!-- -->
|
|
549
|
-
<!-- Multi-Numbers Utility -->
|
|
550
|
-
<!-- -->
|
|
551
|
-
|
|
552
|
-
<!-- -->
|
|
553
|
-
<!-- Structure Numbers -->
|
|
554
|
-
<!-- -->
|
|
555
|
-
|
|
556
|
-
<!-- We compute multi-part numbers to the necessary, -->
|
|
557
|
-
<!-- or configured, number of components -->
|
|
558
|
-
<!-- NB: *every* structure number should finish with -->
|
|
559
|
-
<!-- a period as a separator, which is often provided -->
|
|
560
|
-
<!-- by the "multi-number" template. Some of the -->
|
|
561
|
-
<!-- cross-reference text code adds a period before -->
|
|
562
|
-
<!-- testing equality of strings -->
|
|
563
|
-
|
|
564
|
-
<!-- Structure Numbers: Divisions -->
|
|
565
|
-
<!-- NB: this is number of the *container* of the division, -->
|
|
566
|
-
<!-- a serial number for the division itself will be appended -->
|
|
567
|
-
<xsl:template match="part|chapter|appendix|section|subsection|subsubsection|backmatter/solutions" mode="structure-number">
|
|
568
|
-
<xsl:value-of select="@struct"/>
|
|
569
|
-
</xsl:template>
|
|
570
|
-
|
|
571
|
-
<!-- Structure Numbers: Specialized Divisions -->
|
|
572
|
-
<!-- Some divisions get their numbers from their parents, or -->
|
|
573
|
-
<!-- in other ways. We are careful to do this by determining -->
|
|
574
|
-
<!-- the serial-numer and the structure-number, so that other -->
|
|
575
|
-
<!-- devices (like local numbers) will behave correctly. -->
|
|
576
|
-
<!-- Serial numbers are computed elsewhere, but in tandem. -->
|
|
577
|
-
<xsl:template match="exercises|solutions[not(parent::backmatter)]|worksheet|handout|reading-questions|references[not(parent::backmatter)]|glossary[not(parent::backmatter)]" mode="structure-number">
|
|
578
|
-
<xsl:variable name="is-numbered">
|
|
579
|
-
<xsl:apply-templates select="." mode="is-specialized-own-number"/>
|
|
580
|
-
</xsl:variable>
|
|
581
|
-
<xsl:choose>
|
|
582
|
-
<xsl:when test="$is-numbered = 'true'">
|
|
583
|
-
<xsl:value-of select="@struct"/>
|
|
584
|
-
</xsl:when>
|
|
585
|
-
<xsl:otherwise>
|
|
586
|
-
<xsl:apply-templates select="parent::*" mode="structure-number" />
|
|
587
|
-
</xsl:otherwise>
|
|
588
|
-
</xsl:choose>
|
|
589
|
-
</xsl:template>
|
|
590
|
-
<!-- "references" and "glossary" are solo in main matter -->
|
|
591
|
-
<!-- divisions, unique and not numbered in back matter -->
|
|
592
|
-
<xsl:template match="backmatter/references" mode="structure-number" />
|
|
593
|
-
<xsl:template match="backmatter/glossary" mode="structure-number" />
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
<!-- Structure Numbers: Theorems, Examples, Projects, Figures -->
|
|
597
|
-
<xsl:template match="&DEFINITION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;" mode="structure-number">
|
|
598
|
-
<xsl:call-template name="block-structure-number">
|
|
599
|
-
<xsl:with-param name="levels" select="$numbering-blocks"/>
|
|
600
|
-
</xsl:call-template>
|
|
601
|
-
</xsl:template>
|
|
602
|
-
<!-- PROJECT-LIKE is now independent, under control of $numbering-projects -->
|
|
603
|
-
<!-- But all ready to become elective -->
|
|
604
|
-
<xsl:template match="&PROJECT-LIKE;" mode="structure-number">
|
|
605
|
-
<xsl:variable name="project-levels">
|
|
606
|
-
<xsl:choose>
|
|
607
|
-
<xsl:when test="$b-number-project-distinct">
|
|
608
|
-
<xsl:value-of select="$numbering-projects" />
|
|
609
|
-
</xsl:when>
|
|
610
|
-
<xsl:otherwise>
|
|
611
|
-
<xsl:value-of select="$numbering-blocks" />
|
|
612
|
-
</xsl:otherwise>
|
|
613
|
-
</xsl:choose>
|
|
614
|
-
</xsl:variable>
|
|
615
|
-
<xsl:call-template name="block-structure-number">
|
|
616
|
-
<xsl:with-param name="levels" select="$project-levels"/>
|
|
617
|
-
</xsl:call-template>
|
|
618
|
-
</xsl:template>
|
|
619
|
-
<!-- FIGURE-LIKE get a structure number from default $numbering-blocks -->
|
|
620
|
-
<!-- or from "docinfo" independent numbering configuration -->
|
|
621
|
-
<xsl:template match="&FIGURE-LIKE;" mode="structure-number">
|
|
622
|
-
<xsl:variable name="figure-levels">
|
|
623
|
-
<xsl:choose>
|
|
624
|
-
<xsl:when test="$b-number-figure-distinct">
|
|
625
|
-
<xsl:value-of select="$numbering-figures" />
|
|
626
|
-
</xsl:when>
|
|
627
|
-
<xsl:otherwise>
|
|
628
|
-
<xsl:value-of select="$numbering-blocks" />
|
|
629
|
-
</xsl:otherwise>
|
|
630
|
-
</xsl:choose>
|
|
631
|
-
</xsl:variable>
|
|
632
|
-
<xsl:call-template name="block-structure-number">
|
|
633
|
-
<xsl:with-param name="levels" select="$figure-levels"/>
|
|
634
|
-
</xsl:call-template>
|
|
635
|
-
</xsl:template>
|
|
636
|
-
<!-- Proofs get structure number from parent theorem -->
|
|
637
|
-
<!-- NB: assumes proofs are not detached? Maybe not. -->
|
|
638
|
-
<!-- Definitely a detached proof in a "paragraphs" is bad -->
|
|
639
|
-
<xsl:template match="&PROOF-LIKE;" mode="structure-number">
|
|
640
|
-
<xsl:apply-templates select="parent::*" mode="number" />
|
|
641
|
-
</xsl:template>
|
|
642
|
-
<!-- Captioned items, arranged in a side-by-side, -->
|
|
643
|
-
<!-- then inside a captioned figure, earn a serial -->
|
|
644
|
-
<!-- number that is a letter. So their structure -->
|
|
645
|
-
<!-- number comes from the enclosing captioned figure. -->
|
|
646
|
-
<!-- The sidebyside may be a child of the figure, -->
|
|
647
|
-
<!-- or wrapped in an sbsgroup. -->
|
|
648
|
-
<xsl:template match="figure/sidebyside/figure | figure/sidebyside/table | figure/sidebyside/listing | figure/sidebyside/list" mode="structure-number">
|
|
649
|
-
<xsl:apply-templates select="parent::sidebyside/parent::figure" mode="number" />
|
|
650
|
-
</xsl:template>
|
|
651
|
-
<xsl:template match="figure/sbsgroup/sidebyside/figure | figure/sbsgroup/sidebyside/table | figure/sbsgroup/sidebyside/listing | figure/sbsgroup/sidebyside/list" mode="structure-number">
|
|
652
|
-
<xsl:apply-templates select="parent::sidebyside/parent::sbsgroup/parent::figure" mode="number" />
|
|
653
|
-
</xsl:template>
|
|
654
|
-
|
|
655
|
-
<!-- Structure Numbers: Equations -->
|
|
656
|
-
<!-- "mrow" may be numbered, and bare "md" inherit a number from their -->
|
|
657
|
-
<!-- manufactured single "mrow". So we need a structure number for the -->
|
|
658
|
-
<!-- numbered versions of these elements. -->
|
|
659
|
-
<xsl:template match="mrow|md[@pi:authored-one-line]" mode="structure-number">
|
|
660
|
-
<xsl:call-template name="block-structure-number">
|
|
661
|
-
<xsl:with-param name="levels" select="$numbering-equations"/>
|
|
662
|
-
</xsl:call-template>
|
|
663
|
-
</xsl:template>
|
|
664
|
-
|
|
665
|
-
<!-- Structure Numbers: Inline Exercises -->
|
|
666
|
-
<!-- Follows the theorem/figure/etc scheme. The second alternative -->
|
|
667
|
-
<!-- adds an inline exercise in a division introduction or conclusion -->
|
|
668
|
-
<!-- (its parent is not in the inline filter); divisional-container -->
|
|
669
|
-
<!-- exercises are handled by the next template instead. -->
|
|
670
|
-
<xsl:template match="exercise[boolean(&INLINE-EXERCISE-FILTER;)]|exercise[(parent::introduction or parent::conclusion) and not(ancestor::exercises or ancestor::worksheet or ancestor::reading-questions)]" mode="structure-number">
|
|
671
|
-
<xsl:variable name="exercise-levels">
|
|
672
|
-
<xsl:choose>
|
|
673
|
-
<xsl:when test="$b-number-exercise-distinct">
|
|
674
|
-
<xsl:value-of select="$numbering-exercises" />
|
|
675
|
-
</xsl:when>
|
|
676
|
-
<xsl:otherwise>
|
|
677
|
-
<xsl:value-of select="$numbering-blocks" />
|
|
678
|
-
</xsl:otherwise>
|
|
679
|
-
</xsl:choose>
|
|
680
|
-
</xsl:variable>
|
|
681
|
-
<xsl:call-template name="block-structure-number">
|
|
682
|
-
<xsl:with-param name="levels" select="$exercise-levels"/>
|
|
683
|
-
</xsl:call-template>
|
|
684
|
-
</xsl:template>
|
|
685
|
-
|
|
686
|
-
<!-- Structure Numbers: Divisional and Worksheet Exercises -->
|
|
687
|
-
<!-- Within a "exercises" or "worksheet", look up to enclosing division -->
|
|
688
|
-
<!-- in order to decide where the structure number comes from -->
|
|
689
|
-
<xsl:template match="exercises//exercise|worksheet//exercise|reading-questions//exercise" mode="structure-number">
|
|
690
|
-
<!-- Need to look up through "exercisegroup", "subexercises", "sidebyside", etc -->
|
|
691
|
-
<!-- Only one of these specialized divisions, just a single node in variable -->
|
|
692
|
-
<xsl:variable name="container" select="ancestor::*[self::exercises or self::worksheet or self::reading-questions]"/>
|
|
693
|
-
<xsl:apply-templates select="$container" mode="number" />
|
|
694
|
-
</xsl:template>
|
|
695
|
-
|
|
696
|
-
<!-- Structure Numbers: Exercise Groups -->
|
|
697
|
-
<!-- An exercisegroup gets it structure number from the parent exercises -->
|
|
698
|
-
<xsl:template match="exercisegroup" mode="structure-number">
|
|
699
|
-
<xsl:apply-templates select="parent::*" mode="number" />
|
|
700
|
-
</xsl:template>
|
|
701
|
-
|
|
702
|
-
<!-- Hints, answers, solutions get structure number from parent -->
|
|
703
|
-
<!-- exercise's number. Identical for inline and divisional exercises -->
|
|
704
|
-
<xsl:template match="&SOLUTION-LIKE;" mode="structure-number">
|
|
705
|
-
<xsl:apply-templates select="parent::*" mode="number" />
|
|
706
|
-
</xsl:template>
|
|
707
|
-
|
|
708
|
-
<!-- Anything within a webwork-reps that needs a structure number -->
|
|
709
|
-
<!-- gets it from the enclosing exercise. -->
|
|
710
|
-
<xsl:template match="webwork-reps//*" mode="structure-number">
|
|
711
|
-
<xsl:apply-templates select="ancestor::exercise" mode="number" />
|
|
712
|
-
</xsl:template>
|
|
713
|
-
|
|
714
|
-
<!-- Structure Numbers: Bibliographic Items -->
|
|
715
|
-
<!-- Bibliographic items get their number from the containing -->
|
|
716
|
-
<!-- "references", which may be solo in an unstructured division, -->
|
|
717
|
-
<!-- or one of potentially several in a structured division. -->
|
|
718
|
-
<!-- Since the global "references" (child of "backmatter") is not -->
|
|
719
|
-
<!-- numbered, these items will have un-qualified numbers -->
|
|
720
|
-
<!-- (serial number only). -->
|
|
721
|
-
<xsl:template match="biblio" mode="structure-number">
|
|
722
|
-
<xsl:apply-templates select="parent::*" mode="number" />
|
|
723
|
-
</xsl:template>
|
|
724
|
-
|
|
725
|
-
<!-- Notes get structure number from parent biblio's number -->
|
|
726
|
-
<xsl:template match="biblio/note" mode="structure-number">
|
|
727
|
-
<xsl:apply-templates select="parent::*" mode="number" />
|
|
728
|
-
</xsl:template>
|
|
729
|
-
|
|
730
|
-
<!-- Structure Numbers: Footnotes -->
|
|
731
|
-
<xsl:template match="fn" mode="structure-number">
|
|
732
|
-
<xsl:call-template name="block-structure-number">
|
|
733
|
-
<xsl:with-param name="levels" select="$numbering-footnotes"/>
|
|
734
|
-
</xsl:call-template>
|
|
735
|
-
</xsl:template>
|
|
736
|
-
|
|
737
|
-
<!-- Structure Numbers: Lists -->
|
|
738
|
-
<!-- Lists occur in paragraphs (anonymously), in "list" -->
|
|
739
|
-
<!-- blocks (numbered), and within exercises (numbered). -->
|
|
740
|
-
<!-- Typically we are interested in list items (only), -->
|
|
741
|
-
<!-- since that is where there is content. And then we -->
|
|
742
|
-
<!-- are only interested in the list items within an ordered -->
|
|
743
|
-
<!-- list. We control for items under unordered lists or -->
|
|
744
|
-
<!-- description lists elsewhere by providing empty numbers. -->
|
|
745
|
-
<!-- NB: the order of these templates may matter -->
|
|
746
|
-
<xsl:template match="li" mode="structure-number" />
|
|
747
|
-
|
|
748
|
-
<xsl:template match="list//li" mode="structure-number">
|
|
749
|
-
<xsl:apply-templates select="ancestor::list" mode="number" />
|
|
750
|
-
</xsl:template>
|
|
751
|
-
|
|
752
|
-
<xsl:template match="exercise//li" mode="structure-number">
|
|
753
|
-
<xsl:apply-templates select="ancestor::exercise" mode="number" />
|
|
754
|
-
</xsl:template>
|
|
755
|
-
|
|
756
|
-
<!-- Structure Numbers: Tasks (in projects) -->
|
|
757
|
-
<!-- A task gets it structure number from the parent project-like -->
|
|
758
|
-
<xsl:template match="task" mode="structure-number">
|
|
759
|
-
<!-- ancestors, strip tasks, get number of next enclosure -->
|
|
760
|
-
<xsl:apply-templates select="ancestor::*[not(self::task)][1]" mode="number" />
|
|
761
|
-
</xsl:template>
|
|
762
|
-
|
|
763
|
-
<!-- Structure Numbers: GOAL-LIKE -->
|
|
764
|
-
<!-- Objectives are one-per-subdivision, and so -->
|
|
765
|
-
<!-- get their structure number from their parent -->
|
|
766
|
-
<xsl:template match="&GOAL-LIKE;" mode="structure-number">
|
|
767
|
-
<xsl:apply-templates select="parent::*" mode="structure-number" />
|
|
768
|
-
</xsl:template>
|
|
769
|
-
|
|
770
|
-
<!-- Structure Numbers: Objective and Outcome-->
|
|
771
|
-
<!-- A single objective or outcome is a list item -->
|
|
772
|
-
<!-- in an objectives or outcomes environment -->
|
|
773
|
-
<xsl:template match="objectives/ol/li|outcomes/ol/li" mode="structure-number">
|
|
774
|
-
<xsl:apply-templates select="ancestor::*[&STRUCTURAL-FILTER;][1]" mode="number" />
|
|
775
|
-
</xsl:template>
|
|
776
|
-
|
|
777
|
-
<!-- Structure Numbers: Fragment -->
|
|
778
|
-
<!-- We number serially, see below -->
|
|
779
|
-
<xsl:template match="fragment" mode="structure-number"/>
|
|
780
|
-
|
|
781
|
-
<!-- worksheet pages are unnumbered -->
|
|
782
|
-
<xsl:template match="page" mode="structure-number"/>
|
|
783
|
-
|
|
784
|
-
<!-- Should not drop in here. Ever. -->
|
|
785
|
-
<xsl:template match="*" mode="structure-number">
|
|
786
|
-
<xsl:text>[STRUCT]</xsl:text>
|
|
787
|
-
<xsl:message>PTX:ERROR: An object (<xsl:value-of select="local-name(.)" />) lacks a structure number, search output for "[STRUCT]"</xsl:message>
|
|
788
|
-
<xsl:apply-templates select="." mode="location-report" />
|
|
789
|
-
</xsl:template>
|
|
790
|
-
|
|
791
|
-
<!-- -->
|
|
792
|
-
<!-- Full Numbers -->
|
|
793
|
-
<!-- -->
|
|
794
|
-
|
|
795
|
-
<!-- Now trivial, the container structure plus the serial. -->
|
|
796
|
-
<!-- We condition on empty serial number in order to create -->
|
|
797
|
-
<!-- empty full numbers. This is where we add separator, -->
|
|
798
|
-
<!-- normally a period, but for a list item within a named -->
|
|
799
|
-
<!-- list, we use a colon (a double period?). -->
|
|
800
|
-
<xsl:template match="*" mode="number">
|
|
801
|
-
<xsl:variable name="serial">
|
|
802
|
-
<xsl:apply-templates select="." mode="serial-number" />
|
|
803
|
-
</xsl:variable>
|
|
804
|
-
<xsl:choose>
|
|
805
|
-
<xsl:when test="$serial = ''" />
|
|
806
|
-
<xsl:otherwise>
|
|
807
|
-
<xsl:variable name="structure">
|
|
808
|
-
<xsl:apply-templates select="." mode="structure-number" />
|
|
809
|
-
</xsl:variable>
|
|
810
|
-
<xsl:if test="not($structure='')">
|
|
811
|
-
<xsl:value-of select="$structure" />
|
|
812
|
-
<xsl:choose>
|
|
813
|
-
<xsl:when test="self::li and ancestor::list">
|
|
814
|
-
<xsl:text>:</xsl:text>
|
|
815
|
-
</xsl:when>
|
|
816
|
-
<!-- A figure-like inside a sidebyside (or -->
|
|
817
|
-
<!-- sbsgroup) inside a figure is subnumbered -->
|
|
818
|
-
<!-- with a letter like "(a)", so the serial -->
|
|
819
|
-
<!-- number already carries its own delimiter -->
|
|
820
|
-
<!-- and no period separator is needed. -->
|
|
821
|
-
<xsl:when test="(&FIGURE-FILTER;) and (parent::sidebyside/parent::figure or parent::sidebyside/parent::sbsgroup/parent::figure)"/>
|
|
822
|
-
<xsl:otherwise>
|
|
823
|
-
<xsl:text>.</xsl:text>
|
|
824
|
-
</xsl:otherwise>
|
|
825
|
-
</xsl:choose>
|
|
826
|
-
</xsl:if>
|
|
827
|
-
<xsl:value-of select="$serial" />
|
|
828
|
-
</xsl:otherwise>
|
|
829
|
-
</xsl:choose>
|
|
830
|
-
</xsl:template>
|
|
831
|
-
|
|
832
|
-
<!-- ##### Division serial numbers ##### -->
|
|
833
|
-
<!-- ############## -->
|
|
834
|
-
<!-- Serial Numbers -->
|
|
835
|
-
<!-- ############## -->
|
|
836
|
-
|
|
837
|
-
<!-- Serial Numbers: Divisions -->
|
|
838
|
-
<!-- To respect the maximum level for numbering, we -->
|
|
839
|
-
<!-- return an empty serial number at an excessive level, -->
|
|
840
|
-
<!-- otherwise we call for a serial number relative to peers -->
|
|
841
|
-
<xsl:template match="part|chapter|appendix|section|subsection|subsubsection|backmatter/solutions" mode="serial-number">
|
|
842
|
-
<xsl:variable name="relative-level">
|
|
843
|
-
<xsl:apply-templates select="." mode="new-level" />
|
|
844
|
-
</xsl:variable>
|
|
845
|
-
<xsl:choose>
|
|
846
|
-
<xsl:when test="$relative-level > $numbering-maxlevel" />
|
|
847
|
-
<xsl:otherwise>
|
|
848
|
-
<xsl:value-of select="@serial"/>
|
|
849
|
-
</xsl:otherwise>
|
|
850
|
-
</xsl:choose>
|
|
851
|
-
</xsl:template>
|
|
852
|
-
|
|
853
|
-
<!-- Serial Numbers: Specialized Divisions -->
|
|
854
|
-
<xsl:template match="exercises|solutions|worksheet|handout|reading-questions|references|glossary" mode="serial-number">
|
|
855
|
-
<xsl:variable name="is-numbered">
|
|
856
|
-
<xsl:apply-templates select="." mode="is-specialized-own-number"/>
|
|
857
|
-
</xsl:variable>
|
|
858
|
-
<xsl:choose>
|
|
859
|
-
<xsl:when test="$is-numbered = 'true'">
|
|
860
|
-
<xsl:variable name="relative-level">
|
|
861
|
-
<xsl:apply-templates select="." mode="new-level" />
|
|
862
|
-
</xsl:variable>
|
|
863
|
-
<xsl:choose>
|
|
864
|
-
<xsl:when test="$relative-level > $numbering-maxlevel" />
|
|
865
|
-
<xsl:otherwise>
|
|
866
|
-
<xsl:value-of select="@serial"/>
|
|
867
|
-
</xsl:otherwise>
|
|
868
|
-
</xsl:choose>
|
|
869
|
-
</xsl:when>
|
|
870
|
-
<xsl:otherwise>
|
|
871
|
-
<xsl:apply-templates select="parent::*" mode="serial-number" />
|
|
872
|
-
</xsl:otherwise>
|
|
873
|
-
</xsl:choose>
|
|
874
|
-
</xsl:template>
|
|
875
|
-
</xsl:stylesheet>
|
|
1
|
+
<?xml version='1.0'?>
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE xsl:stylesheet [
|
|
4
|
+
<!ENTITY % entities SYSTEM "entities.ent">
|
|
5
|
+
%entities;
|
|
6
|
+
]>
|
|
7
|
+
|
|
8
|
+
<!--********************************************************************
|
|
9
|
+
Copyright 2020 Robert A. Beezer
|
|
10
|
+
|
|
11
|
+
This file is part of PreTeXt.
|
|
12
|
+
|
|
13
|
+
PreTeXt is free software: you can redistribute it and/or modify
|
|
14
|
+
it under the terms of the GNU General Public License as published by
|
|
15
|
+
the Free Software Foundation, either version 2 or version 3 of the
|
|
16
|
+
License (at your option).
|
|
17
|
+
|
|
18
|
+
PreTeXt is distributed in the hope that it will be useful,
|
|
19
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
GNU General Public License for more details.
|
|
22
|
+
|
|
23
|
+
You should have received a copy of the GNU General Public License
|
|
24
|
+
along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
25
|
+
*********************************************************************-->
|
|
26
|
+
|
|
27
|
+
<xsl:stylesheet
|
|
28
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
29
|
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
30
|
+
xmlns:pi="http://pretextbook.org/2020/pretext/internal"
|
|
31
|
+
xmlns:exsl="http://exslt.org/common"
|
|
32
|
+
xmlns:date="http://exslt.org/dates-and-times"
|
|
33
|
+
extension-element-prefixes="exsl date"
|
|
34
|
+
exclude-result-prefixes="pi"
|
|
35
|
+
>
|
|
36
|
+
|
|
37
|
+
<!-- Intend output as plain text (numbers) -->
|
|
38
|
+
<xsl:output method="text" encoding="UTF-8"/>
|
|
39
|
+
|
|
40
|
+
<!-- Read documentation in the "-assembly" stylesheet to understand -->
|
|
41
|
+
<!-- employment/purpose of these templates there. -->
|
|
42
|
+
<!-- -->
|
|
43
|
+
<!-- 2021-12-22: moving the computation of serial numbers out of -->
|
|
44
|
+
<!-- the "-common" stylesheet, so as to be pre-computed. -->
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<!-- ######################## -->
|
|
48
|
+
<!-- Block Structure Numbers -->
|
|
49
|
+
<!-- ######################## -->
|
|
50
|
+
|
|
51
|
+
<!-- Given a block element, produce its structure number prefix -->
|
|
52
|
+
<!-- by reading the pre-computed @block-struct from the nearest -->
|
|
53
|
+
<!-- ancestor division, then truncating or padding to the configured -->
|
|
54
|
+
<!-- number of levels. The @block-struct chain already excludes -->
|
|
55
|
+
<!-- parts (they are squelched in assembly), so when parts are -->
|
|
56
|
+
<!-- present the caller's $levels (which counts from "part" depth) -->
|
|
57
|
+
<!-- must be reduced by one to match the shorter chain. -->
|
|
58
|
+
<xsl:template name="block-structure-number">
|
|
59
|
+
<xsl:param name="levels"/>
|
|
60
|
+
<xsl:variable name="raw-struct"
|
|
61
|
+
select="ancestor::*[@block-struct][1]/@block-struct"/>
|
|
62
|
+
<!-- The @block-struct chain already excludes parts, so when -->
|
|
63
|
+
<!-- parts are present the $levels count (which includes the -->
|
|
64
|
+
<!-- part depth) must be reduced by one. But only for -->
|
|
65
|
+
<!-- blocks actually inside a part or backmatter — blocks -->
|
|
66
|
+
<!-- in frontmatter have no part ancestor and should use -->
|
|
67
|
+
<!-- $levels unmodified. -->
|
|
68
|
+
<xsl:variable name="effective-levels">
|
|
69
|
+
<xsl:choose>
|
|
70
|
+
<xsl:when test="not($parts = 'absent') and ancestor::*[self::part or self::backmatter]">
|
|
71
|
+
<xsl:choose>
|
|
72
|
+
<xsl:when test="$levels > 0">
|
|
73
|
+
<xsl:value-of select="$levels - 1"/>
|
|
74
|
+
</xsl:when>
|
|
75
|
+
<xsl:otherwise>
|
|
76
|
+
<xsl:value-of select="0"/>
|
|
77
|
+
</xsl:otherwise>
|
|
78
|
+
</xsl:choose>
|
|
79
|
+
</xsl:when>
|
|
80
|
+
<xsl:otherwise>
|
|
81
|
+
<xsl:value-of select="$levels"/>
|
|
82
|
+
</xsl:otherwise>
|
|
83
|
+
</xsl:choose>
|
|
84
|
+
</xsl:variable>
|
|
85
|
+
<xsl:call-template name="truncate-pad-struct">
|
|
86
|
+
<xsl:with-param name="struct" select="$raw-struct"/>
|
|
87
|
+
<xsl:with-param name="levels" select="$effective-levels"/>
|
|
88
|
+
</xsl:call-template>
|
|
89
|
+
</xsl:template>
|
|
90
|
+
|
|
91
|
+
<!-- Truncate a dotted-number string to a given number of -->
|
|
92
|
+
<!-- components, padding with ".0" if fewer components exist. -->
|
|
93
|
+
<xsl:template name="truncate-pad-struct">
|
|
94
|
+
<xsl:param name="struct"/>
|
|
95
|
+
<xsl:param name="levels"/>
|
|
96
|
+
<xsl:param name="count" select="0"/>
|
|
97
|
+
|
|
98
|
+
<xsl:choose>
|
|
99
|
+
<!-- Emitted enough levels, halt -->
|
|
100
|
+
<xsl:when test="$count = $levels"/>
|
|
101
|
+
<!-- Components remaining in the string -->
|
|
102
|
+
<xsl:when test="$struct != ''">
|
|
103
|
+
<xsl:if test="$count > 0">
|
|
104
|
+
<xsl:text>.</xsl:text>
|
|
105
|
+
</xsl:if>
|
|
106
|
+
<xsl:choose>
|
|
107
|
+
<xsl:when test="contains($struct, '.')">
|
|
108
|
+
<xsl:value-of select="substring-before($struct, '.')"/>
|
|
109
|
+
<xsl:call-template name="truncate-pad-struct">
|
|
110
|
+
<xsl:with-param name="struct"
|
|
111
|
+
select="substring-after($struct, '.')"/>
|
|
112
|
+
<xsl:with-param name="levels" select="$levels"/>
|
|
113
|
+
<xsl:with-param name="count" select="$count + 1"/>
|
|
114
|
+
</xsl:call-template>
|
|
115
|
+
</xsl:when>
|
|
116
|
+
<xsl:otherwise>
|
|
117
|
+
<xsl:value-of select="$struct"/>
|
|
118
|
+
<xsl:call-template name="truncate-pad-struct">
|
|
119
|
+
<xsl:with-param name="struct" select="''"/>
|
|
120
|
+
<xsl:with-param name="levels" select="$levels"/>
|
|
121
|
+
<xsl:with-param name="count" select="$count + 1"/>
|
|
122
|
+
</xsl:call-template>
|
|
123
|
+
</xsl:otherwise>
|
|
124
|
+
</xsl:choose>
|
|
125
|
+
</xsl:when>
|
|
126
|
+
<!-- Out of components, pad with zero -->
|
|
127
|
+
<xsl:otherwise>
|
|
128
|
+
<xsl:if test="$count > 0">
|
|
129
|
+
<xsl:text>.</xsl:text>
|
|
130
|
+
</xsl:if>
|
|
131
|
+
<xsl:text>0</xsl:text>
|
|
132
|
+
<xsl:call-template name="truncate-pad-struct">
|
|
133
|
+
<xsl:with-param name="struct" select="''"/>
|
|
134
|
+
<xsl:with-param name="levels" select="$levels"/>
|
|
135
|
+
<xsl:with-param name="count" select="$count + 1"/>
|
|
136
|
+
</xsl:call-template>
|
|
137
|
+
</xsl:otherwise>
|
|
138
|
+
</xsl:choose>
|
|
139
|
+
</xsl:template>
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
<!-- ##### Division levels ##### -->
|
|
143
|
+
<!-- 2021-12-22: we are transitioning to selected (and eventually universal) -->
|
|
144
|
+
<!-- use of levels computed during the "assembly" phase. So we use careful -->
|
|
145
|
+
<!-- matches and we use careful choices for application. At every -->
|
|
146
|
+
<!-- application we compute the "old" level to test for consistency. -->
|
|
147
|
+
|
|
148
|
+
<!-- ####################################################################### -->
|
|
149
|
+
<xsl:template match="part|chapter|appendix|section|subsection|subsubsection|exercises|solutions|reading-questions|references|glossary|worksheet|handout" mode="new-level">
|
|
150
|
+
<xsl:variable name="old-level">
|
|
151
|
+
<xsl:apply-templates select="." mode="level"/>
|
|
152
|
+
</xsl:variable>
|
|
153
|
+
<xsl:if test="not($old-level = @level)">
|
|
154
|
+
<xsl:message>PTX:BUG: development bug, new level does not match old level for "<xsl:value-of select="local-name(.)"/>"</xsl:message>
|
|
155
|
+
<xsl:apply-templates select="." mode="location-report" />
|
|
156
|
+
</xsl:if>
|
|
157
|
+
<!-- actual value here, above is debugging -->
|
|
158
|
+
<xsl:value-of select="@level"/>
|
|
159
|
+
</xsl:template>
|
|
160
|
+
|
|
161
|
+
<xsl:template match="*" mode="new-level">
|
|
162
|
+
<xsl:message>PTX:BUG: an element ("<xsl:value-of select="local-name(.)"/>") does not know its *new* level</xsl:message>
|
|
163
|
+
<xsl:apply-templates select="." mode="location-report" />
|
|
164
|
+
</xsl:template>
|
|
165
|
+
<!-- ####################################################################### -->
|
|
166
|
+
|
|
167
|
+
<!-- Specific top-level divisions -->
|
|
168
|
+
<!-- article/frontmatter, article/backmatter are faux divisions, but -->
|
|
169
|
+
<!-- will function as a terminating condition in recursive count below -->
|
|
170
|
+
<xsl:template match="book|article|slideshow|letter|memo|article/frontmatter|article/backmatter" mode="level">
|
|
171
|
+
<xsl:value-of select="0"/>
|
|
172
|
+
</xsl:template>
|
|
173
|
+
|
|
174
|
+
<!-- A book/part will divide the mainmatter, so a "chapter" is at -->
|
|
175
|
+
<!-- level 2, so we also put the faux divisions at level 1 in the -->
|
|
176
|
+
<!-- case of parts, to again terminate recursive count -->
|
|
177
|
+
<xsl:template match="book/part|book/frontmatter|book/backmatter" mode="level">
|
|
178
|
+
<xsl:choose>
|
|
179
|
+
<xsl:when test="$b-has-parts">
|
|
180
|
+
<xsl:value-of select="1"/>
|
|
181
|
+
</xsl:when>
|
|
182
|
+
<xsl:otherwise>
|
|
183
|
+
<xsl:value-of select="0"/>
|
|
184
|
+
</xsl:otherwise>
|
|
185
|
+
</xsl:choose>
|
|
186
|
+
</xsl:template>
|
|
187
|
+
|
|
188
|
+
<!-- Remaining divisions will follow a strict progression from their -->
|
|
189
|
+
<!-- parents. We have front matter divisions of a book first, which -->
|
|
190
|
+
<!-- will have the same level as a chapter, then traditional divisions, -->
|
|
191
|
+
<!-- which may structure a chapter of a book, section of an article, -->
|
|
192
|
+
<!-- or an appendix (structured as a chapter in a book or a sections -->
|
|
193
|
+
<!-- in an article). Then follows specialized divisions of the back -->
|
|
194
|
+
<!-- matter, which are peers of an appendix. Finally we have the -->
|
|
195
|
+
<!-- "specialized divisions" of PreTeXt, which can be descendants of -->
|
|
196
|
+
<!-- chapters of books, sections of articles, or in the case of -->
|
|
197
|
+
<!-- solutions or references, children of an appendix. -->
|
|
198
|
+
|
|
199
|
+
<xsl:template match="colophon|biography|dedication|acknowledgement|preface|chapter|section|subsection|subsubsection|slide|appendix|index|colophon|exercises|reading-questions|references|solutions|glossary|worksheet|handout" mode="level">
|
|
200
|
+
<xsl:variable name="level-above">
|
|
201
|
+
<xsl:apply-templates select="parent::*" mode="level"/>
|
|
202
|
+
</xsl:variable>
|
|
203
|
+
<xsl:value-of select="$level-above + 1"/>
|
|
204
|
+
</xsl:template>
|
|
205
|
+
|
|
206
|
+
<xsl:template match="*" mode="level">
|
|
207
|
+
<xsl:message>PTX:BUG: an element ("<xsl:value-of select="local-name(.)"/>") does not know its level</xsl:message>
|
|
208
|
+
<xsl:apply-templates select="." mode="location-report" />
|
|
209
|
+
</xsl:template>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
<!-- Enclosing Level -->
|
|
213
|
+
|
|
214
|
+
<!-- ##### Serial / structure / full number ##### -->
|
|
215
|
+
<!-- Backmatter references and glossary are unique and un-numbered, -->
|
|
216
|
+
<!-- so an empty serial number. These matches supersede the above. -->
|
|
217
|
+
<xsl:template match="backmatter/references" mode="serial-number" />
|
|
218
|
+
<xsl:template match="backmatter/glossary" mode="serial-number" />
|
|
219
|
+
|
|
220
|
+
<!-- Serial number of a block: read the @serial that the assembly -->
|
|
221
|
+
<!-- "serial-stamp" pass stamped. That pass decides, from the -->
|
|
222
|
+
<!-- publication "@distinct" switches, whether a group shares the -->
|
|
223
|
+
<!-- overall blocks counter or runs on its own distinct counter. -->
|
|
224
|
+
<xsl:template match="&DEFINITION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;|&PROJECT-LIKE;|&FIGURE-LIKE;|&OPENPROBLEM-LIKE;|exercise" mode="serial-number">
|
|
225
|
+
<xsl:value-of select="@serial"/>
|
|
226
|
+
</xsl:template>
|
|
227
|
+
|
|
228
|
+
<!-- Proofs may be numbered (for cross-reference knowls) -->
|
|
229
|
+
<xsl:template match="&PROOF-LIKE;" mode="serial-number">
|
|
230
|
+
<xsl:number count="&PROOF-LIKE;"/>
|
|
231
|
+
</xsl:template>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
<!-- Serial Numbers: Equations -->
|
|
235
|
+
<!-- The assembly equation-serial pass stamps @serial on every numbered -->
|
|
236
|
+
<!-- <mrow>; here we just read it back. Scope rules and pad/truncate -->
|
|
237
|
+
<!-- behaviour live in the assembly pass. -->
|
|
238
|
+
<xsl:template match="mrow[@pi:numbered = 'yes']" mode="serial-number">
|
|
239
|
+
<xsl:value-of select="@serial"/>
|
|
240
|
+
</xsl:template>
|
|
241
|
+
|
|
242
|
+
<!-- An authored bare "md" may carry an @xml:id, and so may be cross-referenced. -->
|
|
243
|
+
<!-- We consider its number, as a target of a cross-reference to be that of the -->
|
|
244
|
+
<!-- contained, single "mrow". This may be an actual number or may be an empty -->
|
|
245
|
+
<!-- string, depending on how the "md" was meant to be numbered. -->
|
|
246
|
+
<xsl:template match="md[@pi:authored-one-line]" mode="serial-number">
|
|
247
|
+
<xsl:apply-templates select="mrow" mode="serial-number"/>
|
|
248
|
+
</xsl:template>
|
|
249
|
+
|
|
250
|
+
<!-- Serial Numbers: Exercises in Exercises or Worksheet or Reading Question Divisions -->
|
|
251
|
+
<!-- Note: numbers may be hard-coded for longevity -->
|
|
252
|
+
<!-- exercisegroups and future lightweight divisions may -->
|
|
253
|
+
<!-- be intermediate, but should not hinder the count -->
|
|
254
|
+
<!-- NB: there are three historical "apply-templates" -->
|
|
255
|
+
<!-- here which might now be written as "value-of", -->
|
|
256
|
+
<!-- but perhaps it is irrelevant -->
|
|
257
|
+
<xsl:template match="exercises//exercise" mode="serial-number">
|
|
258
|
+
<xsl:number from="exercises" level="any" count="exercise" />
|
|
259
|
+
</xsl:template>
|
|
260
|
+
|
|
261
|
+
<xsl:template match="exercises//exercise[@number]" mode="serial-number">
|
|
262
|
+
<xsl:apply-templates select="@number" />
|
|
263
|
+
</xsl:template>
|
|
264
|
+
|
|
265
|
+
<xsl:template match="worksheet//exercise" mode="serial-number">
|
|
266
|
+
<xsl:number from="worksheet" level="any" count="exercise" />
|
|
267
|
+
</xsl:template>
|
|
268
|
+
|
|
269
|
+
<xsl:template match="worksheet//exercise[@number]" mode="serial-number">
|
|
270
|
+
<xsl:apply-templates select="@number" />
|
|
271
|
+
</xsl:template>
|
|
272
|
+
|
|
273
|
+
<xsl:template match="reading-questions//exercise" mode="serial-number">
|
|
274
|
+
<xsl:number from="reading-questions" level="any" count="exercise" />
|
|
275
|
+
</xsl:template>
|
|
276
|
+
|
|
277
|
+
<xsl:template match="reading-questions//exercise[@number]" mode="serial-number">
|
|
278
|
+
<xsl:apply-templates select="@number" />
|
|
279
|
+
</xsl:template>
|
|
280
|
+
|
|
281
|
+
<!-- Serial Numbers: Solutions -->
|
|
282
|
+
<!-- Hints, answers, solutions may be numbered (for cross-reference knowls) -->
|
|
283
|
+
<xsl:template match="&SOLUTION-LIKE;" mode="serial-number">
|
|
284
|
+
<xsl:number />
|
|
285
|
+
</xsl:template>
|
|
286
|
+
|
|
287
|
+
<!-- Serial Numbers: Bibliographic Items -->
|
|
288
|
+
<!-- Always sequential within a References section -->
|
|
289
|
+
<xsl:template match="biblio" mode="serial-number">
|
|
290
|
+
<xsl:number from="references" level="any" count="biblio" />
|
|
291
|
+
</xsl:template>
|
|
292
|
+
<!-- Notes may be numbered (for cross-reference knowls) -->
|
|
293
|
+
<xsl:template match="biblio/note" mode="serial-number">
|
|
294
|
+
<xsl:number />
|
|
295
|
+
</xsl:template>
|
|
296
|
+
|
|
297
|
+
<!-- Hints, answers, solutions, notes are often singletons. -->
|
|
298
|
+
<!-- This utility returns the serial number, or if a singleton, -->
|
|
299
|
+
<!-- returns an empty string. Employing templates will need -->
|
|
300
|
+
<!-- to check if they want to react accordingly, or they should -->
|
|
301
|
+
<!-- just ask for the serial number itself if they don't care. -->
|
|
302
|
+
<xsl:template match="&SOLUTION-LIKE;|biblio/note" mode="non-singleton-number">
|
|
303
|
+
<xsl:variable name="the-number">
|
|
304
|
+
<xsl:apply-templates select="." mode="serial-number" />
|
|
305
|
+
</xsl:variable>
|
|
306
|
+
<xsl:choose>
|
|
307
|
+
<!-- non-singletons always of interest/use -->
|
|
308
|
+
<xsl:when test="not($the-number = 1)">
|
|
309
|
+
<xsl:value-of select="$the-number" />
|
|
310
|
+
</xsl:when>
|
|
311
|
+
<!-- now being careful with "1" -->
|
|
312
|
+
<xsl:otherwise>
|
|
313
|
+
<xsl:variable name="elt-name" select="local-name(.)" />
|
|
314
|
+
<!-- We go to the parent, get all like children, then -->
|
|
315
|
+
<!-- filter by name, since hints and answers, etc all mix -->
|
|
316
|
+
<xsl:variable name="siblings-and-self" select="parent::*/*[local-name(.) = $elt-name]" />
|
|
317
|
+
<!-- maybe "1" is interesting too -->
|
|
318
|
+
<!-- if not, no result whatsoever -->
|
|
319
|
+
<xsl:if test="count($siblings-and-self) > 1">
|
|
320
|
+
<xsl:value-of select="$the-number" />
|
|
321
|
+
</xsl:if>
|
|
322
|
+
</xsl:otherwise>
|
|
323
|
+
</xsl:choose>
|
|
324
|
+
</xsl:template>
|
|
325
|
+
|
|
326
|
+
<!-- Serial Numbers: Footnotes -->
|
|
327
|
+
<!-- We determine the appropriate subtree to count within -->
|
|
328
|
+
<!-- given the document root and the configured depth -->
|
|
329
|
+
<!-- @serial is stamped on every fn during assembly; here we read it back. -->
|
|
330
|
+
<xsl:template match="fn" mode="serial-number">
|
|
331
|
+
<xsl:value-of select="@serial"/>
|
|
332
|
+
</xsl:template>
|
|
333
|
+
|
|
334
|
+
<!-- Serial Numbers: Subfigures, Subtables, Sublisting-->
|
|
335
|
+
<!-- Subnumbering only happens with figures -->
|
|
336
|
+
<!-- or tables arranged in a sidebyside, which -->
|
|
337
|
+
<!-- is again contained inside a figure, the -->
|
|
338
|
+
<!-- element providing the overall caption -->
|
|
339
|
+
<!-- The serial number is a sub-number, (a), (b), (c), -->
|
|
340
|
+
<!-- *Always* with the parenthetical formatting -->
|
|
341
|
+
<!-- Debatable if parentheses should come from here -->
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
<!-- In this case the structure number is the -->
|
|
345
|
+
<!-- full number of the enclosing figure -->
|
|
346
|
+
|
|
347
|
+
<!-- a lone sidebyside, not in a sbsgroup -->
|
|
348
|
+
<xsl:template match="figure/sidebyside/figure | figure/sidebyside/table | figure/sidebyside/listing | figure/sidebyside/list" mode="serial-number">
|
|
349
|
+
<xsl:text>(</xsl:text>
|
|
350
|
+
<xsl:number format="a" count="&FIGURE-LIKE;"/>
|
|
351
|
+
<xsl:text>)</xsl:text>
|
|
352
|
+
</xsl:template>
|
|
353
|
+
|
|
354
|
+
<!-- when inside a sbsgroup, subnumbers range across entire group -->
|
|
355
|
+
<xsl:template match="figure/sbsgroup/sidebyside/figure | figure/sbsgroup/sidebyside/table | figure/sbsgroup/sidebyside/listing | figure/sbsgroup/sidebyside/list" mode="serial-number">
|
|
356
|
+
<xsl:text>(</xsl:text>
|
|
357
|
+
<xsl:number format="a" count="&FIGURE-LIKE;" level="any" from="sbsgroup"/>
|
|
358
|
+
<xsl:text>)</xsl:text>
|
|
359
|
+
</xsl:template>
|
|
360
|
+
|
|
361
|
+
<!-- Serial Numbers: List Items -->
|
|
362
|
+
|
|
363
|
+
<!-- First, the number of a list item within its own ordered list. This -->
|
|
364
|
+
<!-- trades on the PTX format codes being identical to the XSLT codes. -->
|
|
365
|
+
<xsl:template match="ol/li" mode="item-number">
|
|
366
|
+
<xsl:variable name="code" select="../@format-code" />
|
|
367
|
+
<xsl:number format="{$code}" />
|
|
368
|
+
</xsl:template>
|
|
369
|
+
|
|
370
|
+
<!-- Second, the serial number computed recursively. The -->
|
|
371
|
+
<!-- entire hierarchy should be ordered lists, since otherwise, -->
|
|
372
|
+
<!-- the template just below will apply instead. -->
|
|
373
|
+
<xsl:template match="ol/li" mode="serial-number">
|
|
374
|
+
<xsl:if test="ancestor::li">
|
|
375
|
+
<xsl:apply-templates select="ancestor::li[1]" mode="serial-number" />
|
|
376
|
+
<xsl:text>.</xsl:text>
|
|
377
|
+
</xsl:if>
|
|
378
|
+
<xsl:apply-templates select="." mode="item-number" />
|
|
379
|
+
</xsl:template>
|
|
380
|
+
|
|
381
|
+
<!-- If any ancestor of a list item is not ordered, this -->
|
|
382
|
+
<!-- template should match first, and the serial number -->
|
|
383
|
+
<!-- will be empty, the signal that an object has no number. -->
|
|
384
|
+
<xsl:template match="ul//li|dl//li" mode="serial-number" />
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
<!-- Serial Numbers: Exercise Groups -->
|
|
388
|
+
<!-- We provide the range of the -->
|
|
389
|
+
<!-- group as its serial number. -->
|
|
390
|
+
<xsl:template match="exercisegroup" mode="serial-number">
|
|
391
|
+
<xsl:apply-templates select="exercise[1]" mode="serial-number" />
|
|
392
|
+
<xsl:call-template name="ndash-character"/>
|
|
393
|
+
<xsl:apply-templates select="exercise[last()]" mode="serial-number" />
|
|
394
|
+
</xsl:template>
|
|
395
|
+
|
|
396
|
+
<!-- Serial Numbers: Tasks (in Projects) -->
|
|
397
|
+
<!-- Tasks have "list" numbers, which we use on labels -->
|
|
398
|
+
<!-- (we could use serial numbers for a more complex look) -->
|
|
399
|
+
<xsl:template match="task" mode="list-number">
|
|
400
|
+
<xsl:number format="a" />
|
|
401
|
+
</xsl:template>
|
|
402
|
+
<xsl:template match="task/task" mode="list-number">
|
|
403
|
+
<xsl:number format="i" />
|
|
404
|
+
</xsl:template>
|
|
405
|
+
<xsl:template match="task/task/task" mode="list-number">
|
|
406
|
+
<xsl:number format="A" />
|
|
407
|
+
</xsl:template>
|
|
408
|
+
<!-- concatenate list numbers to get serial numbers, eg a.i.A -->
|
|
409
|
+
<xsl:template match="task" mode="serial-number">
|
|
410
|
+
<xsl:apply-templates select="." mode="list-number" />
|
|
411
|
+
</xsl:template>
|
|
412
|
+
<xsl:template match="task/task" mode="serial-number">
|
|
413
|
+
<xsl:apply-templates select="parent::task" mode="serial-number" />
|
|
414
|
+
<xsl:text>.</xsl:text>
|
|
415
|
+
<xsl:apply-templates select="." mode="list-number" />
|
|
416
|
+
</xsl:template>
|
|
417
|
+
<xsl:template match="task/task/task" mode="serial-number">
|
|
418
|
+
<xsl:apply-templates select="parent::task" mode="serial-number" />
|
|
419
|
+
<xsl:text>.</xsl:text>
|
|
420
|
+
<xsl:apply-templates select="." mode="list-number" />
|
|
421
|
+
</xsl:template>
|
|
422
|
+
|
|
423
|
+
<!-- Serial Numbers: fragments -->
|
|
424
|
+
<!-- Simply numbered sequentially, globally. -->
|
|
425
|
+
<xsl:template match="fragment" mode="serial-number">
|
|
426
|
+
<xsl:number level="any"/>
|
|
427
|
+
</xsl:template>
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
<!-- Serial Numbers: the unnumbered -->
|
|
431
|
+
<!-- Empty string signifies not numbered -->
|
|
432
|
+
|
|
433
|
+
<!-- We choose not to number unique, or semi-unique -->
|
|
434
|
+
<!-- (eg prefaces, colophons), elements. Other elements -->
|
|
435
|
+
<!-- are meant as local commentary, and may also carry -->
|
|
436
|
+
<!-- a title for identification and cross-referencing. -->
|
|
437
|
+
<xsl:template match="book|article|letter|memo|paragraphs|blockquote|preface|abstract|acknowledgement|biography|foreword|dedication|contributors|index-part|index[index-list]|colophon|webwork|p|assemblage|aside|biographical|historical|case|contributor" mode="serial-number" />
|
|
438
|
+
|
|
439
|
+
<!-- Some divisions, like "exercises", "solutions", "references", -->
|
|
440
|
+
<!-- are part of the hierarchical numbering scheme, and look simply -->
|
|
441
|
+
<!-- to their parent. Which could be the top-level when in th main -->
|
|
442
|
+
<!-- matter (we handle cases of children of "backmatter" carefully -->
|
|
443
|
+
<!-- elsewhere or it does not happen). So we need an empty structure -->
|
|
444
|
+
<!-- number for these cases. -->
|
|
445
|
+
<xsl:template match="book|article|letter|memo" mode="structure-number" />
|
|
446
|
+
|
|
447
|
+
<!-- Some items are "containers". They are not numbered, you -->
|
|
448
|
+
<!-- cannot point to them, they are invisible to the reader -->
|
|
449
|
+
<!-- in a way. We kill their serial numbers explicitly here. -->
|
|
450
|
+
<!-- Lists live in paragraphs, exercises, objectives, so -->
|
|
451
|
+
<!-- should be referenced as part of some enclosing element. -->
|
|
452
|
+
<!-- "mathbook" helps some tree-climbing routines halt -->
|
|
453
|
+
<xsl:template match="mathbook|pretext|introduction|conclusion|frontmatter|backmatter|sidebyside|sbsgroup|ol|ul|dl|statement" mode="serial-number" />
|
|
454
|
+
|
|
455
|
+
<!-- Poems go by their titles, not numbers -->
|
|
456
|
+
<xsl:template match="poem" mode="serial-number" />
|
|
457
|
+
|
|
458
|
+
<!-- Preformatted ("pre") appear in search results by name -->
|
|
459
|
+
<xsl:template match="pre" mode="serial-number" />
|
|
460
|
+
|
|
461
|
+
<!-- List items, subordinate to an unordered list, or a description -->
|
|
462
|
+
<!-- list, will have numbers that are especically ambiguous, perhaps -->
|
|
463
|
+
<!-- even very clsoe within a multi-level list. They are unnumbered -->
|
|
464
|
+
<!-- in the vicinity of computing serial numbers of list items in -->
|
|
465
|
+
<!-- ordered lists. -->
|
|
466
|
+
|
|
467
|
+
<!-- Every displayed equation eventually lands inside an "mrow" and -->
|
|
468
|
+
<!-- the pre-processor identifies it as numbered or not, so the -->
|
|
469
|
+
<!-- unnumbered ones are straightforward. A local tag (@tag) -->
|
|
470
|
+
<!-- authored on an "mrow" is considered an unnumbered equation. -->
|
|
471
|
+
<xsl:template match="mrow[@pi:numbered = 'no']" mode="serial-number"/>
|
|
472
|
+
|
|
473
|
+
<!-- WeBWorK problems are never numbered, because they live -->
|
|
474
|
+
<!-- in (numbered) exercises. But they have identically named -->
|
|
475
|
+
<!-- components of exercises, so we might need to explicitly -->
|
|
476
|
+
<!-- make webwork/solution, etc to be unnumbered. -->
|
|
477
|
+
|
|
478
|
+
<!-- Glossary items ("gi"), in a "glossary", are known by their title -->
|
|
479
|
+
<xsl:template match="gi" mode="serial-number"/>
|
|
480
|
+
|
|
481
|
+
<!-- GOAL-LIKE are one-per-subdivision, -->
|
|
482
|
+
<!-- and so get their serial number from their parent -->
|
|
483
|
+
<xsl:template match="&GOAL-LIKE;" mode="serial-number">
|
|
484
|
+
<xsl:apply-templates select="parent::*" mode="serial-number" />
|
|
485
|
+
</xsl:template>
|
|
486
|
+
|
|
487
|
+
<!-- A subexercises is meant to be minimal, and does not have a number -->
|
|
488
|
+
<xsl:template match="subexercises" mode="serial-number"/>
|
|
489
|
+
|
|
490
|
+
<!-- We only allow one "instructions" for an "interactive" -->
|
|
491
|
+
<xsl:template match="interactive/instructions" mode="serial-number"/>
|
|
492
|
+
|
|
493
|
+
<!-- Multi-part WeBWorK problems have PTX elements -->
|
|
494
|
+
<!-- called "stage" which typically render as "Part..." -->
|
|
495
|
+
<!-- Their serial numbers are useful, there is no attempt -->
|
|
496
|
+
<!-- above to integrate these into our general scheme -->
|
|
497
|
+
<!-- These are just counted among enclosing "webwork" -->
|
|
498
|
+
<xsl:template match="webwork/stage" mode="serial-number">
|
|
499
|
+
<xsl:number count="stage" from="webwork" />
|
|
500
|
+
</xsl:template>
|
|
501
|
+
|
|
502
|
+
<!-- But when a problem is part of the OPL and is retrieved -->
|
|
503
|
+
<!-- from the server, then we don't see the "stage" element -->
|
|
504
|
+
<!-- until we merge in the "static" version as part of the -->
|
|
505
|
+
<!-- "webwork-reps" collection -->
|
|
506
|
+
<xsl:template match="webwork-reps/static/stage" mode="serial-number">
|
|
507
|
+
<xsl:number count="stage" from="static" />
|
|
508
|
+
</xsl:template>
|
|
509
|
+
|
|
510
|
+
<!-- OPENPROBLEM-LIKE are blocks: their serial number is read from @serial, -->
|
|
511
|
+
<!-- alongside the other block families above. Their structure number -->
|
|
512
|
+
<!-- follows the figure/project pattern: the open-problem level when they -->
|
|
513
|
+
<!-- run on a distinct counter, otherwise the shared "blocks" level. -->
|
|
514
|
+
<xsl:template match="&OPENPROBLEM-LIKE;" mode="structure-number">
|
|
515
|
+
<xsl:variable name="openproblem-levels">
|
|
516
|
+
<xsl:choose>
|
|
517
|
+
<xsl:when test="$b-number-openproblem-distinct">
|
|
518
|
+
<xsl:value-of select="$numbering-openproblems" />
|
|
519
|
+
</xsl:when>
|
|
520
|
+
<xsl:otherwise>
|
|
521
|
+
<xsl:value-of select="$numbering-blocks" />
|
|
522
|
+
</xsl:otherwise>
|
|
523
|
+
</xsl:choose>
|
|
524
|
+
</xsl:variable>
|
|
525
|
+
<xsl:call-template name="block-structure-number">
|
|
526
|
+
<xsl:with-param name="levels" select="$openproblem-levels"/>
|
|
527
|
+
</xsl:call-template>
|
|
528
|
+
</xsl:template>
|
|
529
|
+
|
|
530
|
+
<!-- DISCUSSION-LIKE are appendages; their number is inherited from the parent. -->
|
|
531
|
+
<xsl:template match="&DISCUSSION-LIKE;" mode="serial-number">
|
|
532
|
+
<xsl:number select="parent::*" count="&DISCUSSION-LIKE;"/>
|
|
533
|
+
</xsl:template>
|
|
534
|
+
<xsl:template match="&DISCUSSION-LIKE;" mode="structure-number">
|
|
535
|
+
<xsl:apply-templates select="parent::*" mode="number"/>
|
|
536
|
+
</xsl:template>
|
|
537
|
+
|
|
538
|
+
<!-- No numbers on pages of worksheets -->
|
|
539
|
+
<xsl:template match="page" mode="serial-number"/>
|
|
540
|
+
|
|
541
|
+
<!-- Should not drop in here. Ever. -->
|
|
542
|
+
<xsl:template match="*" mode="serial-number">
|
|
543
|
+
<xsl:text>[NUM]</xsl:text>
|
|
544
|
+
<xsl:message>PTX:ERROR: An object (<xsl:value-of select="local-name(.)" />) lacks a serial number, search output for "[NUM]"</xsl:message>
|
|
545
|
+
<xsl:apply-templates select="." mode="location-report" />
|
|
546
|
+
</xsl:template>
|
|
547
|
+
|
|
548
|
+
<!-- -->
|
|
549
|
+
<!-- Multi-Numbers Utility -->
|
|
550
|
+
<!-- -->
|
|
551
|
+
|
|
552
|
+
<!-- -->
|
|
553
|
+
<!-- Structure Numbers -->
|
|
554
|
+
<!-- -->
|
|
555
|
+
|
|
556
|
+
<!-- We compute multi-part numbers to the necessary, -->
|
|
557
|
+
<!-- or configured, number of components -->
|
|
558
|
+
<!-- NB: *every* structure number should finish with -->
|
|
559
|
+
<!-- a period as a separator, which is often provided -->
|
|
560
|
+
<!-- by the "multi-number" template. Some of the -->
|
|
561
|
+
<!-- cross-reference text code adds a period before -->
|
|
562
|
+
<!-- testing equality of strings -->
|
|
563
|
+
|
|
564
|
+
<!-- Structure Numbers: Divisions -->
|
|
565
|
+
<!-- NB: this is number of the *container* of the division, -->
|
|
566
|
+
<!-- a serial number for the division itself will be appended -->
|
|
567
|
+
<xsl:template match="part|chapter|appendix|section|subsection|subsubsection|backmatter/solutions" mode="structure-number">
|
|
568
|
+
<xsl:value-of select="@struct"/>
|
|
569
|
+
</xsl:template>
|
|
570
|
+
|
|
571
|
+
<!-- Structure Numbers: Specialized Divisions -->
|
|
572
|
+
<!-- Some divisions get their numbers from their parents, or -->
|
|
573
|
+
<!-- in other ways. We are careful to do this by determining -->
|
|
574
|
+
<!-- the serial-numer and the structure-number, so that other -->
|
|
575
|
+
<!-- devices (like local numbers) will behave correctly. -->
|
|
576
|
+
<!-- Serial numbers are computed elsewhere, but in tandem. -->
|
|
577
|
+
<xsl:template match="exercises|solutions[not(parent::backmatter)]|worksheet|handout|reading-questions|references[not(parent::backmatter)]|glossary[not(parent::backmatter)]" mode="structure-number">
|
|
578
|
+
<xsl:variable name="is-numbered">
|
|
579
|
+
<xsl:apply-templates select="." mode="is-specialized-own-number"/>
|
|
580
|
+
</xsl:variable>
|
|
581
|
+
<xsl:choose>
|
|
582
|
+
<xsl:when test="$is-numbered = 'true'">
|
|
583
|
+
<xsl:value-of select="@struct"/>
|
|
584
|
+
</xsl:when>
|
|
585
|
+
<xsl:otherwise>
|
|
586
|
+
<xsl:apply-templates select="parent::*" mode="structure-number" />
|
|
587
|
+
</xsl:otherwise>
|
|
588
|
+
</xsl:choose>
|
|
589
|
+
</xsl:template>
|
|
590
|
+
<!-- "references" and "glossary" are solo in main matter -->
|
|
591
|
+
<!-- divisions, unique and not numbered in back matter -->
|
|
592
|
+
<xsl:template match="backmatter/references" mode="structure-number" />
|
|
593
|
+
<xsl:template match="backmatter/glossary" mode="structure-number" />
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
<!-- Structure Numbers: Theorems, Examples, Projects, Figures -->
|
|
597
|
+
<xsl:template match="&DEFINITION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;" mode="structure-number">
|
|
598
|
+
<xsl:call-template name="block-structure-number">
|
|
599
|
+
<xsl:with-param name="levels" select="$numbering-blocks"/>
|
|
600
|
+
</xsl:call-template>
|
|
601
|
+
</xsl:template>
|
|
602
|
+
<!-- PROJECT-LIKE is now independent, under control of $numbering-projects -->
|
|
603
|
+
<!-- But all ready to become elective -->
|
|
604
|
+
<xsl:template match="&PROJECT-LIKE;" mode="structure-number">
|
|
605
|
+
<xsl:variable name="project-levels">
|
|
606
|
+
<xsl:choose>
|
|
607
|
+
<xsl:when test="$b-number-project-distinct">
|
|
608
|
+
<xsl:value-of select="$numbering-projects" />
|
|
609
|
+
</xsl:when>
|
|
610
|
+
<xsl:otherwise>
|
|
611
|
+
<xsl:value-of select="$numbering-blocks" />
|
|
612
|
+
</xsl:otherwise>
|
|
613
|
+
</xsl:choose>
|
|
614
|
+
</xsl:variable>
|
|
615
|
+
<xsl:call-template name="block-structure-number">
|
|
616
|
+
<xsl:with-param name="levels" select="$project-levels"/>
|
|
617
|
+
</xsl:call-template>
|
|
618
|
+
</xsl:template>
|
|
619
|
+
<!-- FIGURE-LIKE get a structure number from default $numbering-blocks -->
|
|
620
|
+
<!-- or from "docinfo" independent numbering configuration -->
|
|
621
|
+
<xsl:template match="&FIGURE-LIKE;" mode="structure-number">
|
|
622
|
+
<xsl:variable name="figure-levels">
|
|
623
|
+
<xsl:choose>
|
|
624
|
+
<xsl:when test="$b-number-figure-distinct">
|
|
625
|
+
<xsl:value-of select="$numbering-figures" />
|
|
626
|
+
</xsl:when>
|
|
627
|
+
<xsl:otherwise>
|
|
628
|
+
<xsl:value-of select="$numbering-blocks" />
|
|
629
|
+
</xsl:otherwise>
|
|
630
|
+
</xsl:choose>
|
|
631
|
+
</xsl:variable>
|
|
632
|
+
<xsl:call-template name="block-structure-number">
|
|
633
|
+
<xsl:with-param name="levels" select="$figure-levels"/>
|
|
634
|
+
</xsl:call-template>
|
|
635
|
+
</xsl:template>
|
|
636
|
+
<!-- Proofs get structure number from parent theorem -->
|
|
637
|
+
<!-- NB: assumes proofs are not detached? Maybe not. -->
|
|
638
|
+
<!-- Definitely a detached proof in a "paragraphs" is bad -->
|
|
639
|
+
<xsl:template match="&PROOF-LIKE;" mode="structure-number">
|
|
640
|
+
<xsl:apply-templates select="parent::*" mode="number" />
|
|
641
|
+
</xsl:template>
|
|
642
|
+
<!-- Captioned items, arranged in a side-by-side, -->
|
|
643
|
+
<!-- then inside a captioned figure, earn a serial -->
|
|
644
|
+
<!-- number that is a letter. So their structure -->
|
|
645
|
+
<!-- number comes from the enclosing captioned figure. -->
|
|
646
|
+
<!-- The sidebyside may be a child of the figure, -->
|
|
647
|
+
<!-- or wrapped in an sbsgroup. -->
|
|
648
|
+
<xsl:template match="figure/sidebyside/figure | figure/sidebyside/table | figure/sidebyside/listing | figure/sidebyside/list" mode="structure-number">
|
|
649
|
+
<xsl:apply-templates select="parent::sidebyside/parent::figure" mode="number" />
|
|
650
|
+
</xsl:template>
|
|
651
|
+
<xsl:template match="figure/sbsgroup/sidebyside/figure | figure/sbsgroup/sidebyside/table | figure/sbsgroup/sidebyside/listing | figure/sbsgroup/sidebyside/list" mode="structure-number">
|
|
652
|
+
<xsl:apply-templates select="parent::sidebyside/parent::sbsgroup/parent::figure" mode="number" />
|
|
653
|
+
</xsl:template>
|
|
654
|
+
|
|
655
|
+
<!-- Structure Numbers: Equations -->
|
|
656
|
+
<!-- "mrow" may be numbered, and bare "md" inherit a number from their -->
|
|
657
|
+
<!-- manufactured single "mrow". So we need a structure number for the -->
|
|
658
|
+
<!-- numbered versions of these elements. -->
|
|
659
|
+
<xsl:template match="mrow|md[@pi:authored-one-line]" mode="structure-number">
|
|
660
|
+
<xsl:call-template name="block-structure-number">
|
|
661
|
+
<xsl:with-param name="levels" select="$numbering-equations"/>
|
|
662
|
+
</xsl:call-template>
|
|
663
|
+
</xsl:template>
|
|
664
|
+
|
|
665
|
+
<!-- Structure Numbers: Inline Exercises -->
|
|
666
|
+
<!-- Follows the theorem/figure/etc scheme. The second alternative -->
|
|
667
|
+
<!-- adds an inline exercise in a division introduction or conclusion -->
|
|
668
|
+
<!-- (its parent is not in the inline filter); divisional-container -->
|
|
669
|
+
<!-- exercises are handled by the next template instead. -->
|
|
670
|
+
<xsl:template match="exercise[boolean(&INLINE-EXERCISE-FILTER;)]|exercise[(parent::introduction or parent::conclusion) and not(ancestor::exercises or ancestor::worksheet or ancestor::reading-questions)]" mode="structure-number">
|
|
671
|
+
<xsl:variable name="exercise-levels">
|
|
672
|
+
<xsl:choose>
|
|
673
|
+
<xsl:when test="$b-number-exercise-distinct">
|
|
674
|
+
<xsl:value-of select="$numbering-exercises" />
|
|
675
|
+
</xsl:when>
|
|
676
|
+
<xsl:otherwise>
|
|
677
|
+
<xsl:value-of select="$numbering-blocks" />
|
|
678
|
+
</xsl:otherwise>
|
|
679
|
+
</xsl:choose>
|
|
680
|
+
</xsl:variable>
|
|
681
|
+
<xsl:call-template name="block-structure-number">
|
|
682
|
+
<xsl:with-param name="levels" select="$exercise-levels"/>
|
|
683
|
+
</xsl:call-template>
|
|
684
|
+
</xsl:template>
|
|
685
|
+
|
|
686
|
+
<!-- Structure Numbers: Divisional and Worksheet Exercises -->
|
|
687
|
+
<!-- Within a "exercises" or "worksheet", look up to enclosing division -->
|
|
688
|
+
<!-- in order to decide where the structure number comes from -->
|
|
689
|
+
<xsl:template match="exercises//exercise|worksheet//exercise|reading-questions//exercise" mode="structure-number">
|
|
690
|
+
<!-- Need to look up through "exercisegroup", "subexercises", "sidebyside", etc -->
|
|
691
|
+
<!-- Only one of these specialized divisions, just a single node in variable -->
|
|
692
|
+
<xsl:variable name="container" select="ancestor::*[self::exercises or self::worksheet or self::reading-questions]"/>
|
|
693
|
+
<xsl:apply-templates select="$container" mode="number" />
|
|
694
|
+
</xsl:template>
|
|
695
|
+
|
|
696
|
+
<!-- Structure Numbers: Exercise Groups -->
|
|
697
|
+
<!-- An exercisegroup gets it structure number from the parent exercises -->
|
|
698
|
+
<xsl:template match="exercisegroup" mode="structure-number">
|
|
699
|
+
<xsl:apply-templates select="parent::*" mode="number" />
|
|
700
|
+
</xsl:template>
|
|
701
|
+
|
|
702
|
+
<!-- Hints, answers, solutions get structure number from parent -->
|
|
703
|
+
<!-- exercise's number. Identical for inline and divisional exercises -->
|
|
704
|
+
<xsl:template match="&SOLUTION-LIKE;" mode="structure-number">
|
|
705
|
+
<xsl:apply-templates select="parent::*" mode="number" />
|
|
706
|
+
</xsl:template>
|
|
707
|
+
|
|
708
|
+
<!-- Anything within a webwork-reps that needs a structure number -->
|
|
709
|
+
<!-- gets it from the enclosing exercise. -->
|
|
710
|
+
<xsl:template match="webwork-reps//*" mode="structure-number">
|
|
711
|
+
<xsl:apply-templates select="ancestor::exercise" mode="number" />
|
|
712
|
+
</xsl:template>
|
|
713
|
+
|
|
714
|
+
<!-- Structure Numbers: Bibliographic Items -->
|
|
715
|
+
<!-- Bibliographic items get their number from the containing -->
|
|
716
|
+
<!-- "references", which may be solo in an unstructured division, -->
|
|
717
|
+
<!-- or one of potentially several in a structured division. -->
|
|
718
|
+
<!-- Since the global "references" (child of "backmatter") is not -->
|
|
719
|
+
<!-- numbered, these items will have un-qualified numbers -->
|
|
720
|
+
<!-- (serial number only). -->
|
|
721
|
+
<xsl:template match="biblio" mode="structure-number">
|
|
722
|
+
<xsl:apply-templates select="parent::*" mode="number" />
|
|
723
|
+
</xsl:template>
|
|
724
|
+
|
|
725
|
+
<!-- Notes get structure number from parent biblio's number -->
|
|
726
|
+
<xsl:template match="biblio/note" mode="structure-number">
|
|
727
|
+
<xsl:apply-templates select="parent::*" mode="number" />
|
|
728
|
+
</xsl:template>
|
|
729
|
+
|
|
730
|
+
<!-- Structure Numbers: Footnotes -->
|
|
731
|
+
<xsl:template match="fn" mode="structure-number">
|
|
732
|
+
<xsl:call-template name="block-structure-number">
|
|
733
|
+
<xsl:with-param name="levels" select="$numbering-footnotes"/>
|
|
734
|
+
</xsl:call-template>
|
|
735
|
+
</xsl:template>
|
|
736
|
+
|
|
737
|
+
<!-- Structure Numbers: Lists -->
|
|
738
|
+
<!-- Lists occur in paragraphs (anonymously), in "list" -->
|
|
739
|
+
<!-- blocks (numbered), and within exercises (numbered). -->
|
|
740
|
+
<!-- Typically we are interested in list items (only), -->
|
|
741
|
+
<!-- since that is where there is content. And then we -->
|
|
742
|
+
<!-- are only interested in the list items within an ordered -->
|
|
743
|
+
<!-- list. We control for items under unordered lists or -->
|
|
744
|
+
<!-- description lists elsewhere by providing empty numbers. -->
|
|
745
|
+
<!-- NB: the order of these templates may matter -->
|
|
746
|
+
<xsl:template match="li" mode="structure-number" />
|
|
747
|
+
|
|
748
|
+
<xsl:template match="list//li" mode="structure-number">
|
|
749
|
+
<xsl:apply-templates select="ancestor::list" mode="number" />
|
|
750
|
+
</xsl:template>
|
|
751
|
+
|
|
752
|
+
<xsl:template match="exercise//li" mode="structure-number">
|
|
753
|
+
<xsl:apply-templates select="ancestor::exercise" mode="number" />
|
|
754
|
+
</xsl:template>
|
|
755
|
+
|
|
756
|
+
<!-- Structure Numbers: Tasks (in projects) -->
|
|
757
|
+
<!-- A task gets it structure number from the parent project-like -->
|
|
758
|
+
<xsl:template match="task" mode="structure-number">
|
|
759
|
+
<!-- ancestors, strip tasks, get number of next enclosure -->
|
|
760
|
+
<xsl:apply-templates select="ancestor::*[not(self::task)][1]" mode="number" />
|
|
761
|
+
</xsl:template>
|
|
762
|
+
|
|
763
|
+
<!-- Structure Numbers: GOAL-LIKE -->
|
|
764
|
+
<!-- Objectives are one-per-subdivision, and so -->
|
|
765
|
+
<!-- get their structure number from their parent -->
|
|
766
|
+
<xsl:template match="&GOAL-LIKE;" mode="structure-number">
|
|
767
|
+
<xsl:apply-templates select="parent::*" mode="structure-number" />
|
|
768
|
+
</xsl:template>
|
|
769
|
+
|
|
770
|
+
<!-- Structure Numbers: Objective and Outcome-->
|
|
771
|
+
<!-- A single objective or outcome is a list item -->
|
|
772
|
+
<!-- in an objectives or outcomes environment -->
|
|
773
|
+
<xsl:template match="objectives/ol/li|outcomes/ol/li" mode="structure-number">
|
|
774
|
+
<xsl:apply-templates select="ancestor::*[&STRUCTURAL-FILTER;][1]" mode="number" />
|
|
775
|
+
</xsl:template>
|
|
776
|
+
|
|
777
|
+
<!-- Structure Numbers: Fragment -->
|
|
778
|
+
<!-- We number serially, see below -->
|
|
779
|
+
<xsl:template match="fragment" mode="structure-number"/>
|
|
780
|
+
|
|
781
|
+
<!-- worksheet pages are unnumbered -->
|
|
782
|
+
<xsl:template match="page" mode="structure-number"/>
|
|
783
|
+
|
|
784
|
+
<!-- Should not drop in here. Ever. -->
|
|
785
|
+
<xsl:template match="*" mode="structure-number">
|
|
786
|
+
<xsl:text>[STRUCT]</xsl:text>
|
|
787
|
+
<xsl:message>PTX:ERROR: An object (<xsl:value-of select="local-name(.)" />) lacks a structure number, search output for "[STRUCT]"</xsl:message>
|
|
788
|
+
<xsl:apply-templates select="." mode="location-report" />
|
|
789
|
+
</xsl:template>
|
|
790
|
+
|
|
791
|
+
<!-- -->
|
|
792
|
+
<!-- Full Numbers -->
|
|
793
|
+
<!-- -->
|
|
794
|
+
|
|
795
|
+
<!-- Now trivial, the container structure plus the serial. -->
|
|
796
|
+
<!-- We condition on empty serial number in order to create -->
|
|
797
|
+
<!-- empty full numbers. This is where we add separator, -->
|
|
798
|
+
<!-- normally a period, but for a list item within a named -->
|
|
799
|
+
<!-- list, we use a colon (a double period?). -->
|
|
800
|
+
<xsl:template match="*" mode="number">
|
|
801
|
+
<xsl:variable name="serial">
|
|
802
|
+
<xsl:apply-templates select="." mode="serial-number" />
|
|
803
|
+
</xsl:variable>
|
|
804
|
+
<xsl:choose>
|
|
805
|
+
<xsl:when test="$serial = ''" />
|
|
806
|
+
<xsl:otherwise>
|
|
807
|
+
<xsl:variable name="structure">
|
|
808
|
+
<xsl:apply-templates select="." mode="structure-number" />
|
|
809
|
+
</xsl:variable>
|
|
810
|
+
<xsl:if test="not($structure='')">
|
|
811
|
+
<xsl:value-of select="$structure" />
|
|
812
|
+
<xsl:choose>
|
|
813
|
+
<xsl:when test="self::li and ancestor::list">
|
|
814
|
+
<xsl:text>:</xsl:text>
|
|
815
|
+
</xsl:when>
|
|
816
|
+
<!-- A figure-like inside a sidebyside (or -->
|
|
817
|
+
<!-- sbsgroup) inside a figure is subnumbered -->
|
|
818
|
+
<!-- with a letter like "(a)", so the serial -->
|
|
819
|
+
<!-- number already carries its own delimiter -->
|
|
820
|
+
<!-- and no period separator is needed. -->
|
|
821
|
+
<xsl:when test="(&FIGURE-FILTER;) and (parent::sidebyside/parent::figure or parent::sidebyside/parent::sbsgroup/parent::figure)"/>
|
|
822
|
+
<xsl:otherwise>
|
|
823
|
+
<xsl:text>.</xsl:text>
|
|
824
|
+
</xsl:otherwise>
|
|
825
|
+
</xsl:choose>
|
|
826
|
+
</xsl:if>
|
|
827
|
+
<xsl:value-of select="$serial" />
|
|
828
|
+
</xsl:otherwise>
|
|
829
|
+
</xsl:choose>
|
|
830
|
+
</xsl:template>
|
|
831
|
+
|
|
832
|
+
<!-- ##### Division serial numbers ##### -->
|
|
833
|
+
<!-- ############## -->
|
|
834
|
+
<!-- Serial Numbers -->
|
|
835
|
+
<!-- ############## -->
|
|
836
|
+
|
|
837
|
+
<!-- Serial Numbers: Divisions -->
|
|
838
|
+
<!-- To respect the maximum level for numbering, we -->
|
|
839
|
+
<!-- return an empty serial number at an excessive level, -->
|
|
840
|
+
<!-- otherwise we call for a serial number relative to peers -->
|
|
841
|
+
<xsl:template match="part|chapter|appendix|section|subsection|subsubsection|backmatter/solutions" mode="serial-number">
|
|
842
|
+
<xsl:variable name="relative-level">
|
|
843
|
+
<xsl:apply-templates select="." mode="new-level" />
|
|
844
|
+
</xsl:variable>
|
|
845
|
+
<xsl:choose>
|
|
846
|
+
<xsl:when test="$relative-level > $numbering-maxlevel" />
|
|
847
|
+
<xsl:otherwise>
|
|
848
|
+
<xsl:value-of select="@serial"/>
|
|
849
|
+
</xsl:otherwise>
|
|
850
|
+
</xsl:choose>
|
|
851
|
+
</xsl:template>
|
|
852
|
+
|
|
853
|
+
<!-- Serial Numbers: Specialized Divisions -->
|
|
854
|
+
<xsl:template match="exercises|solutions|worksheet|handout|reading-questions|references|glossary" mode="serial-number">
|
|
855
|
+
<xsl:variable name="is-numbered">
|
|
856
|
+
<xsl:apply-templates select="." mode="is-specialized-own-number"/>
|
|
857
|
+
</xsl:variable>
|
|
858
|
+
<xsl:choose>
|
|
859
|
+
<xsl:when test="$is-numbered = 'true'">
|
|
860
|
+
<xsl:variable name="relative-level">
|
|
861
|
+
<xsl:apply-templates select="." mode="new-level" />
|
|
862
|
+
</xsl:variable>
|
|
863
|
+
<xsl:choose>
|
|
864
|
+
<xsl:when test="$relative-level > $numbering-maxlevel" />
|
|
865
|
+
<xsl:otherwise>
|
|
866
|
+
<xsl:value-of select="@serial"/>
|
|
867
|
+
</xsl:otherwise>
|
|
868
|
+
</xsl:choose>
|
|
869
|
+
</xsl:when>
|
|
870
|
+
<xsl:otherwise>
|
|
871
|
+
<xsl:apply-templates select="parent::*" mode="serial-number" />
|
|
872
|
+
</xsl:otherwise>
|
|
873
|
+
</xsl:choose>
|
|
874
|
+
</xsl:template>
|
|
875
|
+
</xsl:stylesheet>
|