]> granicus.if.org Git - apache/blob - docs/manual/style/xsl/language.xsl
update bootstrap stylesheets to reflect manual lang-targets changes.
[apache] / docs / manual / style / xsl / language.xsl
1 <?xml version="1.0"?>
2
3 <!--
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
10
11      http://www.apache.org/licenses/LICENSE-2.0
12
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.
18 -->
19
20 <!DOCTYPE xsl:stylesheet [
21     <!ENTITY lf SYSTEM "util/lf.xml">
22     <!ENTITY xsl "http://www.w3.org/1999/XSL/Transform">
23 ]>
24
25 <xsl:stylesheet version="1.0"
26               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27                   xmlns="">
28
29 <xsl:output 
30   method="xml"
31   encoding="utf-8"
32   indent="no"
33 />
34
35 <xsl:param name="type" />
36 <xsl:param name="langs" />
37
38 <!-- ==================================================================== -->
39 <!-- /                                                                    -->
40 <!-- bootstrap                                                            -->
41 <!-- ==================================================================== -->
42 <xsl:template match="/">
43 <xsl:choose>
44 <xsl:when test="$type = 'list'">
45     <language-list>
46     &lf;
47     <xsl:call-template name="language-list">
48         <xsl:with-param name="langs" select="normalize-space($langs)" />
49     </xsl:call-template>
50     </language-list>
51     &lf;
52 </xsl:when>
53 <xsl:otherwise>
54     <xsl:apply-templates select="*" />
55 </xsl:otherwise>
56 </xsl:choose>
57 </xsl:template>
58
59
60 <!-- ==================================================================== -->
61 <!-- language-list                                                        -->
62 <!-- generate language list                                               -->
63 <!-- ==================================================================== -->
64 <xsl:template name="language-list">
65 <xsl:param name="langs" />
66
67 <xsl:if test="string-length($langs)">
68     <lang>
69         <xsl:value-of select="substring-before(concat($langs, ' '),' ')" />
70     </lang>
71     &lf;
72
73     <xsl:call-template name="language-list">
74         <xsl:with-param name="langs" select="normalize-space(substring-after(
75                                              concat($langs, ' '), ' '))" />
76     </xsl:call-template>
77 </xsl:if>
78 </xsl:template>
79
80
81 <!-- ==================================================================== -->
82 <!-- <language-list>                                                      -->
83 <!-- generate stuff from language list                                    -->
84 <!-- ==================================================================== -->
85 <xsl:template match="/language-list">
86 <xsl:choose>
87 <xsl:when test="$type = 'design'">
88     <items>
89     &lf;
90         <xsl:for-each select="lang">
91             <xsl:variable name="file" select="document(concat('../lang/', .,
92                                               '.xml'))/language" />
93             <item lang="{$file/@id}" charset="{$file/charset}" >
94                 <xsl:value-of select="$file/target-ext" />
95             </item>
96             &lf;
97         </xsl:for-each>
98     </items>
99     &lf;
100 </xsl:when>
101 <xsl:when test="$type = 'targets'">
102     <xsl:apply-templates select="/language-list" mode="targets" />
103 </xsl:when>
104 <xsl:when test="$type = 'desc'">
105     <xsl:apply-templates select="/language-list" mode="desc" />
106 </xsl:when>
107 <xsl:when test="$type = 'modlists'">
108     <xsl:apply-templates select="/language-list" mode="modlists" />
109 </xsl:when>
110 </xsl:choose>
111 </xsl:template>
112
113
114 <!-- ==================================================================== -->
115 <!-- <language-list>                                                      -->
116 <!-- generate target list from language list                              -->
117 <!-- ==================================================================== -->
118 <xsl:template match="/language-list" mode="targets">
119
120 <xsl:call-template name="copyright" />
121
122 <xsl:call-template name="head">
123     <xsl:with-param name="text" select="'this file contains language specific
124         targets and will be included'" />
125 </xsl:call-template>
126
127 <xsl:call-template name="head">
128     <xsl:with-param name="text" select="'into build.xml. IT IS AUTOGENERATED.
129         DO NOT TOUCH!'" />
130 </xsl:call-template>
131 <xsl:call-template name="sep" />
132
133 <project name="lang-targets">
134     &lf;&lf;
135
136     <!-- Test for existence of man page directory -->
137     <target name="check-man">
138         <if><not><available file="../../man" type="dir" /></not><then>
139             <property name="skip-man" value="yes" />
140         </then></if>
141     </target>
142     &lf;
143
144     <!-- build *-all targets -->
145     <!-- =================== -->
146     <target name="all"
147             description="- builds all HTML files and nroff man pages">
148         <xsl:attribute name="depends">
149             <xsl:text>validate-xml, </xsl:text>
150             <xsl:for-each select="lang[document(concat('../lang/', .,
151                                        '.xml'))/language/messages]">
152                 <xsl:value-of select="." />
153                 <xsl:if test="position() != last()">, </xsl:if>
154             </xsl:for-each>
155         </xsl:attribute>
156     </target>
157     &lf;
158
159     <target name="zip-all"
160             description="- builds all zip download packages">
161         <xsl:attribute name="depends">
162             <xsl:for-each select="lang[document(concat('../lang/', .,
163                                        '.xml'))/language/messages]">
164                 <xsl:text>zip-</xsl:text>
165                 <xsl:value-of select="." />
166                 <xsl:if test="position() != last()">, </xsl:if>
167             </xsl:for-each>
168         </xsl:attribute>
169     </target>
170     &lf;
171
172     <target name="war-all"
173             description="- builds all war download packages">
174         <xsl:attribute name="depends">
175             <xsl:for-each select="lang[document(concat('../lang/', .,
176                                        '.xml'))/language/messages]">
177                 <xsl:text>war-</xsl:text>
178                 <xsl:value-of select="." />
179                 <xsl:if test="position() != last()">, </xsl:if>
180             </xsl:for-each>
181         </xsl:attribute>
182     </target>
183     &lf;
184
185     <!-- single language targets -->
186     <!-- ======================= -->
187     <xsl:for-each select="lang">
188     <xsl:sort select="." />
189         <xsl:variable name="file" select="document(concat('../lang/', .,
190                                                    '.xml'))/language" />
191
192         <xsl:if test="$file/messages">
193             &lf;
194             <xsl:call-template name="head">
195                 <xsl:with-param name="text" select="$file/name" />
196             </xsl:call-template>
197             <xsl:call-template name="sep" />
198
199             <property name="inputext.{.}" value="{$file/source-ext}" />&lf;
200             <property name="outputext.{.}" value="{$file/target-ext}" />&lf;&lf;
201
202             <target name="{.}" description="- builds {$file/name} HTML files">
203                 &lf;
204                 <xsl:text>    </xsl:text>
205                 <html.generic lang="{.}" />&lf;
206
207                 <xsl:if test=". = 'en'">
208                     <xsl:text>    </xsl:text><runtarget target="man-en" />&lf;
209                 </xsl:if>
210             </target>
211             &lf;
212
213             <target name="-off-{.}" depends="metafiles"
214                   unless="-off.{.}.done">&lf;
215                 <xsl:text>    </xsl:text>
216                 <dependencies.offline lang="{.}" style="zip" dir="_off" />&lf;
217                 <xsl:text>    </xsl:text>
218                 <offline.generic lang="{.}" style="zip" dir="_off" />&lf;
219                 <xsl:text>    </xsl:text>
220                 <property name="-off.{.}.done" value="yes" />&lf;
221             </target>
222             &lf;
223
224             <target name="zip-{.}" depends="-off-{.}"
225                     description="- builds the {$file/name} zipped download package">&lf;
226                 <xsl:text>    </xsl:text>
227                 <zip.generic lang="{.}" />&lf;
228             </target>
229             &lf;
230
231             <target name="war-{.}" depends="-off-{.}"
232                     description="- builds the {$file/name} Konqueror Web Archive">&lf;
233                 <xsl:text>    </xsl:text>
234                 <war.generic lang="{.}" />&lf;
235             </target>
236             &lf;
237
238             <xsl:if test="$file/chm">
239                 <target name="chm-{.}"
240                         description="- builds the {$file/name} CHM file">&lf;
241                     <xsl:text>    </xsl:text>
242                     <chm.generic lang="{.}" />&lf;
243                 </target>
244                 &lf;
245             </xsl:if>
246
247             <xsl:if test="$file/man">
248                 <target name="man-{.}"
249                         depends="check-man"
250                         unless="skip-man"
251                         description="- builds the {$file/name} nroff files">&lf;
252                     <xsl:text>    </xsl:text>
253                     <nroff.generic lang="{.}" />&lf;
254                 </target>
255                 &lf;
256             </xsl:if>
257
258             <xsl:if test=". = 'en'">
259                 <target name="latex-en"
260                         description="- builds the English latex file">&lf;
261                     <xsl:text>    </xsl:text>
262                     <latex.generic lang="en" />&lf;
263                 </target>
264                 &lf;
265             </xsl:if>
266         </xsl:if>
267     </xsl:for-each>
268     &lf;
269
270     <!-- XML validation -->
271     <!-- ============== -->
272     <xsl:call-template name="head">
273         <xsl:with-param name="text" select="'XML validation.'" />
274     </xsl:call-template>
275     <xsl:call-template name="head">
276         <xsl:with-param name="text" select="'If you get an error during
277             transformation, this task may be useful'" />
278     </xsl:call-template>
279     <xsl:call-template name="head">
280         <xsl:with-param name="text" select="'because it mostly gives you a
281             hint, where you forgot the &lt;/p&gt; ;-)'" />
282     </xsl:call-template>
283     <xsl:call-template name="sep" />
284
285     <target name="validate-xml" description="- validates all XML source files">
286         &lf;
287         <xsl:text>    </xsl:text>
288         <xmlvalidate lenient="false" failonerror="true" warn="true">
289             &lf;
290             <xsl:text>        </xsl:text>
291             <xmlcatalog refid="w3c-catalog" />&lf;
292             <xsl:text>        </xsl:text>
293             <fileset dir="../">&lf;
294                 <xsl:for-each select="lang">
295                 <xsl:sort select="." />
296
297                     <xsl:variable name="file" select="document(concat(
298                                                       '../lang/', ., '.xml'))
299                                                       /language" />
300                     <xsl:if test="$file/messages">
301                         <xsl:text>            </xsl:text>
302                         <include name="**/*{$file/source-ext}" />&lf;
303                     </xsl:if>
304                 </xsl:for-each>
305                 &lf;
306                 <xsl:text>            </xsl:text>
307                 <patternset refid="excludes" />&lf;
308                 <xsl:text>            </xsl:text>
309                 <patternset refid="scratch" />&lf;
310             <xsl:text>        </xsl:text>
311             </fileset>
312             &lf;
313         <xsl:text>    </xsl:text>
314         </xmlvalidate>
315         &lf;
316     </target>
317     &lf;&lf;
318 </project>
319 </xsl:template>
320
321
322 <!-- ==================================================================== -->
323 <!-- <language-list>                                                      -->
324 <!-- generate list of modulelists                                         -->
325 <!-- ==================================================================== -->
326 <xsl:template match="/language-list" mode="modlists">
327 <items>
328     &lf;
329     <xsl:for-each select="lang">
330     <xsl:sort select="." />
331
332         <xsl:variable name="file" select="document(concat(
333                                           '../lang/', ., '.xml'))
334                                           /language" />
335         <item lang="{.}">
336             <xsl:text>../../../mod/allmodules</xsl:text>
337             <xsl:value-of select="$file/source-ext" />
338         </item>
339         &lf;
340     </xsl:for-each>
341 </items>
342 </xsl:template>
343
344 <!-- ==================================================================== -->
345 <!-- <language-list>                                                      -->
346 <!-- generate project description                                         -->
347 <!-- ==================================================================== -->
348 <xsl:template match="/language-list" mode="desc">
349
350 <xsl:call-template name="copyright" />
351
352 <description><xsl:text>
353 This build file contains all operations that are necessary for building
354 the Apache httpd documentation. It is called by invoking build.bat (Win32)
355 or build.sh (/bin/sh systems) with a target argument (full list below).
356 For example, if you want to build the Japanese HTML files, type:
357
358   ./build.sh ja
359
360 Some targets have additional requirements:
361
362 * 'metafiles' and 'modulelists' need perl in PATH. (It's checked automatically
363   and skipped if perl is not available)
364
365 * 'chm-foo' targets need:
366   - the HTML Help compiler in PATH (or modify this build file). The
367     compiler (hhc.exe) is part of the HTML Help Workshop which is freely
368     available and can be downloaded from
369     http://msdn.microsoft.com/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp
370   - The appropriate locale (e.g. Japanese) before invoking hhc.exe. Otherwise
371     the compiler is not able to build the fulltext search index correctly and
372     the TOC may be garbled, too. In particular:
373 </xsl:text>
374
375     <xsl:for-each select="lang">
376     <xsl:sort select="." />
377
378         <xsl:variable name="file" select="document(concat('../lang/', .,
379                                           '.xml'))/language" />
380
381         <xsl:if test="$file/messages and $file/chm">
382             <xsl:text>    + chm-</xsl:text>
383             <xsl:value-of select="." />
384             <xsl:text>: </xsl:text>
385             <xsl:value-of select="normalize-space($file/chm/settings)" />
386             &lf;
387         </xsl:if>
388     </xsl:for-each>
389     &lf;
390 </description>
391 </xsl:template>
392
393
394 <!-- ==================================================================== -->
395 <!-- <language>                                                           -->
396 <!-- generate language specific xslt                                      -->
397 <!-- ==================================================================== -->
398 <xsl:template match="/language">
399
400 <xsl:call-template name="copyright" />
401
402 <xsl:element name="xsl:stylesheet" namespace="&xsl;">
403     <xsl:attribute name="version">1.0</xsl:attribute>
404     &lf;
405     &lf;
406
407     <xsl:element name="xsl:output">
408         <xsl:attribute name="method">
409             <xsl:choose>
410             <xsl:when test="$type = 'manual' or
411                             $type = 'chm' or
412                             $type = 'zip'">
413                 <xsl:text>xml</xsl:text>
414             </xsl:when>
415             <xsl:when test="$type = 'hhc' or
416                             $type = 'hhp' or
417                             $type = 'man'">
418                 <xsl:text>text</xsl:text>
419             </xsl:when>
420             <xsl:otherwise>
421                 <xsl:message terminate="yes">
422                     <xsl:text>Unknown style type '</xsl:text>
423                     <xsl:value-of select="$type" />
424                     <xsl:text>'!</xsl:text>
425                 </xsl:message>
426             </xsl:otherwise>
427             </xsl:choose>
428         </xsl:attribute>
429         <xsl:attribute name="encoding">
430             <xsl:choose>
431             <xsl:when test="$type = 'chm' or
432                             $type = 'hhc' or
433                             $type = 'hhp'">
434                 <xsl:value-of select="chm/charset" />
435             </xsl:when>
436             <xsl:when test="$type = 'man'">
437                 <xsl:value-of select="man/charset" />
438             </xsl:when>
439             <xsl:otherwise>
440                 <xsl:value-of select="charset" />
441             </xsl:otherwise>
442             </xsl:choose>
443         </xsl:attribute>
444         <xsl:attribute name="indent">no</xsl:attribute>
445         <xsl:if test="$type = 'manual' or
446                       $type = 'chm' or
447                       $type = 'zip'">
448             <xsl:attribute name="doctype-public">
449                 <xsl:text>-//W3C//DTD XHTML 1.0 Strict//EN</xsl:text>
450             </xsl:attribute>
451         </xsl:if>
452         <xsl:if test="$type = 'manual'">
453             <xsl:attribute name="doctype-system">
454                 <xsl:text>http://www.w3.org/TR/xhtml1/DTD/</xsl:text>
455                 <xsl:text>xhtml1-strict.dtd</xsl:text>
456             </xsl:attribute>
457         </xsl:if>
458         <xsl:if test="$type = 'chm' or
459                       $type = 'zip'">
460             <xsl:attribute name="omit-xml-declaration">yes</xsl:attribute>
461         </xsl:if>
462     </xsl:element>
463     &lf;&lf;
464
465     <xsl:comment>
466         <xsl:text> Read the localized messages from the specified </xsl:text>
467         <xsl:text>language file </xsl:text>
468     </xsl:comment>
469     &lf;
470
471     <xsl:element name="xsl:variable">
472         <xsl:attribute name="name">message</xsl:attribute>
473         <xsl:attribute name="select">
474             <xsl:text>document('</xsl:text>
475             <xsl:if test="$type != 'manual'">../</xsl:if>
476             <xsl:text>lang/</xsl:text>
477             <xsl:value-of select="@id" />
478             <xsl:text>.xml')/language/messages/message</xsl:text>
479         </xsl:attribute>
480     </xsl:element>
481     &lf;
482
483     <xsl:if test="$type != 'man'">
484         <xsl:element name="xsl:variable">
485             <xsl:attribute name="name">doclang</xsl:attribute>
486             <xsl:value-of select="@id" />
487         </xsl:element>
488         &lf;
489         <xsl:element name="xsl:variable">
490             <xsl:attribute name="name">allmodules</xsl:attribute>
491             <xsl:attribute name="select">
492                 <xsl:text>document('</xsl:text>
493                 <xsl:if test="$type != 'manual'">../</xsl:if>
494                 <xsl:text>xsl/util/allmodules.xml')</xsl:text>
495                 <xsl:text>/items/item[@lang=$doclang]</xsl:text>
496             </xsl:attribute>
497         </xsl:element>
498         &lf;
499     </xsl:if>
500     &lf;
501
502     <xsl:if test="$type != 'man'">
503         <xsl:comment>
504             <xsl:text> some meta information have to be passed to </xsl:text>
505             <xsl:text>the transformation </xsl:text>
506         </xsl:comment>
507         &lf;
508     </xsl:if>
509
510     <xsl:if test="$type = 'manual' or
511                   $type = 'chm' or
512                   $type = 'zip' or
513                   $type = 'hhc'">
514         <xsl:element name="xsl:variable">
515             <xsl:attribute name="name">output-encoding</xsl:attribute>
516             <xsl:choose>
517             <xsl:when test="$type = 'chm' or
518                              $type = 'hhc'">
519                 <xsl:value-of select="normalize-space(chm/charset)" />
520             </xsl:when>
521             <xsl:otherwise>
522                 <xsl:value-of select="normalize-space(charset)" />
523             </xsl:otherwise>
524             </xsl:choose>
525         </xsl:element>
526         &lf;
527     </xsl:if>
528
529     <xsl:if test="$type = 'manual' or
530                   $type = 'chm' or
531                   $type = 'zip'">
532         <xsl:element name="xsl:variable">
533             <xsl:attribute name="name">is-chm</xsl:attribute>
534             <xsl:attribute name="select">
535                 <xsl:choose>
536                 <xsl:when test="$type = 'chm'">
537                     <xsl:text>true()</xsl:text>
538                 </xsl:when>
539                 <xsl:otherwise>
540                     <xsl:text>false()</xsl:text>
541                 </xsl:otherwise>
542                 </xsl:choose>
543             </xsl:attribute>
544         </xsl:element>
545         &lf;
546
547         <xsl:element name="xsl:variable">
548             <xsl:attribute name="name">is-zip</xsl:attribute>
549             <xsl:attribute name="select">
550                 <xsl:choose>
551                 <xsl:when test="$type = 'zip'">
552                     <xsl:text>true()</xsl:text>
553                 </xsl:when>
554                 <xsl:otherwise>
555                     <xsl:text>false()</xsl:text>
556                 </xsl:otherwise>
557                 </xsl:choose>
558             </xsl:attribute>
559         </xsl:element>
560         &lf;&lf;
561     </xsl:if>
562
563     <xsl:if test="$type = 'hhc'">
564         <xsl:element name="xsl:variable">
565             <xsl:attribute name="name">toc-font</xsl:attribute>
566             <xsl:value-of select="normalize-space(chm/toc-font)" />
567         </xsl:element>
568         &lf;
569
570         <xsl:element name="xsl:variable">
571             <xsl:attribute name="name">xml-ext</xsl:attribute>
572             <xsl:value-of select="normalize-space(source-ext)" />
573         </xsl:element>
574         &lf;&lf;
575     </xsl:if>
576
577     <xsl:if test="$type = 'hhp'">
578         <xsl:element name="xsl:variable">
579             <xsl:attribute name="name">hhp-lang</xsl:attribute>
580             <xsl:value-of select="normalize-space(chm/lang)" />
581         </xsl:element>
582         &lf;&lf;
583     </xsl:if>
584
585     <xsl:comment> Now get the real guts of the stylesheet </xsl:comment>
586     &lf;
587
588     <xsl:element name="xsl:include">
589         <xsl:attribute name="href">
590             <xsl:choose>
591             <xsl:when test="$type = 'chm' or
592                             $type = 'zip'">
593                 <xsl:text>../xsl/common.xsl</xsl:text>
594             </xsl:when>
595             <xsl:when test="$type = 'hhc'">
596                 <xsl:text>../xsl/hhc.xsl</xsl:text>
597             </xsl:when>
598             <xsl:when test="$type = 'hhp'">
599                 <xsl:text>../xsl/hhp.xsl</xsl:text>
600             </xsl:when>
601             <xsl:when test="$type = 'man'">
602                 <xsl:text>../xsl/nroff.xsl</xsl:text>
603             </xsl:when>
604             <xsl:otherwise>
605                 <xsl:text>xsl/common.xsl</xsl:text>
606             </xsl:otherwise>
607             </xsl:choose>
608         </xsl:attribute>
609     </xsl:element>
610     &lf;&lf;
611 </xsl:element>
612
613 </xsl:template>
614 <!-- /language -->
615
616
617 <xsl:template name="copyright">
618 &lf;
619 <xsl:comment><xsl:text>
620  Licensed to the Apache Software Foundation (ASF) under one or more
621  contributor license agreements.  See the NOTICE file distributed with
622  this work for additional information regarding copyright ownership.
623  The ASF licenses this file to You under the Apache License, Version 2.0
624  (the "License"); you may not use this file except in compliance with
625  the License.  You may obtain a copy of the License at
626
627      http://www.apache.org/licenses/LICENSE-2.0
628
629  Unless required by applicable law or agreed to in writing, software
630  distributed under the License is distributed on an "AS IS" BASIS,
631  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
632  See the License for the specific language governing permissions and
633  limitations under the License.
634 </xsl:text></xsl:comment>
635 &lf;&lf;
636 </xsl:template>
637
638
639 <xsl:template name="sepstring">
640 <xsl:text>============================================</xsl:text>
641 <xsl:text>========================</xsl:text>
642 </xsl:template>
643
644
645 <xsl:template name="sep">
646 <xsl:comment>
647     <xsl:text> </xsl:text>
648     <xsl:call-template name="sepstring" />
649     <xsl:text> </xsl:text>
650 </xsl:comment>
651 &lf;
652 </xsl:template>
653
654 <xsl:template name="head">
655 <xsl:param name="text" />
656
657 <xsl:variable name="s"><xsl:call-template name="sepstring" /></xsl:variable>
658 <xsl:variable name="empty" select="translate($s, '=', ' ')" />
659
660 <xsl:comment>
661     <xsl:text> </xsl:text>
662     <xsl:value-of select="substring(concat(normalize-space($text), $empty), 1,
663                                     string-length($empty))" />
664     <xsl:text> </xsl:text>
665 </xsl:comment>
666 &lf;
667 </xsl:template>
668
669 </xsl:stylesheet>