1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
|
<?xml version="1.0"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<!-- XSLT stylesheet to convert the Xalan documentation collected in one xml file into a fo file
for use in FOP
TBD: - The faq doesn't show in the content
- check why margin-bottom on the page with properties is too large
- check why keep-next not only doesn't work, but leads to repeating already printed lines
- make lines containing only code look nicer (smaller line height)
- replace bullets in ordered lists with numbers
- correct the hack replacing nbsp with '-'
- handle the links correctly which have been external in the html doc and are now internal
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- to use with document() to get resources.xml -->
<xsl:param name="resourceFile" select="'../../sources/xalan/resources.xml'"/>
<xsl:param name="project" select="Xalan"/>
<xsl:template match ="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- defines page layout -->
<fo:layout-master-set>
<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1.5cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="1.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-name="simple">
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="14pt" >
<xsl:value-of select="$project"/> documentation - p. <fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center">
<xsl:value-of select="$project"/> - an XSL Transformer
</fo:block>
<!-- generates table of contents and puts it into a table -->
<fo:block font-size="14pt"
font-family="sans-serif"
line-height="18pt"
space-after.optimum="10pt"
font-weight="bold"
start-indent="15pt">
Content
</fo:block>
<fo:table>
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="10cm"/>
<fo:table-column column-width="5cm"/>
<fo:table-body font-size="12pt"
line-height="16pt"
font-family="sans-serif">
<fo:table-row>
<fo:table-cell>
<fo:block text-align="end" >
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="end" >
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="end" >
page
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="documentation/chapter">
<fo:table-row>
<fo:table-cell>
<fo:block text-align="end" >
<xsl:number value="position()" format="I"/>.
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start" >
<fo:basic-link color="blue">
<xsl:attribute name="internal-destination">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:value-of select="s1/@title|faqs/@title"/>
</fo:basic-link>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="end">
<fo:page-number-citation ref-id="{@id}"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!--chapter-->
<xsl:template match="chapter">
<fo:block id="{@id}" break-before="page"/>
<xsl:apply-templates/>
</xsl:template>
<!-- s1 -->
<xsl:template match ="s1">
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-before.optimum="15pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
keep-with-next.within-page="always"
text-align="center">
<xsl:attribute name="id">
<xsl:value-of select="translate(@title,' ),-.(','____')"/>
</xsl:attribute>
<xsl:value-of select="@title"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<!-- s2 -->
<xsl:template match ="s2">
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
keep-with-next.within-page="always"
space-before.optimum="15pt"
space-after.optimum="12pt"
text-align="start"
padding-top="3pt"
>
<xsl:value-of select="@title"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<!-- s3 -->
<xsl:template match ="s3">
<fo:block font-size="14pt"
font-family="sans-serif"
line-height="18pt"
keep-with-next.within-page="always"
space-before.optimum="10pt"
space-after.optimum="9pt"
text-align="start"
padding-top="3pt">
<xsl:value-of select="@title"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<!-- p [not(code)] -->
<xsl:template match ="p">
<fo:block font-size="11pt"
font-family="sans-serif"
line-height="13pt"
space-after.optimum="3pt"
space-before.optimum="3pt"
text-align="start">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match ="note">
<fo:block font-size="11pt"
font-family="sans-serif"
font-weight="italic"
line-height="13pt"
space-after.optimum="3pt"
space-before.optimum="3pt"
text-align="start">
Note:
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="anchor">
<fo:block> <!--id="concat(local-name(ancestor::node()="chapter"/@id.,'_',{./@name}"/-->
<xsl:attribute name="id">
<xsl:value-of select="concat(ancestor::chapter/@id,'_',./@name)"/>
</xsl:attribute>
</fo:block>
</xsl:template>
<xsl:template match="table">
<xsl:variable name="colwidth" select="14.5 div count(tr[1]/td)"/>
<fo:table>
<xsl:for-each select="tr[1]/td">
<fo:table-column column-width="{$colwidth}cm"/>
</xsl:for-each>
<fo:table-body font-size="10pt" font-family="sans-serif">
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="tr">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:template>
<xsl:template match="td">
<fo:table-cell>
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:table-cell>
</xsl:template>
<!-- p + code
<xsl:template match ="p[code]">
<fo:block font-size="11pt"
font-family="sans-serif"
line-height="11pt"
space-after.optimum="0pt"
space-before.optimum="0pt"
text-align="start">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
-->
<xsl:template match="img">
<fo:block>
<fo:external-graphic src="file:build/docs/images/{@src}"/>
</fo:block>
</xsl:template>
<!-- faqs -->
<xsl:template match ="faqs">
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-before.optimum="15pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
>
<xsl:attribute name="id">
<xsl:value-of select="translate(.,' ),-.(','____')"/>
</xsl:attribute>
<xsl:value-of select="@title"/>
</fo:block>
<xsl:apply-templates/>
</xsl:template>
<!-- faq -->
<xsl:template match ="faq">
<xsl:apply-templates/>
</xsl:template>
<!-- q in faq -->
<xsl:template match="q">
<fo:block font-size="14pt"
font-family="sans-serif"
line-height="18pt"
keep-with-next.within-page="always"
space-before.optimum="10pt"
space-after.optimum="9pt"
text-align="start"
padding-top="3pt">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- a in faq -->
<xsl:template match ="a">
<xsl:apply-templates/>
</xsl:template>
<!-- jump (links) -->
<xsl:template match ="jump">
<fo:basic-link color="blue">
<xsl:attribute name="external-destination">
<xsl:if test="starts-with(@href,'apidocs')">
<xsl:value-of select="concat('http://xml.apache.org/xalan-j/',@href)"/>
</xsl:if>
<xsl:if test="not(starts-with(@href,'apidocs'))">
<xsl:value-of select="@href"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="./text()"/>
<!--xsl:apply-templates/-->
</fo:basic-link>
</xsl:template>
<xsl:template match="link">
<xsl:if test="string-length(@anchor)=0">
<xsl:if test="string-length(@idref)=0">
<xsl:apply-templates/>
</xsl:if>
<xsl:if test="string-length(@idref)>0">
<fo:basic-link color="blue" internal-destination="{@idref}">
<xsl:value-of select="./text()"/></fo:basic-link>
</xsl:if>
</xsl:if>
<xsl:if test="string-length(@anchor)>0">
<xsl:if test="string-length(@idref)=0">
<fo:basic-link color="blue"
internal-destination="{concat(ancestor::chapter/@id,'_',@anchor)}">
<xsl:value-of select="./text()"/></fo:basic-link>
</xsl:if>
<xsl:if test="string-length(@idref)>0">
<fo:basic-link color="blue" internal-destination="{@idref}_{@anchor}">
<xsl:value-of select="./text()"/></fo:basic-link>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="resource-ref">
<xsl:variable name="xref" select="@idref"/>
<xsl:variable name="href"
select="document($resourceFile)/resources/resource[@id=$xref]/@location"/>
<xsl:variable name="label"
select="document($resourceFile)/resources/resource[@id=$xref]/@title"/>
<fo:basic-link color="blue">
<xsl:attribute name="external-destination">
<xsl:if test="starts-with($href,'apidocs')">
<xsl:value-of select="concat('http://xml.apache.org/xalan-j/',$href)"/>
</xsl:if>
<xsl:if test="not(starts-with($href,'apidocs'))">
<xsl:value-of select="$href"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="$label"/>
<!--xsl:apply-templates/-->
</fo:basic-link>
</xsl:template>
<xsl:template match="human-resource-ref">
<xsl:variable name="resourceFile"
select="./xalan/resources.xml"/>
<xsl:variable name="ref" select="@idref"/>
<xsl:variable name="mailto"
select="document($resourceFile)/resources/human-resource[@id=$ref]/@mailto"/>
<xsl:variable name="name"
select="document($resourceFile)/resources/human-resource[@id=$ref]/@name"/>
<fo:basic-link color="blue" external-destination="mailto:{$mailto}">
<xsl:value-of select="$name"/>
<!--xsl:apply-templates/-->
</fo:basic-link>
</xsl:template>
<xsl:template match ="source">
<fo:block font-size="10pt"
font-family="Courier"
text-align="start"
white-space-collapse="false">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match ="br">
<fo:block></fo:block>
</xsl:template>
<!-- code -->
<xsl:template match ="*/code">
<fo:inline font-size="10pt"
font-family="Courier">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<!-- ul (unordered list) -->
<xsl:template match ="ul">
<fo:list-block start-indent="1cm"
provisional-distance-between-starts="12pt"
font-family="sans-serif"
font-size="11pt"
line-height="11pt">
<xsl:apply-templates/>
</fo:list-block>
</xsl:template>
<!-- ol (ordered list) -->
<xsl:template match ="ol">
<fo:list-block start-indent="1cm"
provisional-distance-between-starts="12pt"
font-family="sans-serif"
font-size="11pt"
line-height="11pt">
<xsl:apply-templates/>
</fo:list-block>
</xsl:template>
<!-- li (list item) in unordered list -->
<xsl:template match ="ul/li">
<fo:list-item>
<fo:list-item-label>
<fo:block><fo:inline font-family="Symbol">·</fo:inline></fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block space-after.optimum="4pt"
text-align="start"
padding-top="3pt">
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
<!-- li (list item) in ordered list -->
<xsl:template match ="ol/li">
<fo:list-item>
<fo:list-item-label>
<fo:block>
<xsl:number level="multiple" count="li" format="1"/>)
</fo:block>
</fo:list-item-label>
<fo:list-item-body>
<fo:block space-after.optimum="4pt"
text-align="start"
padding-top="3pt">
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
<!-- temporary kludge for definition list gloss with label-item pairs ) -->
<xsl:template match="gloss">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="label">
<fo:block font-size="11pt"
font-family="sans-serif"
line-height="13pt"
space-after.optimum="3pt"
space-before.optimum="6pt"
text-align="start">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="item">
<fo:block font-size="11pt"
font-family="sans-serif"
line-height="13pt"
space-after.optimum="6pt"
space-before.optimum="0pt"
margin-left="24pt"
text-align="start">
<xsl:apply-templates/>
<fo:block></fo:block>
</fo:block>
</xsl:template>
<!-- end body -->
</xsl:stylesheet>
|