4 Licensed to the Apache Software Foundation (ASF) under one or more
5 contributor license agreements. See the NOTICE file distributed with
6 this work for additional information regarding copyright ownership.
7 The ASF licenses this file to You under the Apache License, Version 2.0
8 (the "License"); you may not use this file except in compliance with
9 the License. You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
20 <!DOCTYPE xsl:stylesheet [
21 <!ENTITY lf SYSTEM "../xsl/util/lf.xml">
22 <!ENTITY tab SYSTEM "../xsl/util/tab.xml">
24 <!ENTITY ul.start SYSTEM "../xsl/util/ul-start.xml">
25 <!ENTITY ul.end SYSTEM "../xsl/util/ul-end.xml" >
26 <!ENTITY li.start SYSTEM "../xsl/util/li-start.xml">
27 <!ENTITY li.end SYSTEM "../xsl/util/li-end.xml" >
29 <xsl:stylesheet version="1.0"
30 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
34 <!-- WARNING! Do not touch anything, especially the whitespaces [1] -->
35 <!-- unless you know, what you're doing. The HTML help compiler parses -->
36 <!-- the TOC file not really as html instead of line by line and takes -->
37 <!-- care of whitespace indentations etc. -->
39 <!-- [1] Covered by the &lf; and &tab; entities. -->
41 <!-- You have been warned. -->
44 <!-- create nodeset for referencing later -->
45 <xsl:variable name="not-exists" select="document('')/xsl:stylesheet/xsl:template
46 [@name='data']/not-exists/file" />
48 <xsl:template name="data">
49 <!-- documents not converted (yet?). -->
51 <!-- example: <file>developer/API.xml</file> -->
55 <!-- Constants used for case translation -->
56 <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
57 <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
59 <!-- document() works relative to the xsl (!) file -->
60 <xsl:variable name="basedir" select="'../../'"/>
63 <xsl:variable name="icon.document" select="'11'" />
64 <xsl:variable name="icon.document.not-translated" select="'12'" />
65 <xsl:variable name="icon.section" select="'35'" />
66 <xsl:variable name="icon.directive" select="'41'" />
67 <xsl:variable name="icon.commondirective" select="'19'" />
68 <!-- this should not happen. this icon is only displayed within the
69 toc view of the help workshop (it's a question mark): -->
70 <xsl:variable name="icon.no-anchor" select="'9'" />
72 <!-- for module-translatename -->
73 <xsl:include href="../xsl/util/modtrans.xsl"/>
75 <!-- ==================================================================== -->
77 <!-- Create CHM contents file (toc) from sitemap -->
78 <!-- The file is an html style text file (see warning on top) -->
79 <!-- ==================================================================== -->
80 <xsl:template match="/sitemap">
83 <xsl:text><html><head></xsl:text>
84 <xsl:text><title>Apache HTTP Server Documentation</title></xsl:text>
85 <xsl:text></head></xsl:text>&lf;
87 <xsl:text><body></xsl:text>&lf;
89 <!-- toc properties first -->
90 <xsl:text><object type="text/site properties"></xsl:text>&lf;&tab;
91 <!-- XXX: that magic value is still obfuscated. Research needed ... -->
92 <xsl:text><param name="Window Styles" value="0x800027"></xsl:text>&lf;&tab;
93 <xsl:text><param name="Font" value="</xsl:text>
94 <xsl:value-of select="$toc-font" />
95 <xsl:text>"></xsl:text>&lf;
96 <xsl:text></object></xsl:text>&lf;
100 <!-- index page on top. -->
102 <xsl:call-template name="object">
103 <xsl:with-param name="name"
104 select="normalize-space($message[@id='apachehttpserver'])" />
105 <xsl:with-param name="href" select="'index.html'" />
106 <xsl:with-param name="indent" select="'		'" />
110 <!-- iterate over the categories in document order -->
111 <xsl:for-each select="category">
113 <xsl:call-template name="folder">
114 <xsl:with-param name="name" select="normalize-space(title)" />
115 </xsl:call-template>&lf;&tab;
118 <xsl:apply-templates select="page" />
119 <xsl:if test="@id = 'modules'">
120 <xsl:apply-templates select="document($allmodules)/modulefilelist" />
128 <xsl:text></body></html></xsl:text>&lf;
133 <!-- ==================================================================== -->
134 <!-- category/page -->
135 <!-- ==================================================================== -->
136 <xsl:template match="category/page">
137 <xsl:if test="not(starts-with(@href,'http:') or starts-with(@href, 'https:'))">
140 <!-- document entry, if not href attribute, assume it means "sitemap" -->
141 <xsl:call-template name="object">
142 <xsl:with-param name="name">
144 <xsl:when test="@href">
145 <xsl:value-of select="normalize-space(.)" />
148 <xsl:value-of select="normalize-space($message[@id='sitemap'])" />
152 <xsl:with-param name="href">
154 <xsl:when test="not(@href)">
155 <xsl:text>sitemap.html</xsl:text>
157 <xsl:when test="contains(@href, '#')">
158 <xsl:value-of select="substring-before(@href, '#')" />
161 <xsl:value-of select="@href"/>
165 <xsl:with-param name="indent" select="'		'" />
168 <!-- now try to index the sections of the document -->
169 <xsl:apply-templates select="self::page" mode="index" />
174 <!-- /category/page -->
177 <!-- ==================================================================== -->
178 <!-- category/page, mode="index" -->
179 <!-- display all section headings of one page -->
180 <!-- ==================================================================== -->
181 <xsl:template match="category/page" mode="index">
182 <xsl:variable name="href.offline">
184 <xsl:when test="string-length(@href) = 0">
185 <xsl:text>sitemap.html</xsl:text>
188 <xsl:call-template name="helper.href.offline">
189 <xsl:with-param name="href" select="@href" />
194 <xsl:variable name="xml"
195 select="concat(substring-before($href.offline, '.html'), '.xml')" />
197 <xsl:if test="not($xml = $not-exists)">
198 <xsl:variable name="xmlfile">
199 <xsl:variable name="metafile"
200 select="document(document(concat($basedir, $xml))/*/@metafile)
203 <xsl:when test="$metafile/variants/variant[.=$doclang] and not
204 ($metafile/variants/variant[.=$doclang]
205 /@htmlonly = 'yes')">
206 <xsl:value-of select="concat($basedir,
207 substring-before($xml, '.xml'), $xml-ext)" />
210 <xsl:value-of select="concat($basedir, $xml)" />
215 <xsl:variable name="current" select="document($xmlfile)" />
217 <xsl:if test="count($current/*/*[local-name()='section' or
218 local-name()='category']) > 1">
220 &ul.start; &lf;&tab;&tab;&tab;
222 <xsl:for-each select="$current/*/*[local-name()='section' or
223 local-name()='category']">
226 <xsl:call-template name="object">
227 <xsl:with-param name="name" select="normalize-space(title)" />
228 <xsl:with-param name="href">
231 select="concat(substring-before($xml, '.xml'),
235 <xsl:with-param name="indent" select="'				'" />
238 &li.end; &lf;&tab;&tab;
242 </xsl:if> <!-- count() > 1 -->
243 </xsl:if> <!-- xml exists -->
245 <!-- /category/page, "index" -->
248 <!-- ==================================================================== -->
249 <!-- category/modulefilelist -->
250 <!-- process all listed module files -->
251 <!-- ==================================================================== -->
252 <xsl:template match="modulefilelist">
253 <!-- create a module name translation list for sorting -->
254 <xsl:variable name="translist">
255 <xsl:text>-</xsl:text>
257 <xsl:for-each select="modulefile">
258 <xsl:variable name="current"
259 select="document(concat($basedir,'mod/',.))/modulesynopsis" />
261 <xsl:text> </xsl:text>
262 <xsl:value-of select="$current/name"/>
263 <xsl:text> </xsl:text>
264 <xsl:call-template name="module-translatename">
265 <xsl:with-param name="name" select="$current/name"/>
267 <xsl:text> -</xsl:text>
271 <!-- put core and mpm_common on top -->
272 <xsl:call-template name="toc-entry.mpm">
273 <xsl:with-param name="current"
274 select="document(concat($basedir, 'mod/', modulefile[starts-with(.,
275 'core.xml')]/text()))/modulesynopsis" />
276 <xsl:with-param name="name" select="'core'" />
279 <xsl:call-template name="toc-entry.mpm">
280 <xsl:with-param name="current"
281 select="document(concat($basedir, 'mod/', modulefile[starts-with(.,
282 'mpm_common.xml')]/text()))/modulesynopsis" />
283 <xsl:with-param name="name" select="'common'" />
286 <!-- remaining MPMs -->
287 <xsl:for-each select="modulefile">
288 <xsl:sort select="substring-before(substring-after($translist, concat('- ',
289 document(concat($basedir, 'mod/', .))/modulesynopsis/name, ' ')), ' -')" />
291 <xsl:variable name="current"
292 select="document(concat($basedir, 'mod/', .))/modulesynopsis" />
294 <xsl:if test="$current/status='MPM' and not($current/name='mpm_common')">
295 <xsl:call-template name="toc-entry.mpm">
296 <xsl:with-param name="current" select="$current" />
297 <xsl:with-param name="name" select="substring-before(
298 substring-after($translist, concat('- ', $current/name, ' ')),
304 <!-- normal modules -->
305 <xsl:for-each select="modulefile">
306 <xsl:sort select="substring-before(substring-after($translist, concat('- ',
307 document(concat($basedir, 'mod/', .))/modulesynopsis/name, ' ')), ' -')" />
309 <xsl:variable name="current"
310 select="document(concat($basedir, 'mod/', .))/modulesynopsis" />
312 <xsl:if test="not($current/status='MPM') and not($current/status='Core')">
313 <xsl:call-template name="toc-entry.module">
314 <xsl:with-param name="current" select="$current"/>
319 <!-- /category/modulefilelist -->
322 <!-- ==================================================================== -->
323 <!-- toc-entry.mpm -->
324 <!-- create entry (and initiate subsection entries) of an mpm -->
325 <!-- ==================================================================== -->
326 <xsl:template name="toc-entry.mpm">
327 <xsl:param name="current" />
328 <xsl:param name="name" />
332 <xsl:call-template name="object">
333 <xsl:with-param name="name">
335 <xsl:when test="$name='core'">
336 <xsl:value-of select="normalize-space($message[@id='apachecore'])" />
338 <xsl:when test="$name='common'">
339 <xsl:value-of select="normalize-space($message[@id='apachempmcommon'])" />
342 <xsl:value-of select="normalize-space($message[@id='apachempm'])" />
343 <xsl:text> </xsl:text>
344 <xsl:value-of select="$name" />
348 <xsl:with-param name="href"
349 select="concat('mod/', $current/name, '.html')" />
350 <xsl:with-param name="indent" select="'			'" />
353 <xsl:call-template name="sections-and-directives">
354 <xsl:with-param name="current" select="$current" />
359 <!-- /toc-entry.mpm -->
362 <!-- ==================================================================== -->
363 <!-- toc-entry.module -->
364 <!-- create entry (and initiate subsection entries) of a module -->
365 <!-- ==================================================================== -->
366 <xsl:template name="toc-entry.module">
367 <xsl:param name="current"/>
371 <xsl:call-template name="object">
372 <xsl:with-param name="name">
373 <xsl:value-of select="normalize-space($message[@id='apachemodule'])" />
374 <xsl:text> </xsl:text>
375 <xsl:value-of select="$current/name" />
377 <xsl:with-param name="href"
378 select="concat('mod/', $current/name, '.html')" />
379 <xsl:with-param name="indent" select="'			'" />
382 <xsl:call-template name="sections-and-directives">
383 <xsl:with-param name="current" select="$current" />
388 <!-- /toc-entry.module -->
391 <!-- ==================================================================== -->
392 <!-- sections-and-directives -->
393 <!-- process sections and directives of a module file -->
394 <!-- ==================================================================== -->
395 <xsl:template name="sections-and-directives">
396 <xsl:param name="current" />
398 <xsl:if test="count($current/section) > 0 or
399 count($current/directivesynopsis) > 0">
402 &ul.start; &lf;&tab;&tab;
405 <xsl:for-each select="$current/section">
408 <xsl:call-template name="object">
409 <xsl:with-param name="name" select="normalize-space(title)" />
410 <xsl:with-param name="href">
413 select="concat('mod/', $current/name, '.html#', @id)" />
416 <xsl:with-param name="indent" select="'				'" />
419 &li.end; &lf;&tab;&tab;
422 <!-- directives within the current document -->
423 <xsl:for-each select="$current/directivesynopsis[not(@location)]">
424 <xsl:sort select="name" />
427 <xsl:call-template name="object">
428 <xsl:with-param name="name">
429 <xsl:if test="@type='section'"><</xsl:if>
430 <xsl:value-of select="name"/>
431 <xsl:if test="@type='section'">></xsl:if>
433 <xsl:when test="$message[@id='directive']
434 /@replace-space-with">
435 <xsl:value-of select="$message[@id='directive']
436 /@replace-space-with" />
439 <xsl:text> </xsl:text>
442 <xsl:value-of select="normalize-space($message[@id='directive'])" />
444 <xsl:with-param name="href"
445 select="concat('mod/', $current/name, '.html#',
446 translate(name, $uppercase, $lowercase))" />
447 <xsl:with-param name="indent" select="'				'" />
448 <xsl:with-param name="icon" select="$icon.directive" />
451 &li.end; &lf;&tab;&tab;
454 <!-- directives described elsewhere -->
455 <xsl:for-each select="$current/directivesynopsis[@location]">
456 <xsl:sort select="name" />
459 <xsl:call-template name="object">
460 <xsl:with-param name="name">
461 <xsl:if test="@type='section'"><</xsl:if>
462 <xsl:value-of select="name"/>
463 <xsl:if test="@type='section'">></xsl:if>
465 <xsl:when test="$message[@id='directive']
466 /@replace-space-with">
467 <xsl:value-of select="$message[@id='directive']
468 /@replace-space-with" />
471 <xsl:text> </xsl:text>
474 <xsl:value-of select="normalize-space($message[@id='directive'])" />
476 <xsl:with-param name="href"
477 select="concat('mod/', @location, '.html#',
478 translate(name, $uppercase, $lowercase))" />
479 <xsl:with-param name="indent" select="'				'" />
480 <xsl:with-param name="icon" select="$icon.commondirective" />
483 &li.end; &lf;&tab;&tab;
487 </xsl:if> <!-- sections or directives present -->
489 <!-- /sections-and-directives -->
492 <!-- ==================================================================== -->
494 <!-- display an <object> and do some magic to select the right content -->
495 <!-- ==================================================================== -->
496 <xsl:template name="object">
497 <xsl:param name="name" select="'? unknown ?'" />
498 <xsl:param name="href" />
499 <xsl:param name="icon" select="$icon.section" />
500 <xsl:param name="indent" />
502 <xsl:variable name="href.offline">
503 <xsl:call-template name="helper.href.offline">
504 <xsl:with-param name="href" select="$href" />
508 <!-- xml file is expected to have the same basename -->
509 <xsl:variable name="xml"
510 select="concat(substring-before($href.offline, '.html'), '.xml')" />
512 <xsl:text><object type="text/sitemap"></xsl:text>&lf;
513 <xsl:value-of select="$indent" />
515 <xsl:text><param name="Name" value="</xsl:text>
516 <xsl:call-template name="filter.attval">
517 <xsl:with-param name="text" select="$name" />
519 <xsl:text>"></xsl:text>&lf;
520 <xsl:value-of select="$indent" />
522 <xsl:if test="string-length($href.offline) > 0">
523 <xsl:text><param name="Local" value="</xsl:text>
524 <xsl:call-template name="filter.attval">
525 <xsl:with-param name="text" select="$href.offline" />
527 <xsl:text>"></xsl:text>&lf;
528 <xsl:value-of select="$indent" />
531 <xsl:text><param name="ImageNumber" value="</xsl:text>
533 <xsl:when test="string-length($href.offline) > 0">
535 <xsl:when test="contains($href, '#')">
536 <xsl:value-of select="$icon" />
538 <xsl:when test="$doclang='en' or
539 (not($xml = $not-exists) and
540 (document(document(concat($basedir, $xml))
542 /metafile/variants/variant
543 [.=$doclang and not(@htmlonly='yes')]))">
544 <xsl:value-of select="$icon.document" />
547 <xsl:value-of select="$icon.document.not-translated" />
552 <xsl:value-of select="$icon.no-anchor" />
555 <xsl:text>"></xsl:text>&lf;
556 <xsl:value-of select="substring($indent, 2)" />
558 <xsl:text></object></xsl:text>
563 <!-- ==================================================================== -->
565 <!-- ==================================================================== -->
566 <xsl:template name="folder">
567 <xsl:param name="name" select="'? unknown ?'" />
569 <xsl:text><object type="text/sitemap"></xsl:text>&lf;&tab;&tab;
570 <xsl:text><param name="Name" value="</xsl:text>
571 <xsl:call-template name="filter.attval">
572 <xsl:with-param name="text" select="$name" />
574 <xsl:text>"></xsl:text>&lf;&tab;
575 <xsl:text></object></xsl:text>
580 <!-- ==================================================================== -->
581 <!-- helper.href.offline -->
582 <!-- change uri reference to work offline (/ -> /index.html) -->
583 <!-- ==================================================================== -->
584 <xsl:template name="helper.href.offline">
585 <xsl:param name="href" />
588 <xsl:when test="string-length($href) = 0" />
589 <xsl:when test="contains($href, '#') and '/' = substring($href,
590 string-length(substring-before($href, '#')), 1)">
591 <xsl:value-of select="substring-before($href, '#')" />
592 <xsl:text>index.html#</xsl:text>
593 <xsl:value-of select="substring-after($href, '#')" />
595 <xsl:when test="substring($href, string-length($href), 1) = '/'">
596 <xsl:value-of select="$href" />
597 <xsl:text>index.html</xsl:text>
600 <xsl:value-of select="$href" />
604 <!-- /helper.href.offline -->
607 <!-- ==================================================================== -->
608 <!-- filter.attval -->
609 <!-- escape special characters for being valid within an attribute -->
610 <!-- ==================================================================== -->
611 <xsl:template name="filter.attval">
612 <xsl:param name="text" />
615 <xsl:when test="contains($text, '&')">
616 <xsl:call-template name="filter.attval.special">
617 <xsl:with-param name="text" select="substring-before($text, '&')" />
619 <xsl:text>&amp;</xsl:text>
620 <xsl:call-template name="filter.attval">
621 <xsl:with-param name="text" select="substring-after($text, '&')" />
625 <xsl:call-template name="filter.attval.special">
626 <xsl:with-param name="text" select="$text" />
631 <!-- /filter.attval -->
634 <!-- ==================================================================== -->
635 <!-- filter.attval.special -->
636 <!-- accompanying template of filter.attval -->
637 <!-- ==================================================================== -->
638 <xsl:template name="filter.attval.special">
639 <xsl:param name="text" />
642 <xsl:when test="contains($text, '<')">
643 <xsl:value-of select="substring-before($text, '<')" />
644 <xsl:text>&lt;</xsl:text>
645 <xsl:call-template name="filter.attval.special">
646 <xsl:with-param name="text" select="substring-after($text, '<')" />
649 <xsl:when test="contains($text, '>')">
650 <xsl:value-of select="substring-before($text, '>')" />
651 <xsl:text>&gt;</xsl:text>
652 <xsl:call-template name="filter.attval.special">
653 <xsl:with-param name="text" select="substring-after($text, '>')" />
656 <xsl:when test="contains($text, '"')">
657 <xsl:value-of select="substring-before($text, '"')" />
658 <xsl:text>&quot;</xsl:text>
659 <xsl:call-template name="filter.attval.special">
660 <xsl:with-param name="text" select="substring-after($text, '"')" />
664 <xsl:value-of select="$text" />
668 <!-- /filter.attval.special -->