In this chapter, we consider conversion of XML to XSL/Format, using the initial Raweb DTD, and we shall explain the difference with the new DTD. The files described in this chapter are part of the Tralics distribution (those for the new DTD are in the Raweb package). All these files are adapted from the TEI distribution; the copyright notice is the same as those given in the previous chapter.
We start with a small file containing some commands that deal with fonts. In the original version of Tralics, the translation of {\tiny etc} was a <hi> element, with an attribute rend = `small´. In the current version, Tralics understands more than three sizes (small, large, and normal), and can indicate these in an element, rather than an attribute. Thus, the translation can be <font-small4>. In this file, we have a big template, that interprets all values of the rend attribute, and a lot of trivial, small templates, that interpret elements like <small4>.
This interprets the rend attribute. The effect is to add attributes to the current element, in general <fo:inline>. In the initial version, the template took two arguments used in case of unknown specification (the default is to use bold font weight). Note: Perhaps, we should replace the value of `small´ by 9pt instead of 8pt.
1 <xsl:template name="rend"> 2 <xsl:choose> 3 <xsl:when test="@rend='overline'"> 4 <xsl:attribute name="text-decoration">overline</xsl:attribute> 5 </xsl:when> 6 <xsl:when test="@rend='underline'"> 7 <xsl:attribute name="text-decoration">underline</xsl:attribute> 8 </xsl:when> 9 <xsl:when test="@rend='oldstyle'"> 10 <xsl:attribute name="font-family">Concrete</xsl:attribute> 11 </xsl:when> 12 <xsl:when test="@rend='ital'"> 13 <xsl:attribute name="font-style">italic</xsl:attribute> 14 </xsl:when> 15 <xsl:when test="@rend='emph'"> 16 <xsl:attribute name="font-style">italic</xsl:attribute> 17 </xsl:when> 18 <xsl:when test="@rend='sub'"> 19 <xsl:attribute name="vertical-align">sub</xsl:attribute> 20 </xsl:when> 21 <xsl:when test="@rend='sup'"> 22 <xsl:attribute name="vertical-align">super</xsl:attribute> 23 </xsl:when> 24 <xsl:when test="@rend='it'"> 25 <xsl:attribute name="font-style">italic</xsl:attribute> 26 </xsl:when> 27 <xsl:when test="@rend='slanted'"> 28 <xsl:attribute name="font-style">italic</xsl:attribute> 29 </xsl:when> 30 <xsl:when test="@rend='sc'"> 31 <xsl:attribute name="font-variant">small-caps</xsl:attribute> 32 </xsl:when> 33 <xsl:when test="@rend='tt'"> 34 <xsl:attribute name="font-family">Computer-Modern-Typewriter</xsl:attribute> 35 </xsl:when> 36 <xsl:when test="@rend='sansserif'"> 37 <xsl:attribute name="font-family">sansserif</xsl:attribute> 38 </xsl:when> 39 <xsl:when test="@rend='bold'"> 40 <xsl:attribute name="font-weight">bold</xsl:attribute> 41 </xsl:when> 42 <xsl:when test="@rend='ul'"> 43 <xsl:attribute name="text-decoration">ul</xsl:attribute> 44 </xsl:when> 45 <xsl:when test="@rend='caps'"> 46 <xsl:attribute name="text-decoration">caps</xsl:attribute> 47 </xsl:when> 48 <xsl:when test="@rend='hl'"> 49 <xsl:attribute name="text-decoration">hl</xsl:attribute> 50 </xsl:when> 51 <xsl:when test="@rend='so'"> 52 <xsl:attribute name="text-decoration">so</xsl:attribute> 53 </xsl:when> 54 <xsl:when test="@rend='st'"> 55 <xsl:attribute name="text-decoration">st</xsl:attribute> 56 </xsl:when> 57 <xsl:when test="@rend='small'"> 58 <xsl:attribute name="font-size">8pt</xsl:attribute> 59 </xsl:when> 60 <xsl:when test="@rend='small1'"> 61 <xsl:attribute name="font-size">9pt</xsl:attribute> 62 </xsl:when> 63 <xsl:when test="@rend='small2'"> 64 <xsl:attribute name="font-size">8pt</xsl:attribute> 65 </xsl:when> 66 <xsl:when test="@rend='small3'"> 67 <xsl:attribute name="font-size">7pt</xsl:attribute> 68 </xsl:when> 69 <xsl:when test="@rend='small4'"> 70 <xsl:attribute name="font-size">5pt</xsl:attribute> 71 </xsl:when> 72 <xsl:when test="@rend='large'"> 73 <xsl:attribute name="font-size">12pt</xsl:attribute> 74 </xsl:when> 75 <xsl:when test="@rend='large1'"> 76 <xsl:attribute name="font-size">12pt</xsl:attribute> 77 </xsl:when> 78 <xsl:when test="@rend='large2'"> 79 <xsl:attribute name="font-size">14pt</xsl:attribute> 80 </xsl:when> 81 <xsl:when test="@rend='large3'"> 82 <xsl:attribute name="font-size">17pt</xsl:attribute> 83 </xsl:when> 84 <xsl:when test="@rend='large4'"> 85 <xsl:attribute name="font-size">20pt</xsl:attribute> 86 </xsl:when> 87 <xsl:when test="@rend='large5'"> 88 <xsl:attribute name="font-size">25pt</xsl:attribute> 89 </xsl:when> 90 <xsl:otherwise> 91 <xsl:attribute name="font-weight">bold</xsl:attribute> 92 </xsl:otherwise> 93 </xsl:choose> 94 </xsl:template>
Replacement code for the rend attribute defined above. In all cases, we provide a long and a short name. We produce an <fo:inline> element, with some attributes. We start with two templates associated to <small> and <large>. The attribute we set is font-size.
95 <xsl:template match='small|font-small'> 96 <fo:inline font-size='8pt'> <xsl:apply-templates/> </fo:inline> 97 </xsl:template>
98 <xsl:template match='large|font-large'> 99 <fo:inline font-size='12pt'> <xsl:apply-templates/> </fo:inline> 100 </xsl:template>
We continue with the ten font size commands of LaTeX. This corresponds to \tiny.
101 <xsl:template match='small4|font-small4'> 102 <fo:inline font-size='5pt'> <xsl:apply-templates/> </fo:inline> 103 </xsl:template>
This corresponds to \scriptsize.
104 <xsl:template match='small3|font-small3'> 105 <fo:inline font-size='7pt'> <xsl:apply-templates/> </fo:inline> 106 </xsl:template>
This corresponds to \footnotesize.
107 <xsl:template match='small2|font_small2'> 108 <fo:inline font-size='8pt'> <xsl:apply-templates/> </fo:inline> 109 </xsl:template>
110 <xsl:template match='small1|font-small1'> 111 <fo:inline font-size='9pt'> <xsl:apply-templates/> </fo:inline> 112 </xsl:template>
This corresponds to \normalsize.
113 <xsl:template match='normalsize|font-normalsize'> 114 <fo:inline font-size='10pt'> <xsl:apply-templates/> </fo:inline> 115 </xsl:template>
116 <xsl:template match='large1|font-large1'> 117 <fo:inline font-size='12pt'> <xsl:apply-templates/> </fo:inline> 118 </xsl:template>
119 <xsl:template match='large2|font-large2'> 120 <fo:inline font-size='14.4pt'> <xsl:apply-templates/> </fo:inline> 121 </xsl:template>
122 <xsl:template match='large3|font-large3'> 123 <fo:inline font-size='17.28pt'> <xsl:apply-templates/> </fo:inline> 124 </xsl:template>
125 <xsl:template match='large4|font-large4'> 126 <fo:inline font-size='20.74pt'> <xsl:apply-templates/> </fo:inline> 127 </xsl:template>
128 <xsl:template match='large5|font-large5'> 129 <fo:inline font-size='24.88pt'> <xsl:apply-templates/> </fo:inline> 130 </xsl:template>
Now the four shapes. The attribute is font-style or font-variant. This corresponds to \itshape.
131 <xsl:template match='it|font-italic-shape'> 132 <fo:inline font-style='italic'> <xsl:apply-templates/> </fo:inline> 133 </xsl:template>
134 <xsl:template match='slanted|font-slanted-shape'> 135 <fo:inline font-style='oblique'> <xsl:apply-templates/> </fo:inline> 136 </xsl:template>
137 <xsl:template match='sc|font-small-caps-shape'> 138 <fo:inline font-variant='small-caps'> <xsl:apply-templates/> </fo:inline> 139 </xsl:template>
140 <xsl:template match='upright|font-upright-shape'> 141 <fo:inline font-variant='normal'> <xsl:apply-templates/> </fo:inline> 142 </xsl:template>
Now the three families. The attribute is font-variant or font-family. We provide two different tt families. This corresponds to \rmfamily.
143 <xsl:template match='roman|font-roman-family'> 144 <fo:inline font-variant='normal'> <xsl:apply-templates/> </fo:inline> 145 </xsl:template>
146 <xsl:template match='sansserif|font-sansserif-family'> 147 <fo:inline font-family='sansserif'> <xsl:apply-templates/> </fo:inline> 148 </xsl:template>
This corresponds to \ttfamily (first variant).
149 <xsl:template match='computer-modern-tt'> 150 <fo:inline font-family='Computer-Modern-Typewriter'> 151 <xsl:apply-templates/> 152 </fo:inline> 153 </xsl:template>
This corresponds to \ttfamily (second variant).
154 <xsl:template match='tt|font-typewriter-family'> 155 <fo:inline font-family='monospace'> <xsl:apply-templates/> </fo:inline> 156 </xsl:template>
Now the two series. The attribute is font-weight. This corresponds to \mdseries.
157 <xsl:template match='medium|font-medium-series'> 158 <fo:inline font-weight='medium'> <xsl:apply-templates/> </fo:inline> 159 </xsl:template>
This corresponds to \bfseries.
160 <xsl:template match='bold|font-bold-series'> 161 <fo:inline font-weight='bold'> <xsl:apply-templates/> </fo:inline> 162 </xsl:template>
Superscript, subscript in text fonts. The attribute is vertical-align.
163 <xsl:template match='sup|font-super'> 164 <fo:inline vertical-align='super'> <xsl:apply-templates/> </fo:inline> 165 </xsl:template>
Case of a subscript (corresponds to a non-standard LaTeX command).
166 <xsl:template match='sub|font-sub'> 167 <fo:inline vertical-align='sub'> <xsl:apply-templates/> </fo:inline> 168 </xsl:template>
Overline, underline in text fonts. The attribute is text-decoration.
169 <xsl:template match='underline|font-underline'> 170 <fo:inline text-decoration='underline'> <xsl:apply-templates/> </fo:inline> 171 </xsl:template>
172 <xsl:template match='overline|font-overline'> 173 <fo:inline text-decoration='overline'> <xsl:apply-templates/> /fo:inline> 174 </xsl:template>
Five elements defined by the soul package. Only the long variant is considered here. The result is a text-decoration.
175 <xsl:template match='font-ul'> 176 <fo:inline text-decoration='ul'> <xsl:apply-templates/> </fo:inline> 177 </xsl:template> 178 <xsl:template match='font-caps'> 179 <fo:inline text-decoration='caps'> <xsl:apply-templates/> </fo:inline> 180 </xsl:template> 181 <xsl:template match='font-hl'> 182 <fo:inline text-decoration='hl'> <xsl:apply-templates/> </fo:inline> 183 </xsl:template> 184 <xsl:template match='font-so'> 185 <fo:inline text-decoration='so'> <xsl:apply-templates/> </fo:inline> 186 </xsl:template> 187 <xsl:template match='font-st'> 188 <fo:inline text-decoration='st'> <xsl:apply-templates/> </fo:inline> 189 </xsl:template>
Translation of <note>. We simplified a bit the code. In the TEI, there is an attribute place, whose value can be `foot´ if the note should appear on the foot of the page, it can be `margin´, `left´, `right´ if the note appears in the margin (or more specifically in the left or right margin), but implementation is incomplete, if can be `display´ or `divtop´ if the note should appear in the text as a block; otherwise it will be inlined (with parentheses around).
In the case of the Raweb, we consider only the case where the note is a footnote. We first compute the number, and construct an inline element E, containing this number in a small font, vertically aligned as a superscript. We construct an element B, a <fo:footnote-body> containing this B followed by the content of the note. The result is then <fo:footnote> element, containing E and B.
190 <xsl:template match="note"> 191 <xsl:variable name="FootID"> 192 <xsl:call-template name="calculateFootnoteNumber"/> 193 </xsl:variable> 194 <fo:footnote> 195 <fo:inline font-size="{$footnotenumSize}" vertical-align="super"> 196 <xsl:value-of select="$FootID"/> 197 </fo:inline> 198 <fo:footnote-body> 199 <fo:block end-indent="0pt" start-indent="0pt" 200 text-indent="{$parIndent}" font-size="{$footnoteSize}"> 201 <fo:inline font-size="{$footnotenumSize}" vertical-align="super"> 202 <xsl:value-of select="$FootID"/> 203 </fo:inline> 204 <xsl:apply-templates/> 205 </fo:block> 206 </fo:footnote-body> 207 </fo:footnote> 208 </xsl:template>
This is the end of the file.
209 </xsl:stylesheet>
In the new DTD, there is no <hi> element anymore. Instead, element <b> selects a bold font weight, element <i> selects an italic font style, element <tt> selects type writer font family, elements <sup> and <sub> select some vertical alignment, elements <small> and <big> select a font size, while <span> selects a small caps font variant.
210 <xsl:template match="b"> 211 <fo:inline font-weight="bold"> <xsl:apply-templates /> </fo:inline> 212 </xsl:template> 213 214 <xsl:template match="i"> 215 <fo:inline font-style="italic"> <xsl:apply-templates /> </fo:inline> 216 </xsl:template> 217 218 <xsl:template match="tt"> 219 <fo:inline font-family='Computer-Modern-Typewriter'> 220 <xsl:apply-templates /> </fo:inline> 221 </xsl:template> 222 223 <xsl:template match="sup"> 224 <fo:inline vertical-align="super"> <xsl:apply-templates /> </fo:inline> 225 </xsl:template> 226 227 <xsl:template match="sub"> 228 <fo:inline vertical-align="sub"> <xsl:apply-templates /> </fo:inline> 229 </xsl:template> 230 231 <xsl:template match="small"> 232 <fo:inline font-size="8pt"> <xsl:apply-templates /> </fo:inline> 233 </xsl:template> 234 235 <xsl:template match="span"> 236 <fo:inline font-variant='small-caps'> <xsl:apply-templates /> </fo:inline> 237 </xsl:template> 238 239 <xsl:template match="big"> 240 <fo:inline font-size="12pt"> <xsl:apply-templates /> </fo:inline> 241 </xsl:template>
Finally, the style of a <em> is interpreted by this trivial procedure. It adds an attribute pair to the current element. The default behavior is bold font weight.
242 <xsl:template name="style"> 243 <xsl:param name="defaultvalue"/> 244 <xsl:param name="defaultstyle"/> 245 <xsl:choose> 246 <xsl:when test="@style='UNDERLINE'"> 247 <xsl:attribute name="text-decoration">underline</xsl:attribute> 248 </xsl:when> 249 <xsl:when test="@style='overline'"> 250 <xsl:attribute name="text-decoration">overline</xsl:attribute> 251 </xsl:when> 252 <xsl:when test="@style='sansserif'"> 253 <xsl:attribute name="font-family">sansserif</xsl:attribute> 254 </xsl:when> 255 <xsl:when test="@style='slanted'"> 256 <xsl:attribute name="font-style">oblique</xsl:attribute> 257 </xsl:when> 258 <xsl:when test="@style='HIGHLIGHT'"> 259 <xsl:attribute name="font-style">cursive</xsl:attribute> 260 </xsl:when> 261 <xsl:otherwise> 262 <xsl:attribute name="{$defaultstyle}"> 263 <xsl:value-of select="$defaultvalue"/> 264 </xsl:attribute> 265 </xsl:otherwise> 266 </xsl:choose> 267 </xsl:template>
This is the main file, its name is raweb3fo.xsl. It starts like this.
268 <xsl:stylesheet 269 xmlns:fotex="http://www.tug.org/fotex" 270 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 271 xmlns:m="http://www.w3.org/1998/Math/MathML" 272 xmlns:fo="http://www.w3.org/1999/XSL/Format">
We overwrite some parameters defined in the TEI file.
273 <xsl:param name="linkColor">red</xsl:param> 274 <xsl:param name="pageMarginRight">80pt</xsl:param> 275 <xsl:param name="pdfBookmarks"></xsl:param>
We include these two files. The content of the first one will be shown at the end of the chapter (section 7.17), the other was the purpose of the preceding section.
276 <xsl:include href="raweb3-param.xsl"/> 277 <xsl:include href="rrrafo3.xsl"/>
There are some elements for which white space is ignored.
278 <xsl:strip-space elements="cell bediteur bauteurs citation UR"/> 279 <xsl:output indent="no"/>
We do not use table specifications. Thus this code is a simplification of the original.
280 <xsl:variable name="top" select="/"/> 281 <xsl:variable name="tableSpecs"> 282 <Info></Info> 283 </xsl:variable>
In the case of unknown elements, we put the name in a comment, and we handle the content.
284 <xsl:template match="*"> 285 <xsl:comment><xsl:text>PASS THROUGH </xsl:text> 286 <xsl:value-of select="name()"/> 287 </xsl:comment> 288 <xsl:apply-templates/> 289 </xsl:template>
The first object in the XSL/Format file is the definition of the page layout. In our case, half of the definitions given here are not used, but are taken from the TEI code. Maybe one day somebody wants an index in two columns, in this case, page masters with index 2 can be used. Before 2006, there is no index mechanism offered by Tralics, and the \index command is forbidden in the Raweb.
The <fo:layout-master-set> element contains first some <fo:simple-page-master> elements. All these use the value of $pageMarginTop for the top margin, $pageMarginBottom for the bottom margin, $pageMarginLeft for the left margin, $pageMarginRight for the right margin, $pageWidth for the width of the page, and $pageHeight for the height of the page (values omitted but for the first occurrence). In any case, we define three regions, <fo:region-body>, <fo:region-before>, and <fo:region-after>. These last two regions have always the same extent, stored in variables $regionBeforeExtent and $regionAfterExtent.
We start with simple1: no headings, one column, all pages have the same look. The regions before and after have no name.
290 <xsl:template name="setupPagemasters"> 291 <fo:layout-master-set> 292 <fo:simple-page-master master-name="simple1" 293 page-width="{$pageWidth}" 294 page-height="{$pageHeight}" 295 margin-top="{$pageMarginTop}" 296 margin-bottom="{$pageMarginBottom}" 297 margin-left="{$pageMarginLeft}" 298 margin-right="{$pageMarginRight}"> 299 <fo:region-body 300 margin-bottom="{$bodyMarginBottom}" 301 margin-top="{$bodyMarginTop}"/> 302 <fo:region-before extent="{$regionBeforeExtent}"/> 303 <fo:region-after extent="{$regionAfterExtent}"/> 304 </fo:simple-page-master>
This is for left-hand/even pages in twosided mode, single column.
305 <fo:simple-page-master master-name="left1" > 306 <!-- Attributes as above --> 307 <fo:region-body 308 margin-bottom="{$bodyMarginBottom}" 309 margin-top="{$bodyMarginTop}"/> 310 <fo:region-before 311 region-name="xsl-region-before-left" 312 extent="{$regionBeforeExtent}"/> 313 <fo:region-after 314 region-name="xsl-region-after-left" 315 extent="{$regionAfterExtent}"/> 316 </fo:simple-page-master>
Case of right-hand/odd pages in twosided mode, single column.
317 <fo:simple-page-master master-name="right1" > 318 <!-- Attributes as above --> 319 <fo:region-body 320 margin-bottom="{$bodyMarginBottom}" 321 margin-top="{$bodyMarginTop}"/> 322 <fo:region-before 323 region-name="xsl-region-before-right" 324 extent="{$regionBeforeExtent}"/> 325 <fo:region-after 326 region-name="xsl-region-after-right" 327 extent="{$regionAfterExtent}"/> 328 </fo:simple-page-master>
Special case of first page in either mode, single column.
329 <fo:simple-page-master master-name="first1"> 330 <!-- Attributes as above --> 331 <fo:region-body 332 margin-bottom="{$bodyMarginBottom}" 333 margin-top="{$bodyMarginTop}"/> 334 <fo:region-before 335 region-name="xsl-region-before-first" 336 extent="{$regionBeforeExtent}"/> 337 <fo:region-after 338 region-name="xsl-region-after-first" 339 extent="{$regionAfterExtent}"/> 340 </fo:simple-page-master>
Case of a blank page. No headings here.
341 <fo:simple-page-master master-name="blank1"> 342 <!-- Attributes as above --> 343 <fo:region-body 344 margin-bottom="{$bodyMarginBottom}" 345 margin-top="{$bodyMarginTop}"/> 346 <fo:region-before 347 region-name="DummyRegion" 348 extent="{$regionBeforeExtent}"/> 349 <fo:region-after 350 region-name="DummyRegion" 351 extent="{$regionAfterExtent}"/> 352 </fo:simple-page-master>
For pages in one-side mode, 2 columns per page. We use the value of $columnCount for the number of columns.
353 <fo:simple-page-master master-name="simple2"> 354 <!-- Attributes as above --> 355 <fo:region-body 356 column-count="{$columnCount}" 357 margin-bottom="{$bodyMarginBottom}" 358 margin-top="{$bodyMarginTop}"/> 359 <fo:region-before extent="{$regionBeforeExtent}"/> 360 <fo:region-after extent="{$regionAfterExtent}"/> 361 </fo:simple-page-master>
For left-hand/even pages in twosided mode, 2 columns per page.
362 <fo:simple-page-master master-name="left2"> 363 <!-- Attributes as above --> 364 <fo:region-body 365 column-count="{$columnCount}" 366 margin-bottom="{$bodyMarginBottom}" 367 margin-top="{$bodyMarginTop}"/> 368 <fo:region-before 369 region-name="xsl-region-before-left" 370 extent="{$regionBeforeExtent}"/> 371 <fo:region-after 372 region-name="xsl-region-after-left" 373 extent="{$regionAfterExtent}"/> 374 </fo:simple-page-master>
For right-hand/odd pages in twosided mode, 2 columns per page.
375 <fo:simple-page-master master-name="right2"> 376 <!-- Attributes as above --> 377 <fo:region-body 378 column-count="{$columnCount}" 379 margin-bottom="{$bodyMarginBottom}" 380 margin-top="{$bodyMarginTop}"/> 381 <fo:region-before 382 region-name="xsl-region-before-right" 383 extent="{$regionBeforeExtent}"/> 384 <fo:region-after 385 region-name="xsl-region-after-right" 386 extent="{$regionAfterExtent}"/> 387 </fo:simple-page-master>
Special case of first page in either mode, two columns per page.
388 <fo:simple-page-master master-name="first2"> 389 <!-- Attributes as above --> 390 <fo:region-body 391 column-count="{$columnCount}" 392 margin-bottom="{$bodyMarginBottom}" 393 margin-top="{$bodyMarginTop}"/> 394 <fo:region-before 395 region-name="xsl-region-before-first" 396 extent="{$regionBeforeExtent}"/> 397 <fo:region-after 398 region-name="xsl-region-after-first" 399 extent="{$regionAfterExtent}"/> 400 </fo:simple-page-master>
We define now some <fo:page-sequence-master> elements. They contain a <fo:repeatable-page-master-alternatives> element. These contain some <fo:conditional-page-master-reference>. We start with setup for double-sided, 1 column, no first page.
401 <fo:page-sequence-master master-name="twoside1nofirst"> 402 <fo:repeatable-page-master-alternatives> 403 <fo:conditional-page-master-reference 404 master-reference="right1" 405 odd-or-even="odd"/> 406 <fo:conditional-page-master-reference 407 master-reference="left1" 408 odd-or-even="even"/> 409 </fo:repeatable-page-master-alternatives> 410 </fo:page-sequence-master>
Setup for double-sided, 1 column. Note that this is the only one that defines a page master for blank pages.
411 <fo:page-sequence-master master-name="twoside1"> 412 <fo:repeatable-page-master-alternatives> 413 <fo:conditional-page-master-reference 414 master-reference="first1" 415 page-position="first"/> 416 <fo:conditional-page-master-reference 417 master-reference="right1" 418 odd-or-even="odd"/> 419 <fo:conditional-page-master-reference 420 master-reference="left1" 421 odd-or-even="even"/> 422 <fo:conditional-page-master-reference 423 master-reference="blank1" 424 blank-or-not-blank="blank"/> 425 </fo:repeatable-page-master-alternatives> 426 </fo:page-sequence-master>
Setup for single-sided, 1 column.
427 <fo:page-sequence-master master-name="oneside1"> 428 <fo:repeatable-page-master-alternatives> 429 <fo:conditional-page-master-reference 430 master-reference="first1" 431 page-position="first"/> 432 <fo:conditional-page-master-reference master-reference="simple1"/> 433 </fo:repeatable-page-master-alternatives> 434 </fo:page-sequence-master>
Setup for double-sided, 2 columns.
435 <fo:page-sequence-master master-name="twoside2"> 436 <fo:repeatable-page-master-alternatives> 437 <fo:conditional-page-master-reference 438 master-reference="first2" 439 page-position="first"/> 440 <fo:conditional-page-master-reference 441 master-reference="right2" 442 odd-or-even="odd"/> 443 <fo:conditional-page-master-reference 444 master-reference="left2" 445 odd-or-even="even"/> 446 </fo:repeatable-page-master-alternatives> 447 </fo:page-sequence-master>
Setup for single-sided, 2 columns.
448 <fo:page-sequence-master master-name="oneside2"> 449 <fo:repeatable-page-master-alternatives> 450 <fo:conditional-page-master-reference 451 master-reference="first2" 452 page-position="first"/> 453 <fo:conditional-page-master-reference master-reference="simple2" /> 454 </fo:repeatable-page-master-alternatives> 455 </fo:page-sequence-master> 456 <xsl:call-template name="hookDefinepagemasters"/>
That was a long template! The XSLT processor replaces all the space characters and newline characters by a single space. The resulting element is printed on a single line; it has over 5000 characters. This is much larger than the 500 that appear in the TeX source; in fact, in the case of the apics Team, TeX used 15174 input buffer positions.
457 </fo:layout-master-set> 458 </xsl:template>
We define here two <fo:static-content> elements, for left and right pages. They contain a <fo:block> and a second block (is this really needed?) The inner block says text-indent = `0pt´, because headings should not be indented. We set border-after-style to solid. In the original version, this did not work, and there was a <pagestylehrule> instead. On one end we have page numbers, on the other we have the name of the team or INRIA.
459 <xsl:template name="myheaders"> 460 <fo:static-content flow-name="xsl-region-before-right"> 461 <fo:block text-align="justify" font-size="{$bodySize}"> 462 <fo:block border-after-style="solid" text-indent="0pt"> 463 <fo:inline font-style="italic"><xsl:value-of select="$PRID"/></fo:inline> 464 <fo:leader rule-thickness="0pt"/> 465 <fo:inline> <fo:page-number/> </fo:inline> 466 </fo:block> 467 </fo:block> 468 </fo:static-content> 469 470 <fo:static-content flow-name="xsl-region-before-left"> 471 <fo:block text-align="justify" font-size="{$bodySize}"> 472 <fo:block border-after-style="solid" text-indent="0pt"> 473 <fo:inline> <fo:page-number/> </fo:inline> 474 <fo:leader rule-thickness="0pt"/> 475 <fo:inline font-style="italic"> 476 Activity Report INRIA <xsl:value-of select="$year"/> 477 </fo:inline> 478 </fo:block> 479 </fo:block> 480 </fo:static-content>
We use empty footers, and the first page has no header.
481 <fo:static-content flow-name="xsl-region-before-first"/> 482 <fo:static-content flow-name="xsl-region-after-right"/> 483 <fo:static-content flow-name="xsl-region-after-left"/> 484 <fo:static-content flow-name="xsl-region-after-first"/> 485 </xsl:template>
The main text is in a page sequence, defined like this. Note that the original file had master-name = `twoside1nofirst´. This is useless, but raises the following question: should the first page of text (in general, the fifth page) have a page header, or should it be considered as a first page. The flow-name attribute is useless (used only for static content).
486 <xsl:template name="maintext"> 487 <fo:page-sequence 488 format="1" 489 text-align="justify" 490 hyphenate="true" 491 language="english" 492 initial-page-number="1" 493 master-reference="twoside1" 494 > 495 <fo:flow 496 flow-name="xsl-region-body" 497 font-family="{$bodyFont}" 498 font-size="{$bodySize}"> 499 <xsl:call-template name="raweb.body"/> 500 </fo:flow> 501 </fo:page-sequence> 502 </xsl:template>
The title page is another page sequence, defined like this. The content will be given later; in the new DTD, this is called <identification>.
503 <xsl:template match="accueil"> 504 <fo:page-sequence 505 format="1" 506 text-align="justify" 507 hyphenate="true" 508 language="english" 509 initial-page-number="1" 510 master-reference="twoside1" 511 force-page-count="end-on-even" 512 > 513 <fo:flow font-style="italic" font-family="{$bodyFont}"> 514 <xsl:call-template name="accueil.body"/> 515 </fo:flow> 516 </fo:page-sequence> 517 </xsl:template>
518 <xsl:template name="myTOC"> 519 <fo:page-sequence 520 format="1" 521 text-align="justify" 522 hyphenate="true" 523 language="english" 524 initial-page-number="1" 525 master-reference="twoside1" 526 force-page-count="end-on-even" 527 > 528 <fo:flow flow-name="xsl-region-body"> 529 <fo:block> 530 <xsl:call-template name="toc.body"/> 531 </fo:block> 532 </fo:flow> 533 </fo:page-sequence> 534 </xsl:template>
The document element is <raweb>. The first thing to do is construct the <fo:layout-master-set>, then all <fo:static-content>. After that, we have three parts: the title page, the table of contents, and the main text. Each of these parts start on a right page (an odd one, but the first page in each section is numbered one). Using <cleardoublepage> is a big hack.(note: ➳)
535 <xsl:template match="raweb"> 536 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 537 <xsl:call-template name="setupPagemasters"/> 538 <xsl:call-template name="myheaders"/> 539 <xsl:apply-templates select="accueil"/> 540 <xsl:call-template name="myTOC"/> 541 <xsl:call-template name="maintext"/> 542 </fo:root> 543 </xsl:template>
The maintext template selects a page sequence and a flow (see above), then calls this template. The idea is trivial: we consider one section after the other.
544 <xsl:template name="raweb.body"> 545 <xsl:apply-templates select="composition"/> 546 <xsl:apply-templates select="presentation"/> 547 <xsl:apply-templates select="fondements"/> 548 <xsl:apply-templates select="domaine"/> 549 <xsl:apply-templates select="logiciels"/> 550 <xsl:apply-templates select="resultats"/> 551 <xsl:apply-templates select="contrats"/> 552 <xsl:apply-templates select="international"/> 553 <xsl:apply-templates select="diffusion"/> 554 <xsl:apply-templates select="biblio"/> 555 </xsl:template>
This computes the start of a section. The result is a <fo:block>, containing the number and title of the section; these are found in attributes. This can call two templates that can parameterize the code. Note: there is a problem with the bookmarks. For this reason, we do not show the code.
556 <xsl:template name="secNumberedHeading"> 557 <fo:block keep-with-next.within-page="always"> 558 <xsl:variable name="divid"> 559 xsl:call-template name="idLabel"/> 560 </xsl:variable> 561 <xsl:attribute name="id"> <xsl:value-of select="$divid"/> </xsl:attribute> 562 <xsl:attribute name="text-align">start</xsl:attribute> 563 <xsl:attribute name="font-family"> 564 <xsl:value-of select="$divFont"/> 565 </xsl:attribute> 566 <xsl:call-template name="setupDiv0"/> 567 <xsl:call-template name="blockStartHook"/> 568 <xsl:value-of select="@numero"/> 569 <xsl:text>. </xsl:text> 570 <xsl:value-of select="@titre"/> 571 <xsl:if test="$pdfBookmarks='true'"> 572 <fotex:bookmark ... /> 573 </xsl:if> 574 </fo:block> 575 </xsl:template>
The code changed a bit in the case of the new DTD. This is because the title of the section is now in <bodyTitle>, unless the section is <identification>, <team>, <biblio>, case where `Identification´, `Team´ or `Bibliography´ is used. Moreover, the numero attribute is not used. Instead, the effective section number is used instead, via calculateNumberSection. These lines are a replacement for lines 568 to 571.
576 <xsl:call-template name="calculateNumberSection"/> 577 <xsl:if test="parent::raweb"> 578 <xsl:text> </xsl:text> 579 </xsl:if> 580 <xsl:choose> 581 <xsl:when test="name()='identification'">Identification</xsl:when> 582 <xsl:when test="name()='team'"><xsl:text> </xsl:text> Team</xsl:when> 583 <xsl:when test="name()='biblio'">Bibliography</xsl:when> 584 <xsl:otherwise> 585 <xsl:value-of select="bodyTitle"/> 586 </xsl:otherwise> 587 </xsl:choose>
This returns an id. Question? do we really need to replace underscores by hyphens?
588 <xsl:template name="idLabel"> 589 <xsl:choose> 590 <xsl:when test="@id"><xsl:value-of select="translate(@id,'_','-')"/> </xsl:when> 591 <xsl:otherwise><xsl:value-of select="generate-id()"/></xsl:otherwise> 592 </xsl:choose> 593 </xsl:template>
This is for a subsection. The title is in <head> (and <bodyTitle> in the new DTD). The number has to be computed.
594 <xsl:template name="NumberedHeading"> 595 <xsl:param name="level"/> 596 <fo:block keep-with-next.within-page="always"> 597 <xsl:variable name="divid"> 598 <xsl:call-template name="idLabel"/> 599 </xsl:variable> 600 <xsl:attribute name="id"> 601 <xsl:value-of select="$divid"/> 602 </xsl:attribute> 603 <xsl:attribute name="text-align">start</xsl:attribute> 604 <xsl:attribute name="font-family"> 605 <xsl:value-of select="$divFont"/> 606 </xsl:attribute> 607 <xsl:choose> 608 <xsl:when test="$level=0"><xsl:call-template name="setupDiv0"/></xsl:when> 609 <xsl:when test="$level=1"><xsl:call-template name="setupDiv1"/></xsl:when> 610 <xsl:when test="$level=2"><xsl:call-template name="setupDiv2"/></xsl:when> 611 <xsl:when test="$level=3"><xsl:call-template name="setupDiv3"/></xsl:when> 612 <xsl:when test="$level=4"><xsl:call-template name="setupDiv4"/></xsl:when> 613 </xsl:choose> 614 <xsl:call-template name="blockStartHook"/> 615 <xsl:variable name="Number"> 616 <xsl:if test="$numberHeadings and $numberDepth > $level"> 617 <xsl:call-template name="calculateNumber"> 618 <xsl:with-param name="numbersuffix" select="$headingNumberSuffix"/> 619 </xsl:call-template> 620 </xsl:if> 621 </xsl:variable> 622 <xsl:value-of select="$Number"/> 623 <xsl:apply-templates mode="section" select="head"/> 624 <xsl:if test="$pdfBookmarks='true'"> <fotex:toto/> 625 <fotex:bookmark ... /> 626 </xsl:if> 627 </fo:block> 628 </xsl:template>
The translation of the <composition> section is trivial. We add the toplevel moreinfo before the text.
629 <xsl:template match="composition"> 630 <xsl:call-template name="secNumberedHeading"/> 631 <xsl:apply-templates select="/raweb/moreinfo"/> 632 <xsl:apply-templates/> 633 </xsl:template>
In the new DTD, the previous piece of code is to be replaced by this one. Note that the toplevel moreinfo is a child of <identification>, and the (optional) moreinfo that is a child of <team> is lost.
634 <xsl:template match="team"> 635 <xsl:call-template name="secNumberedHeading"/> 636 <xsl:if test="../moreinfo"><xsl:apply-templates select="../moreinfo"/></xsl:if> 637 <xsl:apply-templates select="participants"/> 638 </xsl:template>
Other sections. We emit a title, then the content of the element. In the new DTD, the final apply-templates selects all nodes but <bodyTitle>.
639 <xsl:template 640 match="presentation|fondements|domaine|logiciels|resultats|contrats 641 |international|diffusion"> 642 <xsl:call-template name="secNumberedHeading"/> 643 <xsl:apply-templates/> 644 </xsl:template>
Modules. This is a subsection. The title is in <head>. In the case of dummy titles, nothing is printed.
645 <xsl:template match="module"> 646 <xsl:if test="./head!='(Sans Titre)'"> 647 <xsl:call-template name="NumberedHeading"> 648 <xsl:with-param name="level" select="'1'"/> 649 </xsl:call-template> 650 </xsl:if> 651 <xsl:apply-templates/> 652 </xsl:template>
A section is equivalent to <div0>, a module to <div1>. We consider here divisions of level 2, 3 and 4.
653 <xsl:template match="div2|div3|div4"> 654 <xsl:call-template name="NumberedHeading"> 655 <xsl:with-param name="level"> 656 <xsl:value-of select="substring-after(name(),'div')"/> 657 </xsl:with-param> 658 </xsl:call-template> 659 <xsl:apply-templates/> 660 </xsl:template>
In the case of the new DTD, the two previous templates are replaced by a single one (for the element <subsection>). Of course, the $level has to be computed differently: it is the number of ancestors (or self) of type <subsection>. In the case of a section and subsection, the apply-templates is applied to all nodes whose name is not <bodyTitle>. Finally, in the case of a <module>, keywords are inserted via keywords-list, and for other divisions, they are inserted via keywords-list2.
The table of contents is formed of a a title, followed by all sections and subsections, translated in a special mode.
661 <xsl:template name="toc.body"> 662 <fo:block font-size="14pt" text-align="center" font-weight="bold" 663 space-after="20pt"> 664 <xsl:text>Table of contents</xsl:text> 665 </fo:block> 666 <xsl:for-each select="//composition|//presentation|//fondements| 667 //domaine|//logiciels|//resultats|//contrats|//international| 668 //diffusion|//biblio|//module|//div2|//div3"> 669 <xsl:apply-templates mode="xtoc" select="(.)"/> 670 </xsl:for-each> 671 </xsl:template>
Translation of a section in the TOC. The result is a bold line, containing the section number (computed), its title (from the attribute in the old DTD, computed in the new one), the page number, and a link to it.
672 <xsl:template mode="xtoc" match="composition|presentation| 673 fondements|domaine|logiciels|resultats|contrats|international| 674 diffusion|biblio"> 675 <xsl:variable name="tocindent"> 676 <xsl:value-of select="$div0Tocindent"/> 677 </xsl:variable> 678 <fo:block> 679 <xsl:attribute name="font-weight">bold</xsl:attribute> 680 <xsl:attribute name="text-indent"> 681 <xsl:value-of select="$tocindent"/> 682 </xsl:attribute> 683 <xsl:call-template name="sec.num"/> 684 <xsl:text> </xsl:text> 685 <fo:inline> 686 <xsl:value-of select="@titre"/> 687 </fo:inline> 688 <fo:leader leader-pattern="dots" /> 689 <fo:inline color="{$linkColor}"> 690 <xsl:variable name="pagref"> 691 <xsl:call-template name="idLabel"/> 692 </xsl:variable> 693 <fo:basic-link internal-destination="{$pagref}"> 694 <fo:page-number-citation ref-id="{$pagref}"/> 695 </fo:basic-link> 696 </fo:inline> 697 </fo:block> 698 </xsl:template>
A module in the TOC. If the title (from the <head> element) is empty, we do nothing, otherwise call some template that adds a line to the TOC. The parameter of the template is 1 (a module is equivalent to a <div1>).
699 <xsl:template mode="xtoc" match="module"> 700 <xsl:if test="head!='(Sans Titre)'"> 701 <xsl:call-template name="tocheading"> 702 <xsl:with-param name="level"> 703 <xsl:value-of select="1"/></xsl:with-param> 704 </xsl:call-template> 705 </xsl:if> 706 </xsl:template>
A division (<div2>, <div3>, or <div4>) in the TOC. Same as for a module, but the parameter of the template, the number, has to be computed. Moreover, an entry is inserted in the TOC even when the title is empty. For the new DTD, this template and the preceding one were replaced by a single template for <subsection>, the value of level parameter being the number of ancestors (or self) named <subsection>.
707 <xsl:template mode="xtoc" match="div2|div3|div4"> 708 <xsl:call-template name="tocheading"> 709 <xsl:with-param name="level"> 710 <xsl:value-of select="substring-after(name(),'div')"/></xsl:with-param> 711 </xsl:call-template> 712 </xsl:template>
A division gives an entry in the TOC as follows. The result is a <fo:block>, with some indentation that depends on the level, plus a number, and a title (unless empty), leaders, then the page number, and a link.
713 <xsl:template name="tocheading"> 714 <xsl:param name="level"/> 715 <xsl:variable name="tocindent"> 716 <xsl:choose> 717 <xsl:when test="$level='0'"> 718 <xsl:value-of select="$div0Tocindent"/></xsl:when> 719 <xsl:when test="$level='1'"> 720 <xsl:value-of select="$div1Tocindent"/></xsl:when> 721 <xsl:when test="$level='2'"> 722 <xsl:value-of select="$div2Tocindent"/></xsl:when> 723 <xsl:when test="$level='3'"> 724 <xsl:value-of select="$div3Tocindent"/></xsl:when> 725 <xsl:when test="$level='4'"> 726 <xsl:value-of select="$div4Tocindent"/></xsl:when> 727 <xsl:otherwise><xsl:value-of select="$div1Tocindent"/></xsl:otherwise> 728 </xsl:choose> 729 </xsl:variable> 730 <fo:block> 731 <xsl:attribute name="text-indent"> 732 <xsl:value-of select="$tocindent"/> 733 </xsl:attribute> 734 <xsl:variable name="Number"> 735 <xsl:if test="$numberHeadings and $numberDepth > $level"> 736 <xsl:call-template name="calculateNumber"> 737 <xsl:with-param name="numbersuffix" select="$tocNumberSuffix"/> 738 </xsl:call-template> 739 </xsl:if> 740 </xsl:variable> 741 <xsl:value-of select="$Number"/> 742 <xsl:text> </xsl:text> 743 <xsl:if test="head!='(Sans Titre)'"> 744 <fo:inline> 745 <xsl:apply-templates mode="tocsection" select="head"/> 746 </fo:inline> 747 </xsl:if> 748 <fo:leader rule-thickness="0pt"/> 749 <fo:inline color="{$linkColor}"> 750 <xsl:variable name="pagref"> 751 <xsl:call-template name="idLabel"/> 752 </xsl:variable> 753 <fo:basic-link internal-destination="{$pagref}"> 754 <fo:page-number-citation ref-id="{$pagref}"/> 755 </fo:basic-link> 756 </fo:inline> 757 </fo:block> 758 </xsl:template>
A <head> in the TOC: the ID disappears (as well as all other attributes). Moreover, the content is evaluated in `section´ mode. All elements disappear (only text remains), unless specified otherwise.
759 <xsl:template match="head" mode="tocsection"> 760 <xsl:apply-templates mode="section"/> 761 </xsl:template>
We interpret math elements in a title as usual (the title could be “Encoding π in πpa”, guess what happens without the math?)
762 <xsl:template match="m:math" mode="section"> 763 <m:math> 764 <xsl:copy-of select="@*"/> 765 <xsl:apply-templates mode="math"/> 766 </m:math> 767 </xsl:template>
A <head> in a section: the ID is in the result (why do we replace underscores by dashes?).
768 <xsl:template match="head" mode="section"> 769 <fo:inline> 770 <xsl:if test=".!='(Sans Titre)'"> 771 <xsl:if test="@id"> 772 <xsl:attribute name="id"> 773 <xsl:value-of select="translate(@id,'_','-')"/> 774 </xsl:attribute> 775 </xsl:if> 776 <xsl:apply-templates mode="section"/> 777 </xsl:if> 778 </fo:inline> 779 </xsl:template>
In the new DTD, lines 744–746 were replaced by the following, and the previous template was renamed bodyTitle. There is one problem: if the title has an ID, it will be inserted in the main text, and in the TOC, this is completely wrong (we are lucky, because a section has an ID, and the title of the section has none).
780 <fo:inline space-start="20pt"> 781 <xsl:apply-templates mode="section" select="bodyTitle"/> 782 </fo:inline>
Translation of the bibliography. There are eight optional parts. We consider them one after the other.
783 <xsl:template match="biblio"> 784 <xsl:call-template name="secNumberedHeading"/> 785 <xsl:call-template name="biblioA"/> 786 <xsl:call-template name='biblioBA'/> 787 <xsl:call-template name='biblioBC'/> 788 <xsl:call-template name='biblioBD'/> 789 <xsl:call-template name='biblioBE'/> 790 <xsl:call-template name='biblioBH'/> 791 <xsl:call-template name='biblioBJ'/> 792 <xsl:call-template name="biblioC"/> 793 </xsl:template>
This outputs the title of a subsection, for the bibliography. This title is in the $name parameter, the default value is never used.
794 <xsl:template name="biblioname"> 795 <xsl:param name="name">Unknown bibliography section</xsl:param> 796 <fo:block font-weight='bold' font-size="14pt" space-before="5pt" 797 keep-with-next='always'> 798 <xsl:value-of select="$name"/> 799 </fo:block> 800 </xsl:template>
Bibliography, part one. We select all entries that have a from attribute whose value is `refer´. The title of the section is “Major publications by the team in recent years”. If no entry matches, the translation is empty.
801 <xsl:template name="biblioA"> 802 <xsl:if test="citation[@from ='refer']"> 803 <xsl:call-template name="biblioname"> 804 <xsl:with-param name="name"> ... </xsl:with-param> 805 </xsl:call-template> 806 <xsl:for-each select="citation[@from ='refer']"> 807 <xsl:apply-templates select="(.)"/> 808 </xsl:for-each> 809 </xsl:if> 810 </xsl:template>
Bibliography, last part. We select all entries that have a from attribute whose value is `foot´. The title of the section is “Bibliography in notes”.
811 <xsl:template name="biblioC"> 812 <xsl:if test="citation[@from ='foot']"> 813 ... 814 </xsl:if> 815 </xsl:template>
We select all entries that have a from attribute whose value is `year´ and type is book or booklet or proceedings. The title of the section is “Books and Monographs”.
816 <xsl:template name='biblioBA'> 817 <xsl:if test="..."> ... </xsl:if> 818 </xsl:template>
We select all entries that have a from attribute whose value is `year´ and type is phdthesis. The title of the section is “Doctoral dissertations and “Habilitation” theses”.
819 <xsl:template name='biblioBC'> 820 <xsl:if test="..."> ... </xsl:if> 821 </xsl:template>
We select all entries that have a from attribute whose value is `year´ and type is article or inbook or incollection. The title of the section is “Articles in referred journals and book chapters”.
822 <xsl:template name='biblioBD'> 823 <xsl:if test="..."> ... </xsl:if> 824 </xsl:template>
We select all entries that have a from attribute whose value is `year´ and type is inproceedings or conference. The title of the section is “Publications in Conferences and Workshops”.
825 <xsl:template name='biblioBE'> 826 <xsl:if test="..."> ... </xsl:if> 827 </xsl:template>
We select all entries that have a from attribute whose value is `year´ and type is manual or techreport or coursenotes. The title of the section is “Internal Reports”.
828 <xsl:template name='biblioBH'> 829 <xsl:if test="..."> ... </xsl:if> 830 </xsl:template>
We select all entries that have a from attribute whose value is `year´ and type is unpublished or misc or masterthesis or mastersthesis. The title of the section is “Miscellaneous”.
831 <xsl:template name='biblioBJ'> 832 <xsl:if test="..."> ... </xsl:if> 833 </xsl:template>
A <citation> produces a <fo:block>, with the same id. It contains the value of the key, in brackets, then the content of the element.
834 <xsl:template match="citation"> 835 <fo:block space-before="15pt" text-indent="-2em"> 836 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 837 [<xsl:value-of select="@key"/>] 838 <xsl:apply-templates/> 839 </fo:block> 840 </xsl:template>
This produces a comma between elements, a period at the end. A similar template rule that produces a comma, but no period, named separateurED.objet also exists.
841 <xsl:template name="separateur.objet"> 842 <xsl:choose> 843 <xsl:when test="position()!=last()">, </xsl:when> 844 <xsl:when test="position()=last()">.</xsl:when> 845 </xsl:choose> 846 </xsl:template>
This is old code, not used anymore.
847 <xsl:template name="separateur.objet.spec"> ? </xsl:template>
The translation of <bvolume>foo</bvolume> is `Bar foo´, where `Bar´ is the name attribute of the element (it could be `volume´ or `vol.´; it is defined by the DTD).
848 <xsl:template match='bvolume|bnumber|bpages|bchapter|bseries|bedition'> 849 <xsl:value-of select="@bname"/> 850 <xsl:text> </xsl:text><xsl:apply-templates/> 851 <xsl:call-template name="separateur.objet"/> 852 </xsl:template>
The translation of <btitle> is the title in italics.
853 <xsl:template match='btitle'> 854 <fo:inline font-style='italic'><xsl:apply-templates/>. </fo:inline> 855 </xsl:template>
The translation of <bjournal>foo</bjournal> is “in « foo »”, or something like that.
856 <xsl:template match='bjournal|bbooktitle'> 857 <xsl:text>in « </xsl:text><xsl:apply-templates/> 858 <xsl:text> »</xsl:text> 859 <xsl:call-template name="separateur.objet"/> 860 </xsl:template>
Translation of most bibliographic elements is trivial.
861 <xsl:template match='byear|bmonth|btype|bschool|bpublisher| 862 bnote|borganization|binstitution|baddress|bhowpublished'> 863 <xsl:apply-templates/> 864 <xsl:call-template name="separateur.objet"/> 865 </xsl:template>
Translation of a <bdoi> element. This is a link to `http://dx.doi.org/xxx´.
866 <xsl:template match='bdoi'> 867 <xsl:value-of select="@bname"/><xsl:text> </xsl:text> 868 <fo:basic-link color="{$linkColor}"> 869 <xsl:attribute 870 name="external-destination">http://dx.doi.org/<xsl:value-of select="."/> 871 </xsl:attribute> 872 <xsl:apply-templates/> 873 </fo:basic-link> 874 <xsl:call-template name="separateur.objet"/> 875 </xsl:template>
Transformation of <cit>. The result is a link to a bibliographical item.
876 <xsl:template match="cit"> 877 <fo:basic-link color="{$linkColor}"> 878 <xsl:attribute name="internal-destination"> 879 <xsl:value-of select="ref/@target"/> 880 </xsl:attribute> 881 <xsl:text>[</xsl:text> 882 <xsl:value-of select="id(ref/@target)/@key"/> 883 <xsl:text>]</xsl:text> 884 </fo:basic-link> 885 </xsl:template>
The bibliography has completely changed in the new DTD. You can get an idea of the new code by looking at the HTML version, given in the previous chapter, and replacing all HTML formatting commands, using the templates above as example. We first construct a key, named `bibliotypes´, that associates to each bibliography entry its type, a letter between d and k, then for each letter, we put in the variable (for instance $d) the number of entries of this type. Then comes the following template, it is similar to `tri-par-publis´ in section 6.4 (details omitted). The template biblioname is no more used, since titles are shown here.
886 <xsl:template match="biblio"> 887 <xsl:call-template name="secNumberedHeading"/> 888 <xsl:call-template name="tri"/> d 889 <fo:block font-weight='bold' font-size="14pt" space-before="5pt" 890 keep-with-next='always'>Year Publications</fo:block> 891 <xsl:call-template name="tri"/> e 892 <xsl:call-template name="tri"/> f 893 <xsl:call-template name="tri"/> g 894 <xsl:call-template name="tri"/> h 895 <xsl:call-template name="tri"/> i 896 <xsl:call-template name="tri"/> j 897 <xsl:call-template name="tri"/> k 898 </xsl:template>
The following template takes four arguments, $str, which is a letter, between d and k, $title and $title2, two titles, and $countPrevious the number of items already put in the bibliography. It outputs all entries, of type $str, in some order (the first sort is useless, of course).
899 <xsl:template name="tri"> 900 <xsl:param name="str"/> 901 <xsl:param name="title"/> 902 <xsl:param name="title2"/> 903 <xsl:param name="countPrevious"/> 904 <xsl:if test="key('bibliotypes',$str)[1]"> 905 <xsl:call-template "bib-title"/> 906 <xsl:for-each select="key('bibliotypes',$str)"> 907 <xsl:sort select="concat( 908 substring('a', 1 div (note[@type='from']/text()='refer')), 909 substring('b', 1 div (note[@type='from']/text()='year')), 910 substring('c', 1 div (note[@type='from']/text()='foot')))"/> 911 <xsl:sort select="descendant::author[1]/persName[1]/surname/text()"/> 912 <xsl:apply-templates select="."> 913 <xsl:with-param name="pos"> 914 <xsl:value-of select="$countPrevious+position()"/></xsl:with-param> 915 </xsl:apply-templates> 916 </xsl:for-each> 917 </xsl:if> 918 </xsl:template>
This outputs one of the two titles (in 14pt for the main title, 12pt for the subtitle).
919 <xsl:template name="bib-title"/> 920 <xsl:if test="string-length($title)>0"> 921 <fo:block font-weight='bold' font-size="14pt" space-before="5pt" 922 keep-with-next='always'> 923 <xsl:value-of select='$title'/> 924 </fo:block> 925 </xsl:if> 926 <xsl:if test="string-length($title2)>0"> 927 <fo:block font-weight='bold' font-size="12pt" space-before="5pt" 928 text-indent="1em" keep-with-next='always'> 929 <xsl:value-of select='$title2'/> 930 </fo:block> 931 </xsl:if> 932 </xsl:template>
This outputs the entry, in a block shifted left by two ems, starting with the number in brackets, followed by a period, with a new line as separator.
933 <xsl:template match="biblStruct"> 934 <xsl:param name="pos" /> 935 <fo:block space-before="15pt" text-indent="-2em"> 936 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 937 <xsl:text>[</xsl:text> 938 <xsl:value-of select="$pos"/> 939 <xsl:text>] </xsl:text> 940 <xsl:apply-templates/> 941 <xsl:text>.</xsl:text> 942 </fo:block> 943 <xsl:text>
</xsl:text> 944 </xsl:template>
Trivial templates, for <edition>, <note> of type `bnote´, `typedoc´, `howpublished´, <orgName>, <addrLine>, or <title> of level `s´ (corresponding to series in BibTeX). The main difference with the code shown above is that we do not call separateur.objet, but each item inserts a comma before it (except the first item, see below).
945 <xsl:template match="edition | note[@type='bnote' | note[@type='howpublished'] 946 | title[@level='s'] | note[@type='typdoc'] | orgName | addrLine"> 947 <xsl:text>, </xsl:text> 948 <xsl:apply-templates/> 949 </xsl:template>
These notes are used for sorting, hence produce no text.
950 <xsl:template match="note[@type='from']" /> 951 <xsl:template match="note[@type='userid']" /> 952 <xsl:template match="note[@type='classification']"/>
953 <xsl:template match="imprint | address"> 954 <xsl:apply-templates/> 955 </xsl:template>
The case of <edition> is a bit more complicated. As already mentioned, the LaTeX companion says that the value should be something like `Second´, and the typeset text should be `second edition´(note: ➳).
956 <xsl:template match="bedition"> 957 <xsl:text>, </xsl:text> 958 <xsl:value-of select="@type"/> 959 <xsl:text> </xsl:text> 960 <xsl:apply-templates/> 961 </xsl:template>
Other trivial rules for <title>. Level `j´ corresponds to the BibTeX field journal, while level `a´ corresponds to the title (for type inbook, article, incollection, inproceedings and conference). In one case we output something like `in “foo”´, using straight double quotes instead of guillemets as was the case of the old DTD; in the other case, we output the value, using italic font style, without an initial comma, because the title follows the author list, which is terminated by a period.
962 <xsl:template match="title[@level='j']"> 963 <xsl:text>, in "</xsl:text> 964 <xsl:apply-templates/> 965 <xsl:text>"</xsl:text> 966 </xsl:template> 967 968 <xsl:template match="title[@level='a']"> 969 <fo:inline font-style='italic'> <xsl:apply-templates/></fo:inline> 970 </xsl:template>
A BibTeX title gives a <title> of level `a´ in cases shown above, and level `m´ otherwise; as explained in the previous chapter, if <title> is below <analytic>, then the type should be `a´, hence the test is false for this title; as a consequence, if the test is true, there are two titles, and we are proceeding with the second one, handling it the same as level `j´, otherwise, it is the first, handling it as level `a´.
971 <xsl:template match="title[@level='m']"> 972 <xsl:choose> 973 <xsl:when test="string-length(../../analytic/title) > 0"> 974 <xsl:text>, in "</xsl:text> 975 <xsl:apply-templates/> 976 <xsl:text>"</xsl:text> 977 </xsl:when> 978 <xsl:otherwise> 979 <fo:inline font-style='italic'><xsl:apply-templates/></fo:inline> 980 </xsl:otherwise> 981 </xsl:choose> 982 </xsl:template>
Translation of <biblScope>. Depending on the type attribute, this gives `vol. 17´, or `chap. 25´, or `no 33´, preceded by a comma, as usual.
983 <xsl:template match="biblScope[@type='volume']"> 984 <xsl:text>, vol. </xsl:text> 985 <xsl:apply-templates/> 986 </xsl:template> 987 988 <xsl:template match="biblScope[@type='chapter']"> 989 <xsl:text>, chap. </xsl:text> 990 <xsl:apply-templates/> 991 </xsl:template> 992 993 <xsl:template match="biblScope[@type='number']"> 994 <xsl:text>, n</xsl:text> 995 <fo:inline vertical-align="super">o</fo:inline> 996 <xsl:text> </xsl:text> 997 <xsl:apply-templates/> 998 </xsl:template>
Comment from the preview chapter: In the case of `pages´ we output something like `p. 10–30´. If the text contains neither a dash nor an en-dash, we output `42 p´. As you can see, the last sentence is wrong in the Pdf case.
999 <xsl:template match="biblScope[@type='pages'][text()!='']"> 1000 <xsl:text>, </xsl:text> 1001 <xsl:if test="string-length(substring-before(., '-')) 1002 or string-length(substring-before(., '–'))>0"> 1003 <xsl:text>p. </xsl:text> 1004 </xsl:if> 1005 <xsl:apply-templates/> 1006 </xsl:template>
In the case of <dateStruct>, we output the value of <year> and <month>. Note: is a simple copy enough here?
1007 <xsl:template match="dateStruct"> 1008 <xsl:text>, </xsl:text> 1009 <xsl:value-of select="month"/> 1010 <xsl:text> </xsl:text> 1011 <xsl:value-of select="year"/> 1012 </xsl:template>
In the case of <publisher>, we output the two children, <orgName> and <address>.
1013 <xsl:template match="publisher"> 1014 <xsl:apply-templates select="orgName"/> 1015 <xsl:if test="./address"> 1016 <xsl:apply-templates select="address"/> 1017 </xsl:if> 1018 </xsl:template>
1019 <xsl:template match='bdoi'> 1020 ... 1021 </xsl:template>
Case of a reference in the bibliography. The destination of the link is the value of the url attribute, or the value of the element is the attribute is absent.
1022 <xsl:template match="biblio//ref"> 1023 <xsl:choose> 1024 <xsl:when test="./@url"> 1025 <xsl:text>, </xsl:text> 1026 <fo:basic-link color="{$linkColor}"> 1027 <xsl:attribute name="external-destination"> 1028 <xsl:value-of select="./@url"/> 1029 </xsl:attribute> 1030 <xsl:apply-templates/> 1031 </fo:basic-link> 1032 </xsl:when> 1033 <xsl:otherwise> 1034 <xsl:text>, </xsl:text> 1035 <fo:basic-link color="{$linkColor}"> 1036 <xsl:attribute name="external-destination"> 1037 <xsl:value-of select="."/> 1038 </xsl:attribute> 1039 <xsl:apply-templates/> 1040 </fo:basic-link> 1041 </xsl:otherwise> 1042 </xsl:choose> 1043 </xsl:template>
Same code as in the HTML version, see section 6.4.
1044 <xsl:template match="analytic"> 1045 ... 1046 </xsl:template> 1047 1048 <xsl:template match="monogr"> 1049 ... 1050 </xsl:template>
There are two kinds of list of people, in the text and in the bibliography, and a person is represented differently. This a bit annyoing; we could imagine the case where we have a global list at the start of the document and references to the list; it would then be easier to associate to each member of the team its publication list. We start with the bibliography.
Translation of <bauteurs>. This is a list of <bpers>, with an optional <etal> (this one seems wrongly translated; it has a nom but no prenom). For each author, we output the first name, the particle, the last name.(note: ➳)
1051 <xsl:template match ="bauteurs"> 1052 <fo:inline font-variant='small-caps'> 1053 <xsl:for-each select="bpers|etal"> 1054 <xsl:value-of select="@prenom"/> 1055 <xsl:text> </xsl:text> 1056 <xsl:if test="@part"> 1057 <xsl:value-of select="@part"/> 1058 <xsl:text> </xsl:text> 1059 </xsl:if> 1060 <xsl:value-of select="@nom"/> 1061 <xsl:call-template name="separateur.objet"/> 1062 </xsl:for-each> 1063 </fo:inline> 1064 <xsl:text> </xsl:text> 1065 </xsl:template>
Same idea. A comma is put after each editor. After that, `editor´ or `editors´ is added at the end.
1066 <xsl:template match ="bediteur"> 1067 <fo:inline font-variant='small-caps'> 1068 <xsl:for-each select="bpers|etal"> 1069 <xsl:value-of select="@prenom"/> 1070 <xsl:text> </xsl:text> 1071 <xsl:if test="@part"> 1072 <xsl:text> </xsl:text> 1073 <xsl:value-of select="@part"/> 1074 </xsl:if> 1075 <xsl:value-of select="@nom"/> 1076 <xsl:text>, </xsl:text> 1077 </xsl:for-each> 1078 </fo:inline> 1079 <xsl:choose> 1080 <xsl:when test="count(bpers|etal) != 1"> 1081 <xsl:text>editors</xsl:text> 1082 </xsl:when> 1083 <xsl:otherwise> 1084 <xsl:text>editor</xsl:text> 1085 </xsl:otherwise> 1086 </xsl:choose> 1087 <xsl:call-template name="separateur.objet"/> 1088 </xsl:template>
Translation of an <author> (a list of authors) in the new DTD bibliography. Authors are separated by commas, with a period at the end. Initials are used rather than full first name if available.
1089 <xsl:template match="author"> 1090 <fo:inline font-variant='small-caps'> 1091 <xsl:for-each select="persName"> 1092 <xsl:choose> 1093 <xsl:when test="surname='ETAL'"> 1094 <xsl:text>et al.</xsl:text> 1095 </xsl:when> 1096 <xsl:otherwise> 1097 <xsl:call-template name="jg.pers"/> 1098 <xsl:call-template name="separateur.objet"/> 1099 </xsl:otherwise> 1100 </xsl:choose> 1101 </xsl:for-each> 1102 </fo:inline> 1103 <xsl:text> </xsl:text> 1104 </xsl:template>
Case of <editor>, the list of editors. We add a comma in front if there are authors (otherwise, the element is output just after the title). Nothing special is done in the `ETAL´ case.
1105 <xsl:template match="editor"> 1106 <xsl:if test="../..//author"> <xsl:text>, </xsl:text></xsl:if> 1107 <fo:inline font-variant='small-caps'> 1108 <xsl:for-each select="persName"> 1109 <xsl:call-template name="jg.pers"/> 1110 <xsl:call-template name="separateurED.objet"/> 1111 </xsl:for-each> 1112 </fo:inline> 1113 <xsl:text> (editor</xsl:text> 1114 <xsl:call-template name="pluriel-p"> 1115 <xsl:with-param name="liste" select="persName" /> 1116 </xsl:call-template> 1117 <xsl:text>). </xsl:text> 1118 </xsl:template>
Common code for authors or editors.
1119 <xsl:template name=jgpers"> 1120 <xsl:choose> 1121 <xsl:when test="initial"><xsl:apply-templates select="initial"/></xsl:when > 1122 <xsl:otherwise> <xsl:apply-templates select="foreName"/> </xsl:otherwise> 1123 </xsl:choose> 1124 <xsl:text> </xsl:text> 1125 <xsl:value-of select="surname"/> 1126 </xsl:template>
This outputs an S in case the list has more than one element.
1127 <xsl:template name="pluriel-p"> 1128 <xsl:param name="liste" /> 1129 <xsl:if test="count($liste)>1">s</xsl:if> 1130 </xsl:template>
Translation of <catperso>. This is like a subsection, with a title (in <head>), we select all the <pers> children.
1131 <xsl:template match="catperso"> 1132 <fo:block space-before="3pt"> 1133 <fo:block font-weight='bold' text-indent="-15pt"> 1134 <xsl:value-of select="head"/> 1135 </fo:block> 1136 <xsl:for-each select="pers"> 1137 <fo:block> <xsl:call-template name="pers"/></fo:block> 1138 </xsl:for-each> 1139 </fo:block> 1140 </xsl:template>
This replaces the previous template in the case of the new DTD. Changes are obvious.
1141 <xsl:template match="team/participants"> 1142 <fo:block space-before="3pt"> 1143 <fo:block font-weight='bold' text-indent="-15pt"> 1144 <xsl:value-of select="translate(@category, '_', ' ')"/> 1145 </fo:block> 1146 <xsl:for-each select="person"> 1147 <fo:block> <xsl:apply-templates select="."/></fo:block> 1148 </xsl:for-each> 1149 </fo:block> 1150 </xsl:template>
Like above, but the result is inline: we do not put <pers> in a block, but use commas as separators.
1151 <xsl:template match="participants|participant|participante|participantes"> 1152 <fo:block space-after.optimum="4pt"> 1153 <fo:inline> 1154 <xsl:attribute name="font-weight">bold</xsl:attribute> 1155 <xsl:value-of select="@titre"/> 1156 </fo:inline> 1157 <fo:inline> 1158 <xsl:for-each select="pers"> 1159 <xsl:call-template name="pers"/> 1160 <xsl:call-template name="separateur.objet"/> 1161 </xsl:for-each> 1162 </fo:inline> 1163 </fo:block> 1164 </xsl:template>
There are some differences in the new DTD. Instead of four elements, we have a single one, named <participants>, and the title will be `Participant´ in the case where is a single <person>, `Participants´ if there are more than one. Two consecutive <participants> are implicitly merged, the persons in the second one are handled with the first. In some cases, the implementation is wrong; the case of <refperson> is sometimes considered here (but omitted in the HTML case).
1165 <xsl:template match="participants"> 1166 <xsl:if test="not(preceding-sibling::participants) and not(parent::team)"> 1167 <fo:block space-after.optimum="4pt"> 1168 <fo:inline> 1169 <xsl:attribute name="font-weight">bold</xsl:attribute> 1170 <xsl:text>Participant</xsl:text> 1171 <xsl:call-template name="pluriel-p"> 1172 <xsl:with-param name="liste" select="person" /> 1173 </xsl:call-template>: 1174 </fo:inline> 1175 <fo:inline> 1176 <xsl:for-each select="person | following-sibling::participants/person 1177 | refperson"> 1178 <xsl:apply-templates select="." mode="section"/> 1179 <xsl:call-template name="separateur.objet"/> 1180 </xsl:for-each> 1181 </fo:inline> 1182 </fo:block> 1183 </xsl:if> 1184 </xsl:template>
Transformation of <pers>. This is easy: we have two attributes, first name and last name. Unless empty, the content is put in brackets.
1185 <xsl:template name="pers"> 1186 <xsl:value-of select="./@prenom"/> 1187 <xsl:text> </xsl:text> 1188 <xsl:value-of select="./@nom"/> 1189 <xsl:if test="not(normalize-space(string(.)) ='')"> 1190 <xsl:text> [</xsl:text> 1191 <xsl:apply-templates/> 1192 <xsl:text>]</xsl:text> 1193 </xsl:if> 1194 </xsl:template>
In the case of the new DTD, we have a <firstname> and a <lastname>, instead of these two attributes, and <moreinfo> instead of a content. These are the only changes in the case of a <refperson> or a <person> outside the team composition(note: ➳).
1195 <xsl:template match="person">...</xsl:template> 1196 <xsl:template match="person" mode="section">...</xsl:template>
A <refperson> is just a reference to a <person> defined by its href attribute. In this code, we check that the reference is indeed a person.
1197 <xsl:template match="refperson" mode="section"> 1198 <xsl:variable name ="curid" select="@ref"/> 1199 <xsl:variable name ="curelement" select="/raweb//*[@id=$curid]"/> 1200 <xsl:if test="$curelement[name()='person']"> 1201 <xsl:apply-templates select="$curelement" mode="section"/> 1202 </xsl:if> 1203 </xsl:template>
The translation of <xref> (external reference) is a link, that points to the value of the url attribute. It has some color...
1204 <xsl:template match="xref"> 1205 <fo:basic-link color="{$linkColor}"> 1206 <xsl:attribute name="external-destination"> 1207 <xsl:value-of select="@url"/> 1208 </xsl:attribute> 1209 <xsl:apply-templates/> 1210 </fo:basic-link> 1211 </xsl:template>
The same code is used in the case when the link is a <citation> element; but we add a separator (comma or period) after it.
1212 <xsl:template match="citation/xref"> 1213 <fo:basic-link color="{$linkColor}"> 1214 <xsl:attribute name="external-destination"> 1215 <xsl:value-of select="@url"/> 1216 </xsl:attribute> 1217 <xsl:apply-templates/> 1218 </fo:basic-link> 1219 <xsl:call-template name="separateur.objet"/> 1220 </xsl:template>
Translation of an internal link. There is an attribute target that says to what it points. The <ref> element is empty, the link is not: the value of the link element is obtained by evaluating the target in the `xref´ mode. This should give a number (or a sequence like 12.3.4 for a subsection). In the case of a table, figure, math expression, this should be the number of the table, figure, etc.; in the case of a division, it should be the number associated to the title.
1221 <xsl:template match="ref"> 1222 <fo:basic-link color="{$linkColor}"> 1223 <xsl:attribute name="internal-destination"> 1224 <xsl:value-of select="translate(@target,'_','-')"/> 1225 </xsl:attribute> 1226 <xsl:apply-templates mode="xref" select="id(@target)" /> 1227 <xsl:apply-templates/> 1228 </fo:basic-link> 1229 </xsl:template>
The case of the new DTD, is much more complicated, since we have to compute the number of the reference. The same algorithm is used as in the HTML case, see previous chapter, section 6.4. We have a template positionInBib (same as line 3054 in the previous chapter), and we define position-in-bib(W) in the same way. Then the code looks like this:
1230 <xsl:template name="ref-in-bib"> 1231 <fo:basic-link color="{$linkColor}"> 1232 <xsl:attribute name="internal-destination"> 1233 <xsl:value-of select="$curid"/> 1234 </xsl:attribute> 1235 <xsl:choose> 1236 position-in-bib(d) 1237 position-in-bib(e) 1238 position-in-bib(f) 1239 position-in-bib(g) 1240 position-in-bib(h) 1241 position-in-bib(i) 1242 position-in-bib(j) 1243 position-in-bib(k) 1244 </xsl:choose> 1245 </fo:basic-link> 1246 <xsl:text>]</xsl:text> 1247 </xsl:template>
This is called when the attribute xlink:href does not start with a sharp sign; it can be an external reference (otherwise, the document is not valid, and the code is wrong, not shown here).
1248 <xsl:template name="external-ref"> 1249 <xsl:choose> 1250 <xsl:when test="@location='extern'"> 1251 <fo:basic-link color="{$linkColor}"> 1252 <xsl:attribute name="external-destination"> 1253 <xsl:value-of select="@xlink:href"/> 1254 </xsl:attribute> 1255 <xsl:apply-templates/> 1256 </fo:basic-link> 1257 </xsl:when> 1258 <xsl:otherwise> ... </xsl:otherwise> 1259 </xsl:choose> 1260 </xsl:template>
This is called when the attribute xlink:href has the form `#foo´, with `foo´ in $curid, and the target $curelement is <identification> or a child. In this case, we replace it by <team>. The idea is to evaluate the target in pre-ref, xref and post-ref modes, and put the value obtained in xref mode in the link.
1261 <xsl:template name="ref-to-ident"> 1262 <xsl:apply-templates select="/raweb/identification/team" mode="pre-ref" /> 1263 <fo:basic-link color="{$linkColor}" internal-destination="{$curid}"> 1264 <xsl:apply-templates select="/raweb/identification/team" mode="xref"/> 1265 </fo:basic-link> 1266 <xsl:apply-templates select="/raweb/identification/team" mode="post-ref" /> 1267 </xsl:template>
This is called when the attribute xlink:href has the form `#foo´, with `foo´ in $curid, and the target is $curelement. Note that empty pre-ref and post-ref are defined for <table>, <formula>, <subsection>, <biblio>, <presentation>, <fondements>, <domaine>, <logiciels>, <object>, <diffusion>, <resultats>, <contrats>, <identification>, <international>, <team>, <li>. In all other cases default will be used (let´s hope this case does not occur).
1268 <xsl:template name="internal-ref"> 1269 <xsl:apply-templates select="$curelement" mode="pre-ref" /> 1270 <fo:basic-link color="{$linkColor}" internal-destination="{$curid}"> 1271 <xsl:apply-templates select="$curelement" mode="xref"/> 1272 </fo:basic-link> 1273 <xsl:apply-templates select="$curelement" mode="post-ref" /> 1274 </xsl:template>
This is now the code for a reference in the new DTD.
1275 <xsl:template match="ref"> 1276 <xsl:choose> 1277 <xsl:when test="starts-with(@xlink:href, '#')"> 1278 <xsl:variable name="curid" select="substring-after(@xlink:href, '#')"/> 1279 <xsl:variable name="curelement" select="/raweb//*[@id=$curid]"/> 1280 <xsl:variable name="curlabel" 1281 select="$curelement/ancestor-or-self::subsection" /> 1282 <xsl:variable name="curlabelidentification" 1283 select="$curelement/ancestor-or-self::identification"/> 1284 <xsl:choose> 1285 <xsl:when test="$curlabelidentification"> 1286 <xsl:call-template name="ref-to-ident"/> 1287 </xsl:when> 1288 <xsl:when test="@location='biblio'"> 1289 <xsl:call-template name="ref-in-bib"/> 1290 </xsl:when> 1291 <xsl:when test="@location='intern'"> 1292 <xsl:call-template name="external-ref"/> 1293 </xsl:when> 1294 </xsl:choose> 1295 </xsl:when> 1296 <xsl:otherwise> 1297 <xsl:call-template name="external-ref"/> 1298 </xsl:otherwise> 1299 </xsl:choose> 1300 </xsl:template>
In the case of a section, computing the number is trivial: we take it from the DTD.
1301 <xsl:template 1302 match="biblio|presentation|fondements|domaine|logiciels|resultats| 1303 contrats|composition|international|diffusion" mode = 'xref'> 1304 <xsl:value-of select = "@numero"/> 1305 </xsl:template>
In the case of a subsection, computing the number is non trivial. The first component is the section number, followed by a dot.
1306 <xsl:template name="sec.num"> 1307 <xsl:value-of select = 1308 "ancestor-or-self::*[self::composition or self::presentation 1309 or self::fondements or self::domaine or self::logiciels 1310 or self::resultats or self::contrats or self::international 1311 or self::diffusion or self::biblio]/@numero"/> 1312 <xsl:text>.</xsl:text> 1313 </xsl:template>
In the original DTD, the section number was an attribute of the section, hence was easy to compute. This is the replacement code:
1314 <xsl:when test="ancestor-or-self::*[self::identification]">1</xsl:when> 1315 <xsl:when test="ancestor-or-self::*[self::presentation]">2</xsl:when> 1316 <xsl:when test="ancestor-or-self::*[self::fondements]">3</xsl:when> 1317 <xsl:when test="ancestor-or-self::*[self::domaine]">4</xsl:when> 1318 <xsl:when test="ancestor-or-self::*[self::logiciels]">5</xsl:when> 1319 <xsl:when test="ancestor-or-self::*[self::resultats]">6</xsl:when> 1320 <xsl:when test="ancestor-or-self::*[self::contrats]">7</xsl:when> 1321 <xsl:when test="ancestor-or-self::*[self::international]">8</xsl:when> 1322 <xsl:when test="ancestor-or-self::*[self::diffusion]">9</xsl:when> 1323 <xsl:when test="ancestor-or-self::*[self::biblio]">10</xsl:when>
Some people find it annoying that section 7 is followed by section 9, in case where section `International´ is missing. Thus, the correct number is used; for instance, if current section is `domaine´, its number is the number of `identification´ plus `presentation´, plus `fondements´ plus one. Full code nor shown, but obvious.
1324 <xsl:template name="calculateNumberSection"> 1325 <xsl:choose> 1326 <xsl:when test="ancestor-or-self::*[self::identification]">1</xsl:when> 1327 <xsl:when test="ancestor-or-self::*[self::presentation]"> 1328 <xsl:value-of select="count(/raweb/identification)+1"/> 1329 </xsl:when> 1330 <xsl:when test="ancestor-or-self::*[self::fondements]"> 1331 <xsl:value-of select="count(/raweb/identification) 1332 +count(/raweb/presentation)+1"/> 1333 </xsl:when> 1334 <xsl:when test="ancestor-or-self::*[self::domaine]"> 1335 <xsl:value-of select="count(/raweb/identification) 1336 +count(/raweb/presentation)+count(/raweb/fondements)+1"/> 1337 </xsl:when> 1338 ... 1339 <xsl:when test="ancestor-or-self::*[self::biblio]"> 1340 ... 1341 </xsl:when> 1342 <xsl:otherwise>Section</xsl:otherwise> 1343 </xsl:choose> 1344 <xsl:text>.</xsl:text> 1345 </xsl:template> 1346 1347 <xsl:template match="biblio|presentation|fondements|domaine| 1348 logiciels|resultats|contrats|identification|international|diffusion|team" 1349 mode = 'xref'> 1350 <xsl:call-template name="calculateNumberSection"/> 1351 </xsl:template>
This computes the number associated to a division (module, div2, div3, and div4) by counting these things. It is used twice: when the division is typeset (more exactly, when its title is typeset), and when the division appears in a link.
1352 <xsl:template name="calculateNumber"> 1353 <xsl:param name="numbersuffix"/> 1354 <xsl:call-template name="sec.num"/> 1355 <xsl:number level="multiple" from="raweb" 1356 count="module|div2|div3|div4"/> 1357 <xsl:value-of select="$numbersuffix"/> 1358 </xsl:template>
This is the code for the new DTD, a little bit simpler.
1359 <xsl:template name="calculateNumber"> 1360 <xsl:param name="numbersuffix"/> 1361 <xsl:call-template name="calculateNumberSection"/> 1362 <xsl:number level="multiple" from="raweb" count="subsection"/> 1363 <xsl:value-of select="$numbersuffix"/> 1364 </xsl:template>
This calls the template shown above. Is named <subsection> in the new DTD.
1365 <xsl:template mode="xref" match="module|div2|div3|div4"> 1366 <xsl:call-template name="calculateNumber"/> 1367 </xsl:template>
It is not clear where the anchor of a section should be: on the division or its title. For this reason this rule is added for <head> (or <bodyTitle> in the new DTD); it is useless because we decided finally that the anchor should not be on the title. In a previous version of Tralics, <anchor> elements were generated (then removed, and re-inserted). Anchors should not be used in the Raweb.
1368 <xsl:template match="head|anchor" mode ="xref"> 1369 <xsl:call-template name="calculateNumber"/> 1370 </xsl:template>
The idea is that every math formula (a <formula> element) that has an id is numbered.
1371 <xsl:template match="formula" mode="xref"> 1372 <xsl:number level = "any" count="formula[@id]"/> 1373 </xsl:template>
In the case of a figure, we count only figures that are not inline, via the rend attribute.
1374 <xsl:template name="calculateFigureNumber"> 1375 <xsl:number count="figure[@rend != 'inline']" level="any"/> 1376 </xsl:template>
1377 <xsl:template match='figure' mode="xref"> 1378 <xsl:call-template name="calculateFigureNumber"/> 1379 </xsl:template>
Same for a table. In the new DTD, the test is: all tables whose ancestors are not <object>.
1380 <xsl:template name="calculateTableNumber"> 1381 <xsl:number count="table[@rend != 'inline']" level="any"/> 1382 </xsl:template>
1383 <xsl:template match='table' mode="xref"> 1384 <xsl:call-template name="calculateTableNumber"/> 1385 </xsl:template>
In the case of a <note>, we count all elements that have a place attribute with value `foot´. This is called <footnote> in the new DTD.
1386 <xsl:template name="calculateFootnoteNumber"> 1387 <xsl:number level="any" count="note[@place='foot']"/> 1388 </xsl:template>
The case of an item is more complicated. Originally, there was a test: is the parent a <list> of type bibliography? in this case, `[25]´ is produced instead of `25´. This test was removed. Thus, the only non trivial point is that numbering depends on the list level.
1389 <xsl:template match="item" mode="xref"> 1390 <xsl:variable name="listdepth" select="count(ancestor::list)"/> 1391 <xsl:variable name="listNFormat"> 1392 <xsl:choose> 1393 <xsl:when test="$listdepth=1"> <xsl:text>1</xsl:text> </xsl:when> 1394 <xsl:when test="$listdepth=2"> <xsl:text>i</xsl:text> </xsl:when> 1395 <xsl:when test="$listdepth=3"> <xsl:text>a</xsl:text> </xsl:when> 1396 <xsl:when test="$listdepth=4"> <xsl:text>I</xsl:text> </xsl:when> 1397 </xsl:choose> 1398 </xsl:variable> 1399 <xsl:number format="{$listNFormat}"/> 1400 </xsl:template>
In the new DTD, we use <li> instead of <item>. All items are counted the same, independently of the list depth. There is however a second rule, that looks like the previous one, except that the list level is computed but the sum of the number of ancestors of type <glosslist>, <descriptionlist>, <simplelist>, and <orderedlist>.
1401 <xsl:template match='li' mode="xref"> 1402 <xsl:number count="li" level="single" /> 1403 </xsl:template>
Trivial templates added for the new DTD.
1404 <xsl:template name="calculateObjectNumber"> 1405 <xsl:number count="object" level="any"/> 1406 </xsl:template> 1407 1408 <xsl:template name="calculateRessourceNumber"> 1409 <xsl:number count="ressource" level="any"/> 1410 </xsl:template>
1411 <xsl:template match='object' mode="xref"> 1412 <xsl:call-template name="calculateObjectNumber"/> 1413 </xsl:template> 1414 1415 <xsl:template match="ressource" mode="xref"> 1416 <xsl:call-template name="calculateRessourceNumber"/> 1417 </xsl:template>
A <p> element is translated into a <fo:block> element. It has some attributes, for instance a constant font size.
1418 <xsl:template match="p"> 1419 <fo:block font-size="{$bodySize}">
If the preceding sibling is a <p> element, and the current element has not noindent = `true´ as attribute, the paragraph will be indented, said otherwise, it will have a non-zero text-indent. The space-before attribute is computed as follows. We define a maximum value in the case where the preceding sibling is a <p>. We define an optimum value in the case where spacebefore is given as attribute to the current element. We define an optimum value if nothing is given, and the preceding sibling is a <p>. Note: we should always define all three values, because the default is zero, and this is wrong (but fotex interprets badly these quantities...)
1420 <xsl:if test="preceding-sibling::p"> 1421 <xsl:if test ="not(@noindent)"> 1422 <xsl:attribute name="text-indent"> 1423 <xsl:value-of select="$parIndent"/> 1424 </xsl:attribute> 1425 </xsl:if> 1426 <xsl:choose> 1427 <xsl:when test="@spacebefore"> 1428 <xsl:attribute name="space-before.optimum"> 1429 <xsl:value-of select="@spacebefore"/> 1430 </xsl:attribute> 1431 </xsl:when> 1432 <xsl:otherwise> 1433 <xsl:attribute name="space-before.optimum"> 1434 <xsl:value-of select="$parSkip"/> 1435 </xsl:attribute> 1436 </xsl:otherwise> 1437 </xsl:choose> 1438 <xsl:attribute name="space-before.maximum"> 1439 <xsl:value-of select="$parSkipmax"/> 1440 </xsl:attribute> 1441 </xsl:if> 1442 <xsl:if test="not(preceding-sibling::p)"> 1443 <xsl:if test="@spacebefore"> 1444 <xsl:attribute name="space-before.optimum"> 1445 <xsl:value-of select="@spacebefore"/> 1446 </xsl:attribute> 1447 </xsl:if> 1448 </xsl:if>
In the case where the rend attribute is `centered´ or `center´, we set text-align to `center´. If it is `flushed-left´ or `flushed-right´ we set it to left or right. If it is `quoted´ or `justify´ we set it to `justify´ (in the case `quoted´, we also set both left and right margins to 1 cm). The new code has a comment that says “ARG, useless with the new DTD but ...”
1449 <xsl:choose> 1450 <xsl:when test="@rend ='centered'"> 1451 <xsl:attribute name="text-align">center</xsl:attribute> 1452 </xsl:when> 1453 <xsl:when test="@rend ='center'"> 1454 <xsl:attribute name="text-align">center</xsl:attribute> 1455 </xsl:when> 1456 <xsl:when test="@rend ='flushed-left'"> 1457 <xsl:attribute name="text-align">left</xsl:attribute> 1458 </xsl:when> 1459 <xsl:when test="@rend ='flushed-right'"> 1460 <xsl:attribute name="text-align">right</xsl:attribute> 1461 </xsl:when> 1462 <xsl:when test="@rend ='quoted'"> 1463 <xsl:attribute name="text-align">justify</xsl:attribute> 1464 <xsl:attribute name="margin-left">1cm</xsl:attribute> 1465 <xsl:attribute name="margin-right">1cm</xsl:attribute> 1466 </xsl:when> 1467 <xsl:when test="@rend ='justify'"> 1468 <xsl:attribute name="text-align">justify</xsl:attribute> 1469 </xsl:when> 1470 </xsl:choose>
We insert the content of the <p> here.
1471 <xsl:apply-templates/> 1472 </fo:block> 1473 </xsl:template>
Conversion of <hi>. The result is an inline object, the non trivial part concerns transformation of the rend attribute, but this is defined elsewhere.
1474 <xsl:template match="hi"> 1475 <fo:inline> 1476 <xsl:call-template name="rend" /> 1477 <xsl:apply-templates/> 1478 </fo:inline> 1479 </xsl:template>
In the new DTD, <hi> has sometimes been replaced by <em>.
1480 <xsl:template match="em"> 1481 <fo:inline> 1482 <xsl:call-template name="style"/> 1483 <xsl:apply-templates/> 1484 </fo:inline> 1485 </xsl:template>
1486 <xsl:template match="code"> 1487 <fo:inline font-family="{$typewriterFont}"> 1488 <xsl:apply-templates/> 1489 </fo:inline> 1490 </xsl:template>
1491 <xsl:template match="ident"> 1492 <fo:inline color="{$identColor}" font-family="{$sansFont}"> 1493 <xsl:apply-templates/> 1494 </fo:inline> 1495 </xsl:template>
1496 <xsl:template match="term"> 1497 <fo:inline font-style="italic"> 1498 <xsl:apply-templates/> 1499 </fo:inline> 1500 </xsl:template>
This translates a <list>. In any case, the result is a <fo:list-block> with some constant right margin and a left margin that depends on the context: normal list, normal glossary, or glossary in a list. All items in the list are considered.
1501 <xsl:template match="list"> 1502 <xsl:call-template name="titlelist"/> 1503 <fo:list-block margin-right="{$listRightMargin}"> 1504 <xsl:call-template name="setListIndents"/> 1505 <xsl:choose> 1506 <xsl:when test="@type='gloss'"> 1507 <xsl:attribute name="margin-left"> 1508 <xsl:choose> 1509 <xsl:when test="ancestor::list"><xsl:value-of 1510 select="$listLeftGlossInnerIndent"/></xsl:when> 1511 <xsl:otherwise><xsl:value-of select="$listLeftGlossIndent"/></xsl:otherwise> 1512 </xsl:choose> 1513 </xsl:attribute> 1514 </xsl:when> 1515 <xsl:otherwise> 1516 <xsl:attribute name="margin-left"> 1517 <xsl:value-of select="$listLeftIndent"/></xsl:attribute> 1518 </xsl:otherwise> 1519 </xsl:choose> 1520 <xsl:apply-templates select="item"/> 1521 </fo:list-block> 1522 </xsl:template>
If the first child of a list is <head> we start with a block containing the title in italics. This is not used in the Raweb.
1523 <xsl:template name="titlelist"> 1524 <xsl:if test="child::head"> 1525 <fo:block font-style="italic" 1526 text-align="start" 1527 space-before.optimum="4pt"> 1528 <xsl:apply-templates select="head"/> 1529 </fo:block> 1530 </xsl:if> 1531 </xsl:template>
Note: in the case of the new DTD, there are more than one type of lists. Thus the template named <list> has to be replaced by two templates: one for <orderedlist>, <simplelist>, <descriptionlist> and one for <glosslist>. The outer test (has this element an attribute type with value `gloss´?) becomes: is this element a <glosslist> whose answer is trivial. The inner test (is the ancestor a list?) becomes more complicated. A list contains a sequence of <item> elements (renamed to <li> in the new DTD) optionally preceded by a <label>. The code shown above applies a rule to each <item>; this was changed to: apply a rule to everything but a <title>. Note that the default template for a <label> is to ignore it; only in `print´ mode is the action non-trivial.
1532 <xsl:template match="label"/> 1533 1534 <xsl:template match="label" mode="print"> 1535 <xsl:apply-templates/> 1536 </xsl:template>
A list has also a space-before and space-after attributes, that depend on the level. The complete code is not shown here. In the new DTD, computing the list depth is a bit harder, because we must sum up the number of ancestors of type <glosslist>, <descriptionlist>, <simplelist>, and <orderedlist> (the list depth is used more than once: here it is used to compute the margins, below, when we typeset the item, and in section 7.8 when a reference is made to the item).
1537 <xsl:template name="setListIndents"> 1538 <xsl:variable name="listdepth" select="count(ancestor::list)"/> 1539 <xsl:choose> 1540 <xsl:when test="$listdepth=0"> 1541 <xsl:attribute name="space-before"> 1542 <xsl:value-of select="$listAbove-1"/> 1543 </xsl:attribute> 1544 <xsl:attribute name="space-after"> 1545 <xsl:value-of select="$listBelow-1"/> 1546 </xsl:attribute> 1547 </xsl:when> 1548 <!-- Same for listdepth=1 2 or 3 --> 1549 </xsl:choose> 1550 </xsl:template>
1551 <xsl:template match="item"> 1552 <xsl:call-template name="makeItem"/> 1553 </xsl:template>
Translation of an <item>. The result is a <fo:list-item> that contains two sub-elements, we start with the first, the <fo:list-item-label>. It depends on the type attribute of our parent: simple, bullets, ordered, gloss, unordered (in the case of the new DTD, it depends on the name of the parent). In any case, if we have an id, we associate it to the element; then we construct a <fo:block>. The case where the list is in the bibliography is not shown here. The case where the label has an n attribute is not shown here. In the case where the list has type = `ordered´, we evaluate the item in `xref´ mode: this produces a number; this number will be flushed right (alignment end). In the case where the list is a glossary, we will left align the label using a bold font; here the label is either a <label> child or a <label> sibling. In all other cases, if there is a label sibling it will be used. In both these cases, the label is transformed using a special mode.
1554 <xsl:template name="makeItem"> 1555 <xsl:variable name="listdepth" select="count(ancestor::list)"/> 1556 <fo:list-item space-before.optimum="{$listItemsep}">
1557 <fo:list-item-label> 1558 <xsl:if test="@id"> 1559 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 1560 </xsl:if> 1561 <fo:block> 1562 <xsl:attribute name="margin-right">2.5pt</xsl:attribute> 1563 <xsl:choose> 1564 <xsl:when test="../@type='ordered'"> 1565 <xsl:attribute name="text-align">end</xsl:attribute> 1566 <xsl:apply-templates mode="xref" select="."/> 1567 <xsl:text>.</xsl:text> 1568 </xsl:when> 1569 <xsl:when test="../@type='gloss'"> 1570 <xsl:attribute name="text-align">start</xsl:attribute> 1571 <xsl:attribute name="font-weight">bold</xsl:attribute> 1572 <xsl:choose> 1573 <xsl:when test="label"> 1574 <xsl:apply-templates mode="print" select="label"/> 1575 </xsl:when> 1576 <xsl:otherwise> 1577 <xsl:apply-templates mode="print" select="preceding-sibling::*[1]"/> 1578 </xsl:otherwise> 1579 </xsl:choose> 1580 </xsl:when> 1581 <xsl:when test="name(preceding-sibling::*[1])='label'"> 1582 <xsl:apply-templates mode="print" select="preceding-sibling::*[1]"/> 1583 </xsl:when>
In all other cases, a default value is chosen, depending on the list level.
1584 <xsl:otherwise> 1585 <xsl:attribute name="text-align">center</xsl:attribute> 1586 <xsl:choose> 1587 <xsl:when test="$listdepth=1"> 1588 <xsl:value-of select="$bulletOne"/> 1589 </xsl:when> 1590 <xsl:when test="$listdepth=2"> 1591 <xsl:value-of select="$bulletTwo"/> 1592 </xsl:when> 1593 <xsl:when test="$listdepth=3"> 1594 <xsl:value-of select="$bulletThree"/> 1595 </xsl:when> 1596 <xsl:when test="$listdepth=4"> 1597 <xsl:value-of select="$bulletFour"/> 1598 </xsl:when> 1599 </xsl:choose> 1600 </xsl:otherwise> 1601 </xsl:choose> 1602 </fo:block> 1603 </fo:list-item-label>
Essentially, the translation is a <fo:list-item-body> that contains a <fo:block>. This block is constructed implicitly by a <p> or explicitly, with a normal weight for the font.
1604 <fo:list-item-body> 1605 <xsl:choose> 1606 <xsl:when test="p"> <xsl:apply-templates/> </xsl:when> 1607 <xsl:otherwise> 1608 <fo:block font-weight="normal"><xsl:apply-templates/></fo:block> 1609 </xsl:otherwise> 1610 </xsl:choose> 1611 </fo:list-item-body> 1612 </fo:list-item> 1613 </xsl:template>
This converts an image, or something like that. The result is a <fo:external-graphic> object. The src attribute is taken to be the file attribute. Initially, there was a $graphicsPrefix prefix before the image; this was removed: images should be in the current directory. We consider the three attributes scale, width, height and angle. Let´s hope that angle is not used: in TeX, putting the angle to ninety degrees exchanges the role of width and height, but you can specify the width after rotation. Since the order of attributes is irrelevant in XML, you lose(note: ➳). But you cannot turn images in HTML. Note: if you specify a scale, you cannot specify a width nor a height. In the new DTD the attribute file is replaced by xlink:href. We removed a test to $autoScaleFigures, placed after all other tests.
1614 <xsl:template name="generate-graphics"> 1615 <fo:external-graphic src="{@file}"> 1616 <xsl:choose> 1617 <xsl:when test="@scale"> 1618 <xsl:attribute name="content-width"> 1619 <xsl:value-of select="@scale * 100"/><xsl:text>%</xsl:text> 1620 </xsl:attribute> 1621 </xsl:when> 1622 <xsl:when test="@width"> 1623 <xsl:attribute name="content-width"> <xsl:value-of select="@width"/> 1624 </xsl:attribute> 1625 <xsl:if test="@height"> 1626 <xsl:attribute name="content-height"> 1627 <xsl:value-of select="@height"/> 1628 </xsl:attribute> 1629 </xsl:if> 1630 <xsl:if test="@angle"> 1631 <xsl:attribute name="angle"> 1632 <xsl:value-of select="@angle"/> 1633 </xsl:attribute> 1634 </xsl:if> 1635 </xsl:when> 1636 <xsl:when test="@height"> 1637 <xsl:attribute name="content-height"> 1638 <xsl:value-of select="@height"/> 1639 </xsl:attribute> 1640 <xsl:if test="@angle"> 1641 <xsl:attribute name="angle"> 1642 <xsl:value-of select="@angle"/> 1643 </xsl:attribute> 1644 </xsl:if> 1645 </xsl:when> 1646 </xsl:choose> 1647 </fo:external-graphic> 1648 </xsl:template>
A <figure> element, that has rend = `inline´, produces a graphic object by the routine shown above. If it has a <head> (renamed to <caption> in the new DTD), this is a caption, shown after the image. In the new DTD, the template is called <ressource>; if the attribute media is set to `PRINT´, or if the ancestor has no other resource whose media attribute is set to `PRINT´, then it will be used, otherwise discarded (this allows a different image in the Pdf or HTML version).
1649 <xsl:template match="figure[@rend='inline']"> 1650 <xsl:call-template name='generate-graphics'/> 1651 <xsl:if test="head"> 1652 <fo:block text-align="center"> 1653 <xsl:apply-templates select="head"/> 1654 </fo:block> 1655 </xsl:if> 1656 </xsl:template>
All other images produce a <fo:float> object. It has an id, and contains an <fo:block>, this block is created by the procedure shown above, in case there is a file attribute, or by evaluating all <p> children. The content is centered. There is a second block, that contains the caption (from <head>).
1657 <xsl:template match='figure'> 1658 <fo:float> 1659 <xsl:call-template name="addID"/> 1660 <fo:block text-align="center"> 1661 <xsl:choose> 1662 <xsl:when test="@file"> 1663 <xsl:call-template name='generate-graphics'/> 1664 </xsl:when> 1665 <xsl:otherwise><xsl:apply-templates select='p'/></xsl:otherwise> 1666 </xsl:choose> 1667 </fo:block> 1668 <fo:block> 1669 <xsl:call-template name="figureCaptionstyle"/> 1670 <xsl:value-of select="$figureWord"/> 1671 <xsl:call-template name="calculateFigureNumber"/> 1672 <xsl:text>. </xsl:text> 1673 <xsl:apply-templates select="head"/> 1674 </fo:block> 1675 </fo:float> 1676 </xsl:template>
In the new DTD, we have <object> elements rather than <figure>. The content is always a table (so that there is no need to test for a file attribute).
1677 <xsl:template match="object" > 1678 <fo:float> 1679 <xsl:call-template name="addID"/> 1680 <fo:block> 1681 <xsl:apply-templates select="table" mode="object"/> 1682 </fo:block> 1683 <fo:block> 1684 <xsl:call-template name="figureCaptionstyle"/> 1685 <xsl:value-of select="$figureWord"/> 1686 <xsl:call-template name="calculateObjectNumber"/> 1687 <xsl:text>. </xsl:text> 1688 <xsl:apply-templates select="caption"/> 1689 </fo:block> 1690 </fo:float> 1691 </xsl:template>
1692 <xsl:template match="object/caption"><xsl:apply-templates/></xsl:template> 1693 <xsl:template match="ressource/caption"><xsl:apply-templates/></xsl:template>
Essentially, the table is handled by blockTable; this produces a <fo:table> element; but if the table is not marked inline, we use floatTable, this will produce a <fo:table-and-caption>. In the new DTD, a block table is used if the ancestor is an <object> (recall that an <object> is a floating object that contains a table that contains graphic images as cells).
1694 <xsl:template match="table"> 1695 <xsl:choose> 1696 <xsl:when test="@rend='inline'"><xsl:call-template name="blockTable"/></xsl:when> 1697 <xsl:otherwise> <xsl:call-template name="floatTable"/> </xsl:otherwise> 1698 </xsl:choose> 1699 </xsl:template>
This produces a <fo:table-and-caption> containing a table and a caption. The table is computed as in the case without caption. There is a mechanism that turns the whole table-and-caption by ninety degree, this is not used by Tralics. The caption is preceded by something like `Figure 99´, and the number has to be computed.
1700 <xsl:template name="floatTable"> 1701 <fo:table-and-caption> 1702 <xsl:if test="rend='landscape'"> 1703 <xsl:attribute name="reference-direction">-90</xsl:attribute> 1704 </xsl:if> 1705 <xsl:call-template name="addID"/> 1706 <fo:table-caption> 1707 <fo:block text-align="{$tableCaptionAlign}" 1708 space-after="{$spaceBelowCaption}"> 1709 <xsl:value-of select="$tableWord"/> 1710 <xsl:call-template name="calculateTableNumber"/> 1711 <xsl:text>. </xsl:text> 1712 <xsl:apply-templates select="head"/> 1713 </fo:block> 1714 </fo:table-caption> 1715 <xsl:call-template name="blockTable"/> 1716 </fo:table-and-caption> 1717 </xsl:template>
Transforming a table is easy: we select every row, and every cell in the rows. There is however a non trivial point: the current fotex implementation assumes that columns widths are given; hence we must compute them. Note: there is a <xsl:text> element, a contains a newline character; this improves the layout of the resulting XML; it seems useless. In the new version, the for-each has been replaced by an apply-templates to all elements of type <th> (this is strange) and <tr>. Moreover deriveColSpecs has been replaced by calculateTableSpecs (see below).
1718 <xsl:template name="blockTable"> 1719 <fo:table text-align="{$tableAlign}"> 1720 <xsl:call-template name="addID"/> 1721 <xsl:call-template name="deriveColSpecs"/> 1722 <fo:table-body text-indent="0pt"> 1723 <xsl:for-each select="row"> 1724 <xsl:text></xsl:text> <!-- this is a newline character --> 1725 <fo:table-row> 1726 <xsl:apply-templates select="cell"/> 1727 </fo:table-row> 1728 </xsl:for-each> 1729 </fo:table-body> 1730 </fo:table> 1731 </xsl:template>
This seems useless. One can however imagine the situation where the table specifications are stored somewhere and we need a unique identifier for the table.
1732 <xsl:template name="generateTableID"> 1733 <xsl:choose> 1734 <xsl:when test="@id"> <xsl:value-of select="@id"/> </xsl:when> 1735 <xsl:otherwise><xsl:text>Table-</xsl:text><xsl:number level='any'/> 1736 </xsl:otherwise> 1737 </xsl:choose> 1738 </xsl:template>
The procedure that computes the table specifications is in another file. The variable computed here is useless; it is perfectly legitimate to replace the call by this template by a call to inner template.
1739 <xsl:template name="deriveColSpecs" > 1740 <xsl:variable name="no"> <xsl:call-template name="generateTableID"/> 1741 </xsl:variable> 1742 <xsl:call-template name="calculateTableSpecs"/> 1743 </xsl:template>
This is the same as code given elsewhere. We leave the math unchanged.
1744 <xsl:template match="m:math"> 1745 <m:math> 1746 <xsl:copy-of select="@*"/> 1747 <xsl:apply-templates mode="math"/> 1748 </m:math> 1749 </xsl:template>
1750 <xsl:template match="m:*|@*|comment()|processing-instruction()|text()" mode="math"> 1751 ... 1752 </xsl:template>
We replace a formula by its content.
1753 <xsl:template match="formula"> 1754 <xsl:apply-templates/> 1755 </xsl:template>
A special case is when the formula has `display´ as type. If there is an id, then the result is a <fotex:equation>, otherwise it is a <fotex:displaymath>. In the case of an equation, we use a <fo:inline> (why not use it in every case? or add the id to the equation?) Note that the for-each is useless.
1756 <xsl:template match="formula[@type='display']"> 1757 <xsl:choose> 1758 <xsl:when test="@id"> 1759 <fo:inline> 1760 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 1761 <fotex:equation> 1762 <xsl:for-each select="m:math"> 1763 <xsl:apply-templates mode="math"/> 1764 </xsl:for-each> 1765 </fotex:equation> 1766 </fo:inline> 1767 </xsl:when> 1768 <xsl:otherwise> 1769 <fotex:displaymath> 1770 <xsl:for-each select="m:math"> 1771 <xsl:apply-templates mode="math"/> 1772 </xsl:for-each> 1773 </fotex:displaymath> 1774 </xsl:otherwise> 1775 </xsl:choose> 1776 </xsl:template>
We convert a <simplemath> element to a normal math element.
1777 <xsl:template match="simplemath"> 1778 <m:math><m:mi><xsl:apply-templates/></m:mi></m:math> 1779 </xsl:template>
Translation of <head>. We look at the parent. If it is a division (it starts with `div´, or is a <module>) we do nothing (already done), otherwise, we just output it. In the case of the new DTD, this is called <bodyTitle> and nothing is done if the parent is <subsection> or if the grand-father of the parent is <raweb>.
1780 <xsl:template match="head" priority="10"> 1781 <xsl:variable name="parent" select="name(..)"/> 1782 <xsl:if test="not(starts-with($parent,'div')) and not($parent = 'module')"> 1783 <xsl:apply-templates/> 1784 </xsl:if> 1785 </xsl:template>
We copy all <?xmltex?> instructions.
1786 <xsl:template match="processing-instruction()[name()='xmltex']" > 1787 <xsl:message>xmltex pi <xsl:value-of select="."/></xsl:message> 1788 <xsl:copy-of select="."/> 1789 </xsl:template>
1790 <xsl:variable name="processor"> 1791 <xsl:value-of select="system-property('xsl:vendor')"/> 1792 </xsl:variable>
This is defined like in other style sheets.
1793 <xsl:variable name="LeTypeProjet"> 1794 <!-- see elsewhere --> 1795 </xsl:variable>
1796 <xsl:variable name="year"> 1797 <!-- see elsewhere --> 1798 </xsl:variable>
1799 <xsl:variable name="PRID"> 1800 <xsl:value-of select="$LeTypeProjet"/> 1801 <xsl:text> </xsl:text> 1802 <xsl:value-of select="/raweb/accueil/projet"/> 1803 </xsl:variable>
This creates the first page. We start with a <fo:INRIA> special element, giving it the current year as year attribute. This will insert the logo. After that, we have a link to the Team´s home page, with the short and long name. We have a link to each UR. We have also a special element <fo:RATHEME> that completes our page hacking. For the new DTD, replace attribute html by id, element <projet> by <shortname>, element <projetdeveloppe> by <projectName>, replace UR/* in the for-each by UR, and for each <UR> element, replace the attribute nom by name and url (which disappeared) by a value that depends on the name attribute.
1804 <xsl:template name="accueil.body"/> 1805 <fo:INRIA year="{$year}"/> 1806 <fo:block font-size= "25pt" text-align="center"> 1807 <fo:basic-link external-destination="http://www.inria.fr/recherche/ 1808 equipes/{@html}.en.html"> 1809 <xsl:value-of select="$LeTypeProjet"/> <xsl:text> </xsl:text> 1810 <xsl:value-of select="projet"/> 1811 </fo:basic-link> 1812 </fo:block> 1813 <fo:block font-size= "25pt" text-align="center" space-before="1cm"> 1814 <xsl:value-of select="projetdeveloppe"/> 1815 </fo:block> 1816 <fo:block font-size= "17.28pt" text-align="center" space-before="1cm"> 1817 <xsl:for-each select ="UR/*"> 1818 <fo:basic-link external-destination ="{@url}"> 1819 <xsl:value-of select="@nom"/> 1820 <xsl:if test="position()!=last()"> - </xsl:if> 1821 </fo:basic-link> 1822 </xsl:for-each> 1823 </fo:block> 1824 <fo:block font-size= "10pt" font-style="normal" 1825 font-family="Helvetica" text-align="center" space-before="1cm"> 1826 <fo:RATHEME><xsl:value-of select="theme"/></fo:RATHEME> 1827 </fo:block> 1828 </xsl:template>
A <moreinfo> is typeset in italics.
1829 <xsl:template match="moreinfo"> 1830 <fo:block font-style="italic"> <xsl:apply-templates/> </fo:block> 1831 </xsl:template>
1832 <xsl:template name="addID"> 1833 <xsl:attribute name="id"> 1834 <xsl:call-template name="idLabel"/> 1835 </xsl:attribute> 1836 </xsl:template>
These rules have been added so that TeX and LaTeX are nicely printed.
1837 <xsl:template match="TeX"> 1838 <TeX/> 1839 </xsl:template> 1840 <xsl:template match="LaTeX"> 1841 <LaTeX/> 1842 </xsl:template>
1843 <xsl:template match="anchor"> 1844 <fo:inline> 1845 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 1846 </fo:inline> 1847 </xsl:template>
Translation of <keywords>. We take all the <term> elements.
1848 <xsl:template match="keywords"> 1849 <fo:block space-after.optimum="4pt"> 1850 <fo:inline> 1851 <xsl:attribute name="font-weight">bold</xsl:attribute> 1852 <xsl:value-of select="./@titre"/> 1853 </fo:inline> 1854 <xsl:for-each select="term"> 1855 <xsl:apply-templates select="."/> <xsl:call-template name="separateur.objet"/> 1856 </xsl:for-each> 1857 </fo:block> 1858 </xsl:template>
Keywords in the new DTD. We have a list of <keyword> elements. The default behavior is to omit them. In some cases, we output then in italic font style, with a comma as separator.
1859 <xsl:template match="keyword" mode="section"> 1860 <fo:inline font-style="italic"> 1861 <xsl:apply-templates/> 1862 </fo:inline> 1863 <xsl:call-template name="separateur.objet"/> 1864 </xsl:template> 1865 1866 <xsl:template match="keyword"/>
This means: if there is a keyword, we output them all, sorted in alphabetic order (this is strange), preceded by a title.
1867 <xsl:template name="keywords-list2"> 1868 <xsl:if test="./keyword"> 1869 <fo:block space-after.optimum="4pt"> 1870 <fo:inline> 1871 <xsl:attribute name="font-weight">bold</xsl:attribute> 1872 Keywords: 1873 </fo:inline> 1874 <xsl:apply-templates select="(./keyword)" mode="section" > 1875 <xsl:sort /> 1876 </xsl:apply-templates> 1877 </fo:block> 1878 </xsl:if> 1879 </xsl:template>
This code is similar, it is applied to a module (a <subsection> that has no <subsection> as ancestor). We output all keywords, of the module and its submodules.
1880 <xsl:template name="keywords-list"> 1881 <xsl:if test=".//keyword"> 1882 <fo:block space-after.optimum="4pt"> 1883 <fo:inline> 1884 <xsl:attribute name="font-weight">bold</xsl:attribute> 1885 Keywords: 1886 </fo:inline> 1887 <xsl:apply-templates select="(.//keyword)" mode="section" > 1888 <xsl:sort /> 1889 </xsl:apply-templates> 1890 </fo:block> 1891 </xsl:if> 1892 </xsl:template>
These include files are describe in the next section.
1893 <xsl:include href="raweb3-table.xsl"/> 1894 <xsl:include href="raweb3-makecolspec.xsl"/>
This is the end of the file.
1895 </xsl:stylesheet>
We consider here a file that starts like this. This uses extensions to XSLT. It is taken from the TEI distribution, see Copyright notice in the preceding chapter.
1896 <?xml version="1.0" encoding="utf-8"?> 1897 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 1898 xmlns:fotex="http://www.tug.org/fotex" 1899 xmlns:exsl="http://exslt.org/common" 1900 exclude-result-prefixes="saxon exsl" 1901 extension-element-prefixes="saxon exsl fotex" 1902 xmlns:saxon="http://icl.com/saxon" 1903 xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
The computations are the following. For each cell in the table, we construct a variable, named $stuff, that contains the value of the cell (some templates are applied). We construct a <cell> element, that has a <col> attribute whose value is the position of the cell; hence this algorithm does not work in the case where the cell spans multiple columns. The content of the cell is its width (i.e., is the width of the cell to typeset); this is hard to compute (consider two cells, one with an image of size 10cm, another one with a caption for it). In order to make this guess more usable, we added 100(note: ➳). All these cells are put in a variable $tds. Consider for instance the case where the cells are of width 1, 2, 3, and 4, there are two rows, the first two cells are in the first row. We compute the total, namely 10. The columns totals are 4 and 6, so that the width of the columns are 40% and 60%; these two quantities are computed by sorting the cells by column. For each cell that is the first (has no preceding sibling) we compute the sum of the following siblings. In the new DTD, <cell> is replaced by <td>, etc.
1904 <xsl:template name="calculateTableSpecs"> 1905 <xsl:variable name="tds"> 1906 <xsl:for-each select=".//cell"> 1907 <xsl:variable name="stuff"> 1908 <xsl:apply-templates/> 1909 </xsl:variable> 1910 <cell> 1911 <xsl:attribute name="col"><xsl:number/></xsl:attribute> 1912 <xsl:value-of select="string-length($stuff) + 100"/> 1913 </cell> 1914 </xsl:for-each> 1915 </xsl:variable> 1916 <xsl:variable name="total"> 1917 <xsl:value-of select="sum(exsl:node-set($tds)/cell)"/> 1918 </xsl:variable> 1919 <xsl:for-each select="exsl:node-set($tds)/cell"> 1920 <xsl:sort select="@col" data-type="number"/> 1921 <xsl:variable name="c" select="@col"/> 1922 <xsl:if test="not(preceding-sibling::cell[$c=@col])"> 1923 <xsl:variable name="len"> 1924 <xsl:value-of select="sum(following-sibling::cell[$c=@col]) + current()"/> 1925 </xsl:variable> 1926 <xsl:text> 1927 </xsl:text> 1928 <fo:table-column column-number="{@col}" 1929 fotex:column-align="L" column-width="{$len div $total * 100}%" /> 1930 </xsl:if> 1931 </xsl:for-each> 1932 <xsl:text></xsl:text> <!-- this is a newline character --> 1933 </xsl:template> 1934 1935 1936 </xsl:stylesheet>
This is another file. It is taken from the TEI distribution, see Copyright notice in the preceding chapter.
1937 <xsl:stylesheet 1938 xmlns:fotex="http://www.tug.org/fotex" 1939 xmlns:exsl="http://exslt.org/common" 1940 exclude-result-prefixes="exsl" 1941 extension-element-prefixes="exsl" 1942 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 1943 xmlns:fo="http://www.w3.org/1999/XSL/Format" >
The translation of <cell> is <fo:table-cell>. If the cols or rows attributes are at least two, we add corresponding attributes to the result. If the cell, or its parent has a role attribute that says it is a label, we change the font to bold. Other attribute can also be given, see below. Changes for the new DTD: the element is called <td> or <th>. The test for the attribute role has been replaced by the test, is the current element <th>. If the ancestor is not <object>, then border-xx-style is set to solid (where xx is any of `start´, `end´, `before´, and `after´. .
1944 <xsl:template match="cell"> 1945 <fo:table-cell> 1946 <xsl:if test="@cols > 1"> 1947 <xsl:attribute name="number-columns-spanned"> 1948 <xsl:value-of select="@cols"/> 1949 </xsl:attribute> 1950 </xsl:if> 1951 <xsl:if test="@rows > 1"> 1952 <xsl:attribute name="number-rows-spanned"> 1953 <xsl:value-of select="@rows"/> 1954 </xsl:attribute> 1955 </xsl:if> 1956 <xsl:call-template name="cellProperties"/> 1957 <fo:block> 1958 <xsl:choose> 1959 <xsl:when test="@role='label' or parent::row[@role='label']"> 1960 <xsl:attribute name="font-weight">bold</xsl:attribute> 1961 </xsl:when> 1962 </xsl:choose> 1963 <xsl:apply-templates/> 1964 </fo:block> 1965 </fo:table-cell> 1966 </xsl:template>
These are the possible cell properties. If the role is `hi´, we set the background color to `silver´. In the case where the parent table has rend = `frame´, we add a frame around the cell. Only the first row has a border-before, only the last cell in the row has a border-end. Otherwise, we look at the properties of the cell, or of the row. In the new DTD, we should replace <row> by <tr>.
1967 <xsl:template name="cellProperties" > 1968 <xsl:if test="@role='hi'"> 1969 <xsl:attribute name="background-color">silver</xsl:attribute> 1970 </xsl:if> 1971 1972 <xsl:choose> 1973 <xsl:when test="ancestor::table[1][@rend='frame']"> 1974 <xsl:if test="not(parent::row/preceding-sibling::row)"> 1975 <xsl:attribute name="border-before-style">solid</xsl:attribute> 1976 </xsl:if> 1977 <xsl:attribute name="border-after-style">solid</xsl:attribute> 1978 <xsl:if test="not(following-sibling::cell)"> 1979 <xsl:attribute name="border-end-style">solid</xsl:attribute> 1980 </xsl:if> 1981 <xsl:attribute name="border-start-style">solid</xsl:attribute> 1982 </xsl:when> 1983 <xsl:otherwise> 1984 <xsl:if test="@left-border='true'"> 1985 <xsl:attribute name="border-start-style">solid</xsl:attribute> 1986 </xsl:if> 1987 <xsl:if test="@right-border='true'"> 1988 <xsl:attribute name="border-end-style">solid</xsl:attribute> 1989 </xsl:if> 1990 <xsl:if test="ancestor::row/@top-border='true'"> 1991 <xsl:attribute name="border-before-style">solid</xsl:attribute> 1992 </xsl:if> 1993 <xsl:if test="ancestor::row/@bottom-border='true'"> 1994 <xsl:attribute name="border-after-style">solid</xsl:attribute> 1995 </xsl:if> 1996 <xsl:if test="ancestor::row/@bottom-border='true'"> 1997 <xsl:attribute name="border-after-style">solid</xsl:attribute> 1998 </xsl:if> 1999 <xsl:if test="@bottom-border='true'"> 2000 <xsl:attribute name="border-after-style">solid</xsl:attribute> 2001 </xsl:if> 2002 <xsl:if test="@top-border='true'"> 2003 <xsl:attribute name="border-before-style">solid</xsl:attribute> 2004 </xsl:if> 2005 </xsl:otherwise> 2006 </xsl:choose>
If the table is not tight, we add some padding to the cell.
2007 <xsl:if test="not(ancestor::table/@rend='tight')"> 2008 <xsl:attribute name="padding"> 2009 <xsl:value-of select="$tableCellPadding"/> 2010 </xsl:attribute> 2011 </xsl:if>
In the case where the cell has an horizontal alignment property we use it. Otherwise, we look at some database, and try to extract that information. This is not used by the Raweb.
2012 <xsl:choose> 2013 <xsl:when test="@halign"> 2014 <xsl:attribute name="text-align"> 2015 <xsl:value-of select="@halign"/> 2016 </xsl:attribute> 2017 </xsl:when> 2018 <xsl:otherwise> 2019 <xsl:variable name="thiscol"> 2020 <xsl:value-of select="position()"/> 2021 </xsl:variable> 2022 <xsl:variable name="tid">...</xsl:variable> 2023 <xsl:variable name="align">... </xsl:variable> 2024 <xsl:choose> 2025 <xsl:when test="$align='R'"> 2026 <xsl:attribute name="text-align">right</xsl:attribute> 2027 </xsl:when> 2028 <xsl:when test="$align='L'"> 2029 <xsl:attribute name="text-align">left</xsl:attribute> 2030 </xsl:when> 2031 <xsl:when test="$align='C'"> 2032 <xsl:attribute name="text-align">center</xsl:attribute> 2033 </xsl:when> 2034 <xsl:otherwise> 2035 <xsl:if test="not($align='')"> 2036 <xsl:attribute name="text-align"> 2037 <xsl:value-of select="$align"/> 2038 </xsl:attribute> 2039 </xsl:if> 2040 </xsl:otherwise> 2041 </xsl:choose> 2042 </xsl:otherwise> 2043 </xsl:choose> 2044 </xsl:template>
This is the end of the file.
2045 </xsl:stylesheet>
We describe here the file raweb3-param.xsl. This is an adaptation of a file provided by the TEI. We changed the order of items, indicated which parameters are used, or unused.
2046 <xsl:stylesheet 2047 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 2048 xmlns:fo="http://www.w3.org/1999/XSL/Format">
Vertical space before and after a list. The $exampleMargin is used as left and right margins for figure captions.
2049 <xsl:param name="listAbove-1">6pt</xsl:param> 2050 <xsl:param name="listBelow-1">6pt</xsl:param> 2051 <xsl:param name="listAbove-2">4pt</xsl:param> 2052 <xsl:param name="listBelow-2">4pt</xsl:param> 2053 <xsl:param name="listAbove-3">0pt</xsl:param> 2054 <xsl:param name="listBelow-3">0pt</xsl:param> 2055 <xsl:param name="listAbove-4">0pt</xsl:param> 2056 <xsl:param name="listBelow-4">0pt</xsl:param> 2057 <xsl:param name="exampleMargin">12pt</xsl:param>
Quantities use to define list markers. U+2219 is bullet operator (defined to be \ensuremath{\bullet} in ucharacters.sty) is en dash (\textendash), U+002A is asterisk and U+002B is plus sign.
2058 <xsl:param name="bulletOne">∙</xsl:param> 2059 <xsl:param name="bulletTwo">–</xsl:param> 2060 <xsl:param name="bulletThree">*</xsl:param> 2061 <xsl:param name="bulletFour">+</xsl:param>
Page dimensions and margins. The default values are used, except for the right margin (we use the same value as for the left margin). We use a single column. There is a template named hookDefinepagemasters that does nothing. This could be redefined to do some action. Idem for blockStartHook.
2062 <xsl:param name="pageWidth">210mm</xsl:param> 2063 <xsl:param name="pageHeight">297mm</xsl:param> 2064 <xsl:param name="regionAfterExtent">12pt</xsl:param> 2065 <xsl:param name="regionBeforeExtent">12pt</xsl:param> 2066 <xsl:param name="bodyMarginBottom">24pt</xsl:param> 2067 <xsl:param name="bodyMarginTop">24pt</xsl:param> 2068 <xsl:param name="pageMarginTop">75pt</xsl:param> 2069 <xsl:param name="pageMarginBottom">100pt</xsl:param> 2070 <xsl:param name="pageMarginLeft">80pt</xsl:param> 2071 <xsl:param name="pageMarginRight">150pt</xsl:param> 2072 <xsl:param name="columnCount">1</xsl:param> 2073 <xsl:template name="hookDefinepagemasters"/> 2074 <xsl:template name="blockStartHook"/>
Fonts. The body and the headers use Times as font family. The two other fonts are used for typesetting <code> and <ident>, bu these two elements are not created by Tralics.
2075 <xsl:param name="bodyFont">Times Roman</xsl:param> 2076 <xsl:param name="divFont">Times Roman</xsl:param> 2077 <xsl:param name="typewriterFont">Computer-Modern-Typewriter</xsl:param> 2078 <xsl:param name="sansFont">Helvetica</xsl:param>
Font sizes. The main font size is 10pt, the quantity $footnoteSize is used for footnotes (8pt) and $footnotenumSize for footnote markers (is 7pt not too small?). We define a negative indentation for the section titles: $headingOutdent, but a positive paragraph indentation. Note: the first paragraph in a division is not indented.
2079 <xsl:param name="bodyMaster">10</xsl:param> 2080 <xsl:param name="bodySize"> 2081 <xsl:value-of select="$bodyMaster"/><xsl:text>pt</xsl:text> 2082 </xsl:param> 2083 <xsl:param name="footnoteSize">8pt</xsl:param> 2084 <xsl:param name="footnotenumSize">7pt</xsl:param> 2085 <xsl:param name="headingOutdent">-3em</xsl:param> 2086 <xsl:param name="parIndent">1em</xsl:param> 2087 <xsl:param name="parSkip">0pt</xsl:param> 2088 <xsl:param name="parSkipmax">12pt</xsl:param>
The following is used for a section title. We use a bold 18pt font. There is some space before and after: 12pt and 6pt.
2089 <xsl:template name="setupDiv0"> 2090 <xsl:attribute name="font-size">18pt</xsl:attribute> 2091 <xsl:attribute name="text-align">left</xsl:attribute> 2092 <xsl:attribute name="font-weight">bold</xsl:attribute> 2093 <xsl:attribute name="space-after">6pt</xsl:attribute> 2094 <xsl:attribute name="space-before.optimum">12pt</xsl:attribute> 2095 <xsl:attribute name="text-indent"><xsl:value-of select="$headingOutdent"/></xsl:attribute> 2096 </xsl:template>
The following is used for a subsection (module) title. We use a bold 14pt font. There is some space before and after, but less than for a section: 9pt and 3pt.
2097 <xsl:template name="setupDiv1"> 2098 <xsl:attribute name="font-size">14pt</xsl:attribute> 2099 <xsl:attribute name="text-align">left</xsl:attribute> 2100 <xsl:attribute name="font-weight">bold</xsl:attribute> 2101 <xsl:attribute name="space-after">3pt</xsl:attribute> 2102 <xsl:attribute name="space-before.optimum">9pt</xsl:attribute> 2103 <xsl:attribute name="text-indent"><xsl:value-of select="$headingOutdent"/></xsl:attribute> 2104 </xsl:template>
The following is used for a subsubsection title. We use a bold 12pt font. There is some space before and after, but less than for a subsection: 4pt and 2pt.
2105 <xsl:template name="setupDiv2"> 2106 <xsl:attribute name="font-size">12pt</xsl:attribute> 2107 <xsl:attribute name="text-align">left</xsl:attribute> 2108 <xsl:attribute name="font-weight">bold</xsl:attribute> 2109 <xsl:attribute name="font-style">italic</xsl:attribute> 2110 <xsl:attribute name="space-after">2pt</xsl:attribute> 2111 <xsl:attribute name="space-before.optimum">4pt</xsl:attribute> 2112 <xsl:attribute name="text-indent"><xsl:value-of select="$headingOutdent"/></xsl:attribute> 2113 </xsl:template>
The following is used for a paragraph title. We use an italic 10pt font.
2114 <xsl:template name="setupDiv3"> 2115 <xsl:attribute name="font-size">10pt</xsl:attribute> 2116 <xsl:attribute name="text-align">left</xsl:attribute> 2117 <xsl:attribute name="font-style">italic</xsl:attribute> 2118 <xsl:attribute name="space-after">0pt</xsl:attribute> 2119 <xsl:attribute name="space-before.optimum">4pt</xsl:attribute> 2120 <xsl:attribute name="text-indent"><xsl:value-of select="$headingOutdent"/></xsl:attribute> 2121 </xsl:template>
The following is used for a subparagraph title. We use a 10pt normal font.
2122 <xsl:template name="setupDiv4"> 2123 <xsl:attribute name="font-size">10pt</xsl:attribute> 2124 <xsl:attribute name="space-before.optimum">4pt</xsl:attribute> 2125 <xsl:attribute name="text-indent"><xsl:value-of select="$headingOutdent"/></xsl:attribute> 2126 </xsl:template>
This contructs the caption of a figure. It is centered, with some indentation on both sides.
2127 <xsl:template name="figureCaptionstyle"> 2128 <xsl:attribute name="text-align">center</xsl:attribute> 2129 <xsl:attribute name="font-style">italic</xsl:attribute> 2130 <xsl:attribute name="end-indent"> 2131 <xsl:value-of select="$exampleMargin"/> 2132 </xsl:attribute> 2133 <xsl:attribute name="start-indent"> 2134 <xsl:value-of select="$exampleMargin"/> 2135 </xsl:attribute> 2136 </xsl:template>
The template here could be used for table captions. If we compare with figures above, we see that there is some vertical space before and after the caption.
2137 <xsl:param name="tableCaptionAlign">center</xsl:param> 2138 <xsl:param name="spaceAroundTable">8pt</xsl:param> 2139 <xsl:param name="spaceBelowCaption">4pt</xsl:param> 2140 <xsl:param name="tableAlign">center</xsl:param> 2141 <xsl:param name="tableCellPadding">2pt</xsl:param> 2142 2143 <xsl:template name="tableCaptionstyle"> 2144 <xsl:attribute name="text-align">center</xsl:attribute> 2145 <xsl:attribute name="font-style">italic</xsl:attribute> 2146 <xsl:attribute name="end-indent"> 2147 <xsl:value-of select="$exampleMargin"/> 2148 </xsl:attribute> 2149 <xsl:attribute name="start-indent"> 2150 <xsl:value-of select="$exampleMargin"/> 2151 </xsl:attribute> 2152 <xsl:attribute name="space-before"> 2153 <xsl:value-of select="$spaceAroundTable"/> 2154 </xsl:attribute> 2155 <xsl:attribute name="space-after"> 2156 <xsl:value-of select="$spaceBelowCaption"/> 2157 </xsl:attribute> 2158 <xsl:attribute name="keep-with-next">always</xsl:attribute> 2159 </xsl:template>
Parameters for the TOC. What is $tocSize? the font size of the title of the toc? we use 14pt, see above. The two variables $headingNumberSuffix and $tocNumberSuffix explain that we should put a period-plus-space after numbers in the toc and headings. The variable $numberHeadings says that we want something to appear in the TOC, and $numberDepth says that we want in fact everything (in the HTML version, the TOC contains only sections and subsections, for the Pdf, we accept everything. In general it fits on a double page.)
2160 <xsl:param name="tocSize">16pt</xsl:param> 2161 <xsl:param name="div0Tocindent">0in</xsl:param> 2162 <xsl:param name="div1Tocindent">0.25in</xsl:param> 2163 <xsl:param name="div2Tocindent">0.5in</xsl:param> 2164 <xsl:param name="div3Tocindent">0.75in</xsl:param> 2165 <xsl:param name="div4Tocindent">1in</xsl:param> 2166 <xsl:param name="headingNumberSuffix">. </xsl:param> 2167 <xsl:param name="tocNumberSuffix">. </xsl:param> 2168 <xsl:param name="numberHeadings">true</xsl:param> 2169 <xsl:param name="numberDepth">9</xsl:param>
2170 <xsl:param name="listRightMargin">10pt</xsl:param> 2171 <xsl:param name="listNormalIndent">15pt</xsl:param> 2172 <xsl:param name="listLeftGlossIndent">7mm</xsl:param> 2173 <xsl:param name="listLeftGlossInnerIndent">4mm</xsl:param> 2174 <xsl:param name="listLeftIndent">5pt</xsl:param> 2175 <xsl:param name="listItemsep">4pt</xsl:param>
Four names, useful if we decide to switch from English to another language. We use only `Figure´ and `Table´. Note the space at the end; there is no space for the other words.
2176 <xsl:param name="figureWord">Figure </xsl:param> 2177 <xsl:param name="tableWord">Table </xsl:param> 2178 <xsl:param name="appendixWords">Appendix</xsl:param> 2179 <xsl:param name="biblioWords">Bibliography</xsl:param>
2180 <xsl:param name="linkColor">black</xsl:param> 2181 <xsl:param name="pdfBookmarks"></xsl:param>
Not used by the Raweb. The variable $autoScaleFigures is not used: scaling must be explicit. The variable $graphicsPrefix is not used, because we assume that images are in the current directory, and there is no need to add a prefix. The variable $smallSize is not not used (see page ✻ and following how smaller and larger fonts are used). The quantities $authorSize, $dateSize and $titleSize could be used for the title page. In the case of the Raweb, the title page is created by the code on page 3.3.2, this defines fonts and size.
2182 <xsl:param name="autoScaleFigures"></xsl:param> 2183 <xsl:param name="graphicsPrefix"></xsl:param> 2184 <xsl:param name="smallSize"> 2185 <xsl:value-of select="$bodyMaster * 0.9"/><xsl:text>pt</xsl:text> 2186 </xsl:param> 2187 <xsl:param name="authorSize">14pt</xsl:param> 2188 <xsl:param name="dateSize">14pt</xsl:param> 2189 <xsl:param name="titleSize">16pt</xsl:param>
The variable $hyphenate is unused: we always hyphenate. The variable $alignment is unused: we always justify. The $language variable is unused.
2190 <xsl:param name="hyphenate">true</xsl:param> 2191 <xsl:param name="alignment">justify</xsl:param> 2192 <xsl:param name="language">US</xsl:param>
This defines sizes for quantities that are not used here. The quantities $runSize and $runFont are for running heads. We use the default font.
2193 <xsl:param name="runSize">9pt</xsl:param> 2194 <xsl:param name="runFont">sans-serif</xsl:param>
These are unused.
2195 <xsl:param name="flowMarginLeft"></xsl:param> 2196 <xsl:param name="giColor">orange</xsl:param> 2197 <xsl:param name="identColor">blue</xsl:param> 2198 <xsl:param name="activeLinebreaks"></xsl:param> 2199 <xsl:param name="activePagebreaks"></xsl:param> 2200 <xsl:param name="tocFront">true</xsl:param> 2201 <xsl:param name="tocBack">true</xsl:param> 2202 <xsl:param name="tocStartPage">1</xsl:param> 2203 <xsl:param name="exampleSize"> 2204 <xsl:value-of select="$bodyMaster * 0.8"/><xsl:text>pt</xsl:text> 2205 </xsl:param>
2206 <xsl:param name="exampleBefore">4pt</xsl:param> 2207 <xsl:param name="exampleAfter">4pt</xsl:param> 2208 <xsl:param name="OUCS"></xsl:param> 2209 <xsl:param name="titlePage"></xsl:param> 2210 <xsl:param name="divRunningheads"></xsl:param> 2211 <xsl:param name="forcePageMaster"></xsl:param> 2212 <xsl:param name="twoSided">true</xsl:param> 2213 <xsl:param name="frontMulticolumns"></xsl:param> 2214 <xsl:param name="bodyMulticolumns"></xsl:param> 2215 <xsl:param name="backMulticolumns"></xsl:param> 2216 <xsl:param name="sectionHeaders">true</xsl:param> 2217 <xsl:param name="formatFrontpage">i</xsl:param> 2218 <xsl:param name="formatBodypage">1</xsl:param> 2219 <xsl:param name="formatBackpage">1</xsl:param> 2220 <xsl:param name="formatAppendix">A.1.</xsl:param> 2221 <xsl:param name="numberBackHeadings">A.1</xsl:param> 2222 <xsl:param name="numberFrontHeadings">1</xsl:param> 2223 <xsl:param name="captionInlinefigures"></xsl:param> 2224 <xsl:param name="xrefShowTitle"></xsl:param> 2225 <xsl:param name="xrefShowHead"></xsl:param> 2226 <xsl:param name="xrefShowPage"></xsl:param> 2227 <xsl:param name="minimalCrossRef"/> 2228 <xsl:param name="numberHeadingsDepth">9</xsl:param> 2229 <xsl:param name="prenumberedHeadings"></xsl:param> 2230 <xsl:param name="biblSize">16pt</xsl:param> 2231 <xsl:param name="indentBibl">1em</xsl:param> 2232 <xsl:param name="spaceBeforeBibl">4pt</xsl:param> 2233 <xsl:param name="spaceAfterBibl">0pt</xsl:param> 2234 <xsl:param name="inlineTables"></xsl:param> 2235 <xsl:param name="rowAlign">left</xsl:param> 2236 <xsl:param name="makeTableCaption">true</xsl:param> 2237 <xsl:param name="readColSpecFile"></xsl:param>
This is the end of the file.
2238 </xsl:stylesheet>