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 "util/lf.xml">
22 <!ENTITY xsl "http://www.w3.org/1999/XSL/Transform">
25 <xsl:stylesheet version="1.0"
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
35 <xsl:param name="type" />
36 <xsl:param name="langs" />
38 <!-- ==================================================================== -->
41 <!-- ==================================================================== -->
42 <xsl:template match="/">
44 <xsl:when test="$type = 'list'">
47 <xsl:call-template name="language-list">
48 <xsl:with-param name="langs" select="normalize-space($langs)" />
54 <xsl:apply-templates select="*" />
60 <!-- ==================================================================== -->
61 <!-- language-list -->
62 <!-- generate language list -->
63 <!-- ==================================================================== -->
64 <xsl:template name="language-list">
65 <xsl:param name="langs" />
67 <xsl:if test="string-length($langs)">
69 <xsl:value-of select="substring-before(concat($langs, ' '),' ')" />
73 <xsl:call-template name="language-list">
74 <xsl:with-param name="langs" select="normalize-space(substring-after(
75 concat($langs, ' '), ' '))" />
81 <!-- ==================================================================== -->
82 <!-- <language-list> -->
83 <!-- generate stuff from language list -->
84 <!-- ==================================================================== -->
85 <xsl:template match="/language-list">
87 <xsl:when test="$type = 'design'">
90 <xsl:for-each select="lang">
91 <xsl:variable name="file" select="document(concat('../lang/', .,
93 <item lang="{$file/@id}" charset="{$file/charset}" >
94 <xsl:value-of select="$file/target-ext" />
101 <xsl:when test="$type = 'targets'">
102 <xsl:apply-templates select="/language-list" mode="targets" />
104 <xsl:when test="$type = 'desc'">
105 <xsl:apply-templates select="/language-list" mode="desc" />
107 <xsl:when test="$type = 'modlists'">
108 <xsl:apply-templates select="/language-list" mode="modlists" />
114 <!-- ==================================================================== -->
115 <!-- <language-list> -->
116 <!-- generate target list from language list -->
117 <!-- ==================================================================== -->
118 <xsl:template match="/language-list" mode="targets">
120 <xsl:call-template name="copyright" />
122 <xsl:call-template name="head">
123 <xsl:with-param name="text" select="'this file contains language specific
124 targets and will be included'" />
127 <xsl:call-template name="head">
128 <xsl:with-param name="text" select="'into build.xml. IT IS AUTOGENERATED.
131 <xsl:call-template name="sep" />
133 <project name="lang-targets">
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" />
144 <!-- build *-all targets -->
145 <!-- =================== -->
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>
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>
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>
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" />
192 <xsl:if test="$file/messages">
194 <xsl:call-template name="head">
195 <xsl:with-param name="text" select="$file/name" />
197 <xsl:call-template name="sep" />
199 <property name="inputext.{.}" value="{$file/source-ext}" />&lf;
200 <property name="outputext.{.}" value="{$file/target-ext}" />&lf;&lf;
202 <target name="{.}" description="- builds {$file/name} HTML files">
204 <xsl:text> </xsl:text>
205 <html.generic lang="{.}" />&lf;
207 <xsl:if test=". = 'en'">
208 <xsl:text> </xsl:text><runtarget target="man-en" />&lf;
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;
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;
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;
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;
247 <xsl:if test="$file/man">
248 <target name="man-{.}"
251 description="- builds the {$file/name} nroff files">&lf;
252 <xsl:text> </xsl:text>
253 <nroff.generic lang="{.}" />&lf;
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;
270 <!-- XML validation -->
271 <!-- ============== -->
272 <xsl:call-template name="head">
273 <xsl:with-param name="text" select="'XML validation.'" />
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'" />
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 </p> ;-)'" />
283 <xsl:call-template name="sep" />
285 <target name="validate-xml" description="- validates all XML source files">
287 <xsl:text> </xsl:text>
288 <xmlvalidate lenient="false" failonerror="true" warn="true">
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="." />
297 <xsl:variable name="file" select="document(concat(
298 '../lang/', ., '.xml'))
300 <xsl:if test="$file/messages">
301 <xsl:text> </xsl:text>
302 <include name="**/*{$file/source-ext}" />&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>
313 <xsl:text> </xsl:text>
322 <!-- ==================================================================== -->
323 <!-- <language-list> -->
324 <!-- generate list of modulelists -->
325 <!-- ==================================================================== -->
326 <xsl:template match="/language-list" mode="modlists">
329 <xsl:for-each select="lang">
330 <xsl:sort select="." />
332 <xsl:variable name="file" select="document(concat(
333 '../lang/', ., '.xml'))
336 <xsl:text>../../../mod/allmodules</xsl:text>
337 <xsl:value-of select="$file/source-ext" />
344 <!-- ==================================================================== -->
345 <!-- <language-list> -->
346 <!-- generate project description -->
347 <!-- ==================================================================== -->
348 <xsl:template match="/language-list" mode="desc">
350 <xsl:call-template name="copyright" />
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:
360 Some targets have additional requirements:
362 * 'metafiles' and 'modulelists' need perl in PATH. (It's checked automatically
363 and skipped if perl is not available)
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:
375 <xsl:for-each select="lang">
376 <xsl:sort select="." />
378 <xsl:variable name="file" select="document(concat('../lang/', .,
379 '.xml'))/language" />
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)" />
394 <!-- ==================================================================== -->
396 <!-- generate language specific xslt -->
397 <!-- ==================================================================== -->
398 <xsl:template match="/language">
400 <xsl:call-template name="copyright" />
402 <xsl:element name="xsl:stylesheet" namespace="&xsl;">
403 <xsl:attribute name="version">1.0</xsl:attribute>
407 <xsl:element name="xsl:output">
408 <xsl:attribute name="method">
410 <xsl:when test="$type = 'manual' or
413 <xsl:text>xml</xsl:text>
415 <xsl:when test="$type = 'hhc' or
418 <xsl:text>text</xsl:text>
421 <xsl:message terminate="yes">
422 <xsl:text>Unknown style type '</xsl:text>
423 <xsl:value-of select="$type" />
424 <xsl:text>'!</xsl:text>
429 <xsl:attribute name="encoding">
431 <xsl:when test="$type = 'chm' or
434 <xsl:value-of select="chm/charset" />
436 <xsl:when test="$type = 'man'">
437 <xsl:value-of select="man/charset" />
440 <xsl:value-of select="charset" />
444 <xsl:attribute name="indent">no</xsl:attribute>
445 <xsl:if test="$type = 'manual' or
448 <xsl:attribute name="doctype-public">
449 <xsl:text>-//W3C//DTD XHTML 1.0 Strict//EN</xsl:text>
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>
458 <xsl:if test="$type = 'chm' or
460 <xsl:attribute name="omit-xml-declaration">yes</xsl:attribute>
466 <xsl:text> Read the localized messages from the specified </xsl:text>
467 <xsl:text>language file </xsl:text>
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>
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" />
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>
502 <xsl:if test="$type != 'man'">
504 <xsl:text> some meta information have to be passed to </xsl:text>
505 <xsl:text>the transformation </xsl:text>
510 <xsl:if test="$type = 'manual' or
514 <xsl:element name="xsl:variable">
515 <xsl:attribute name="name">output-encoding</xsl:attribute>
517 <xsl:when test="$type = 'chm' or
519 <xsl:value-of select="normalize-space(chm/charset)" />
522 <xsl:value-of select="normalize-space(charset)" />
529 <xsl:if test="$type = 'manual' or
532 <xsl:element name="xsl:variable">
533 <xsl:attribute name="name">is-chm</xsl:attribute>
534 <xsl:attribute name="select">
536 <xsl:when test="$type = 'chm'">
537 <xsl:text>true()</xsl:text>
540 <xsl:text>false()</xsl:text>
547 <xsl:element name="xsl:variable">
548 <xsl:attribute name="name">is-zip</xsl:attribute>
549 <xsl:attribute name="select">
551 <xsl:when test="$type = 'zip'">
552 <xsl:text>true()</xsl:text>
555 <xsl:text>false()</xsl:text>
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)" />
570 <xsl:element name="xsl:variable">
571 <xsl:attribute name="name">xml-ext</xsl:attribute>
572 <xsl:value-of select="normalize-space(source-ext)" />
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)" />
585 <xsl:comment> Now get the real guts of the stylesheet </xsl:comment>
588 <xsl:element name="xsl:include">
589 <xsl:attribute name="href">
591 <xsl:when test="$type = 'chm' or
593 <xsl:text>../xsl/common.xsl</xsl:text>
595 <xsl:when test="$type = 'hhc'">
596 <xsl:text>../xsl/hhc.xsl</xsl:text>
598 <xsl:when test="$type = 'hhp'">
599 <xsl:text>../xsl/hhp.xsl</xsl:text>
601 <xsl:when test="$type = 'man'">
602 <xsl:text>../xsl/nroff.xsl</xsl:text>
605 <xsl:text>xsl/common.xsl</xsl:text>
617 <xsl:template name="copyright">
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
627 http://www.apache.org/licenses/LICENSE-2.0
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>
639 <xsl:template name="sepstring">
640 <xsl:text>============================================</xsl:text>
641 <xsl:text>========================</xsl:text>
645 <xsl:template name="sep">
647 <xsl:text> </xsl:text>
648 <xsl:call-template name="sepstring" />
649 <xsl:text> </xsl:text>
654 <xsl:template name="head">
655 <xsl:param name="text" />
657 <xsl:variable name="s"><xsl:call-template name="sepstring" /></xsl:variable>
658 <xsl:variable name="empty" select="translate($s, '=', ' ')" />
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>