Moved apache code into a folder to help prepare for packaging where we dont want...
[httpd-crcsyncproxy.git] / apache / docs / manual / style / xsl / language.xsl
blob8ef0b4a0487fc7a9a999bf62abbec898745fbc8b
1 <?xml version="1.0"?>
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
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.
18 -->
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"
27 xmlns="">
29 <xsl:output
30 method="xml"
31 encoding="utf-8"
32 indent="no"
35 <xsl:param name="type" />
36 <xsl:param name="langs" />
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>
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)">
68 <lang>
69 <xsl:value-of select="substring-before(concat($langs, ' '),' ')" />
70 </lang>
71 &lf;
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>
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>
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'" />
125 </xsl:call-template>
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" />
133 <project name="lang-targets">
134 &lf;&lf;
136 <!-- build *-all targets -->
137 <!-- =================== -->
138 <target name="all"
139 description="- builds all HTML files and nroff man pages">
140 <xsl:attribute name="depends">
141 <xsl:for-each select="lang[document(concat('../lang/', .,
142 '.xml'))/language/messages]">
143 <xsl:value-of select="." />
144 <xsl:if test="position() != last()">, </xsl:if>
145 </xsl:for-each>
146 </xsl:attribute>
147 </target>
148 &lf;
150 <target name="zip-all"
151 description="- builds all zip download packages">
152 <xsl:attribute name="depends">
153 <xsl:for-each select="lang[document(concat('../lang/', .,
154 '.xml'))/language/messages]">
155 <xsl:text>zip-</xsl:text>
156 <xsl:value-of select="." />
157 <xsl:if test="position() != last()">, </xsl:if>
158 </xsl:for-each>
159 </xsl:attribute>
160 </target>
161 &lf;
163 <target name="war-all"
164 description="- builds all war download packages">
165 <xsl:attribute name="depends">
166 <xsl:for-each select="lang[document(concat('../lang/', .,
167 '.xml'))/language/messages]">
168 <xsl:text>war-</xsl:text>
169 <xsl:value-of select="." />
170 <xsl:if test="position() != last()">, </xsl:if>
171 </xsl:for-each>
172 </xsl:attribute>
173 </target>
174 &lf;
176 <!-- single language targets -->
177 <!-- ======================= -->
178 <xsl:for-each select="lang">
179 <xsl:sort select="." />
180 <xsl:variable name="file" select="document(concat('../lang/', .,
181 '.xml'))/language" />
183 <xsl:if test="$file/messages">
184 &lf;
185 <xsl:call-template name="head">
186 <xsl:with-param name="text" select="$file/name" />
187 </xsl:call-template>
188 <xsl:call-template name="sep" />
190 <property name="inputext.{.}" value="{$file/source-ext}" />&lf;
191 <property name="outputext.{.}" value="{$file/target-ext}" />&lf;&lf;
193 <target name="{.}" description="- builds {$file/name} HTML files">
194 &lf;
195 <xsl:text> </xsl:text>
196 <html.generic lang="{.}" />&lf;
198 <xsl:if test=". = 'en'">
199 <xsl:text> </xsl:text><runtarget target="man-en" />&lf;
200 </xsl:if>
201 </target>
202 &lf;
204 <target name="-off-{.}" depends="metafiles"
205 unless="-off.{.}.done">&lf;
206 <xsl:text> </xsl:text>
207 <dependencies.offline lang="{.}" style="zip" dir="_off" />&lf;
208 <xsl:text> </xsl:text>
209 <offline.generic lang="{.}" style="zip" dir="_off" />&lf;
210 <xsl:text> </xsl:text>
211 <property name="-off.{.}.done" value="yes" />&lf;
212 </target>
213 &lf;
215 <target name="zip-{.}" depends="-off-{.}"
216 description="- builds the {$file/name} zipped download package">&lf;
217 <xsl:text> </xsl:text>
218 <zip.generic lang="{.}" />&lf;
219 </target>
220 &lf;
222 <target name="war-{.}" depends="-off-{.}"
223 description="- builds the {$file/name} Konqueror Web Archive">&lf;
224 <xsl:text> </xsl:text>
225 <war.generic lang="{.}" />&lf;
226 </target>
227 &lf;
229 <xsl:if test="$file/chm">
230 <target name="chm-{.}"
231 description="- builds the {$file/name} CHM file">&lf;
232 <xsl:text> </xsl:text>
233 <chm.generic lang="{.}" />&lf;
234 </target>
235 &lf;
236 </xsl:if>
238 <xsl:if test="$file/man">
239 <target name="man-{.}"
240 description="- builds the {$file/name} nroff files">&lf;
241 <xsl:text> </xsl:text>
242 <nroff.generic lang="{.}" />&lf;
243 </target>
244 &lf;
245 </xsl:if>
247 <xsl:if test=". = 'en'">
248 <target name="latex-en"
249 description="- builds the English latex file">&lf;
250 <xsl:text> </xsl:text>
251 <latex.generic lang="en" />&lf;
252 </target>
253 &lf;
254 </xsl:if>
255 </xsl:if>
256 </xsl:for-each>
257 &lf;
259 <!-- XML validation -->
260 <!-- ============== -->
261 <xsl:call-template name="head">
262 <xsl:with-param name="text" select="'XML validation.'" />
263 </xsl:call-template>
264 <xsl:call-template name="head">
265 <xsl:with-param name="text" select="'If you get an error during
266 transformation, this task may be useful'" />
267 </xsl:call-template>
268 <xsl:call-template name="head">
269 <xsl:with-param name="text" select="'because it mostly gives you a
270 hint, where you forgot the &lt;/p&gt; ;-)'" />
271 </xsl:call-template>
272 <xsl:call-template name="sep" />
274 <target name="validate-xml" description="- validates all XML source files">
275 &lf;
276 <xsl:text> </xsl:text>
277 <xmlvalidate lenient="false" failonerror="false" warn="true">
278 &lf;
279 <xsl:text> </xsl:text>
280 <xmlcatalog refid="w3c-catalog" />&lf;
281 <xsl:text> </xsl:text>
282 <fileset dir="../">&lf;
283 <xsl:for-each select="lang">
284 <xsl:sort select="." />
286 <xsl:variable name="file" select="document(concat(
287 '../lang/', ., '.xml'))
288 /language" />
289 <xsl:if test="$file/messages">
290 <xsl:text> </xsl:text>
291 <include name="**/*{$file/source-ext}" />&lf;
292 </xsl:if>
293 </xsl:for-each>
294 &lf;
295 <xsl:text> </xsl:text>
296 <patternset refid="excludes" />&lf;
297 <xsl:text> </xsl:text>
298 <patternset refid="scratch" />&lf;
299 <xsl:text> </xsl:text>
300 </fileset>
301 &lf;
302 <xsl:text> </xsl:text>
303 </xmlvalidate>
304 &lf;
305 </target>
306 &lf;&lf;
307 </project>
308 </xsl:template>
311 <!-- ==================================================================== -->
312 <!-- <language-list> -->
313 <!-- generate list of modulelists -->
314 <!-- ==================================================================== -->
315 <xsl:template match="/language-list" mode="modlists">
316 <items>
317 &lf;
318 <xsl:for-each select="lang">
319 <xsl:sort select="." />
321 <xsl:variable name="file" select="document(concat(
322 '../lang/', ., '.xml'))
323 /language" />
324 <item lang="{.}">
325 <xsl:text>../../../mod/allmodules</xsl:text>
326 <xsl:value-of select="$file/source-ext" />
327 </item>
328 &lf;
329 </xsl:for-each>
330 </items>
331 </xsl:template>
333 <!-- ==================================================================== -->
334 <!-- <language-list> -->
335 <!-- generate project description -->
336 <!-- ==================================================================== -->
337 <xsl:template match="/language-list" mode="desc">
339 <xsl:call-template name="copyright" />
341 <description><xsl:text>
342 This build file contains all operations that are necessary for building
343 the Apache httpd documentation. It is called by invoking build.bat (Win32)
344 or build.sh (/bin/sh systems) with a target argument (full list below).
345 For example, if you want to build the Japanese HTML files, type:
347 ./build.sh ja
349 Some targets have additional requirements:
351 * 'metafiles' and 'modulelists' need perl in PATH. (It's checked automatically
352 and skipped if perl is not available)
354 * 'chm-foo' targets need:
355 - the HTML Help compiler in PATH (or modify this build file). The
356 compiler (hhc.exe) is part of the HTML Help Workshop which is freely
357 available and can be downloaded from
358 http://msdn.microsoft.com/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp
359 - The appropriate locale (e.g. Japanese) before invoking hhc.exe. Otherwise
360 the compiler is not able to build the fulltext search index correctly and
361 the TOC may be garbled, too. In particular:
362 </xsl:text>
364 <xsl:for-each select="lang">
365 <xsl:sort select="." />
367 <xsl:variable name="file" select="document(concat('../lang/', .,
368 '.xml'))/language" />
370 <xsl:if test="$file/messages and $file/chm">
371 <xsl:text> + chm-</xsl:text>
372 <xsl:value-of select="." />
373 <xsl:text>: </xsl:text>
374 <xsl:value-of select="normalize-space($file/chm/settings)" />
375 &lf;
376 </xsl:if>
377 </xsl:for-each>
378 &lf;
379 </description>
380 </xsl:template>
383 <!-- ==================================================================== -->
384 <!-- <language> -->
385 <!-- generate language specific xslt -->
386 <!-- ==================================================================== -->
387 <xsl:template match="/language">
389 <xsl:call-template name="copyright" />
391 <xsl:element name="xsl:stylesheet" namespace="&xsl;">
392 <xsl:attribute name="version">1.0</xsl:attribute>
393 &lf;
394 &lf;
396 <xsl:element name="xsl:output">
397 <xsl:attribute name="method">
398 <xsl:choose>
399 <xsl:when test="$type = 'manual' or
400 $type = 'chm' or
401 $type = 'zip'">
402 <xsl:text>xml</xsl:text>
403 </xsl:when>
404 <xsl:when test="$type = 'hhc' or
405 $type = 'hhp' or
406 $type = 'man'">
407 <xsl:text>text</xsl:text>
408 </xsl:when>
409 <xsl:otherwise>
410 <xsl:message terminate="yes">
411 <xsl:text>Unknown style type '</xsl:text>
412 <xsl:value-of select="$type" />
413 <xsl:text>'!</xsl:text>
414 </xsl:message>
415 </xsl:otherwise>
416 </xsl:choose>
417 </xsl:attribute>
418 <xsl:attribute name="encoding">
419 <xsl:choose>
420 <xsl:when test="$type = 'chm' or
421 $type = 'hhc' or
422 $type = 'hhp'">
423 <xsl:value-of select="chm/charset" />
424 </xsl:when>
425 <xsl:when test="$type = 'man'">
426 <xsl:value-of select="man/charset" />
427 </xsl:when>
428 <xsl:otherwise>
429 <xsl:value-of select="charset" />
430 </xsl:otherwise>
431 </xsl:choose>
432 </xsl:attribute>
433 <xsl:attribute name="indent">no</xsl:attribute>
434 <xsl:if test="$type = 'manual' or
435 $type = 'chm' or
436 $type = 'zip'">
437 <xsl:attribute name="doctype-public">
438 <xsl:text>-//W3C//DTD XHTML 1.0 Strict//EN</xsl:text>
439 </xsl:attribute>
440 </xsl:if>
441 <xsl:if test="$type = 'manual'">
442 <xsl:attribute name="doctype-system">
443 <xsl:text>http://www.w3.org/TR/xhtml1/DTD/</xsl:text>
444 <xsl:text>xhtml1-strict.dtd</xsl:text>
445 </xsl:attribute>
446 </xsl:if>
447 <xsl:if test="$type = 'chm' or
448 $type = 'zip'">
449 <xsl:attribute name="omit-xml-declaration">yes</xsl:attribute>
450 </xsl:if>
451 </xsl:element>
452 &lf;&lf;
454 <xsl:comment>
455 <xsl:text> Read the localized messages from the specified </xsl:text>
456 <xsl:text>language file </xsl:text>
457 </xsl:comment>
458 &lf;
460 <xsl:element name="xsl:variable">
461 <xsl:attribute name="name">message</xsl:attribute>
462 <xsl:attribute name="select">
463 <xsl:text>document('</xsl:text>
464 <xsl:if test="$type != 'manual'">../</xsl:if>
465 <xsl:text>lang/</xsl:text>
466 <xsl:value-of select="@id" />
467 <xsl:text>.xml')/language/messages/message</xsl:text>
468 </xsl:attribute>
469 </xsl:element>
470 &lf;
472 <xsl:if test="$type != 'man'">
473 <xsl:element name="xsl:variable">
474 <xsl:attribute name="name">doclang</xsl:attribute>
475 <xsl:value-of select="@id" />
476 </xsl:element>
477 &lf;
478 <xsl:element name="xsl:variable">
479 <xsl:attribute name="name">allmodules</xsl:attribute>
480 <xsl:attribute name="select">
481 <xsl:text>document('</xsl:text>
482 <xsl:if test="$type != 'manual'">../</xsl:if>
483 <xsl:text>xsl/util/allmodules.xml')</xsl:text>
484 <xsl:text>/items/item[@lang=$doclang]</xsl:text>
485 </xsl:attribute>
486 </xsl:element>
487 &lf;
488 </xsl:if>
489 &lf;
491 <xsl:if test="$type != 'man'">
492 <xsl:comment>
493 <xsl:text> some meta information have to be passed to </xsl:text>
494 <xsl:text>the transformation </xsl:text>
495 </xsl:comment>
496 &lf;
497 </xsl:if>
499 <xsl:if test="$type = 'manual' or
500 $type = 'chm' or
501 $type = 'zip' or
502 $type = 'hhc'">
503 <xsl:element name="xsl:variable">
504 <xsl:attribute name="name">output-encoding</xsl:attribute>
505 <xsl:choose>
506 <xsl:when test="$type = 'chm' or
507 $type = 'hhc'">
508 <xsl:value-of select="normalize-space(chm/charset)" />
509 </xsl:when>
510 <xsl:otherwise>
511 <xsl:value-of select="normalize-space(charset)" />
512 </xsl:otherwise>
513 </xsl:choose>
514 </xsl:element>
515 &lf;
516 </xsl:if>
518 <xsl:if test="$type = 'manual' or
519 $type = 'chm' or
520 $type = 'zip'">
521 <xsl:element name="xsl:variable">
522 <xsl:attribute name="name">is-chm</xsl:attribute>
523 <xsl:attribute name="select">
524 <xsl:choose>
525 <xsl:when test="$type = 'chm'">
526 <xsl:text>true()</xsl:text>
527 </xsl:when>
528 <xsl:otherwise>
529 <xsl:text>false()</xsl:text>
530 </xsl:otherwise>
531 </xsl:choose>
532 </xsl:attribute>
533 </xsl:element>
534 &lf;
536 <xsl:element name="xsl:variable">
537 <xsl:attribute name="name">is-zip</xsl:attribute>
538 <xsl:attribute name="select">
539 <xsl:choose>
540 <xsl:when test="$type = 'zip'">
541 <xsl:text>true()</xsl:text>
542 </xsl:when>
543 <xsl:otherwise>
544 <xsl:text>false()</xsl:text>
545 </xsl:otherwise>
546 </xsl:choose>
547 </xsl:attribute>
548 </xsl:element>
549 &lf;&lf;
550 </xsl:if>
552 <xsl:if test="$type = 'hhc'">
553 <xsl:element name="xsl:variable">
554 <xsl:attribute name="name">toc-font</xsl:attribute>
555 <xsl:value-of select="normalize-space(chm/toc-font)" />
556 </xsl:element>
557 &lf;
559 <xsl:element name="xsl:variable">
560 <xsl:attribute name="name">xml-ext</xsl:attribute>
561 <xsl:value-of select="normalize-space(source-ext)" />
562 </xsl:element>
563 &lf;&lf;
564 </xsl:if>
566 <xsl:if test="$type = 'hhp'">
567 <xsl:element name="xsl:variable">
568 <xsl:attribute name="name">hhp-lang</xsl:attribute>
569 <xsl:value-of select="normalize-space(chm/lang)" />
570 </xsl:element>
571 &lf;&lf;
572 </xsl:if>
574 <xsl:comment> Now get the real guts of the stylesheet </xsl:comment>
575 &lf;
577 <xsl:element name="xsl:include">
578 <xsl:attribute name="href">
579 <xsl:choose>
580 <xsl:when test="$type = 'chm' or
581 $type = 'zip'">
582 <xsl:text>../xsl/common.xsl</xsl:text>
583 </xsl:when>
584 <xsl:when test="$type = 'hhc'">
585 <xsl:text>../xsl/hhc.xsl</xsl:text>
586 </xsl:when>
587 <xsl:when test="$type = 'hhp'">
588 <xsl:text>../xsl/hhp.xsl</xsl:text>
589 </xsl:when>
590 <xsl:when test="$type = 'man'">
591 <xsl:text>../xsl/nroff.xsl</xsl:text>
592 </xsl:when>
593 <xsl:otherwise>
594 <xsl:text>xsl/common.xsl</xsl:text>
595 </xsl:otherwise>
596 </xsl:choose>
597 </xsl:attribute>
598 </xsl:element>
599 &lf;&lf;
600 </xsl:element>
602 </xsl:template>
603 <!-- /language -->
606 <xsl:template name="copyright">
607 &lf;
608 <xsl:comment><xsl:text>
609 Licensed to the Apache Software Foundation (ASF) under one or more
610 contributor license agreements. See the NOTICE file distributed with
611 this work for additional information regarding copyright ownership.
612 The ASF licenses this file to You under the Apache License, Version 2.0
613 (the "License"); you may not use this file except in compliance with
614 the License. You may obtain a copy of the License at
616 http://www.apache.org/licenses/LICENSE-2.0
618 Unless required by applicable law or agreed to in writing, software
619 distributed under the License is distributed on an "AS IS" BASIS,
620 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
621 See the License for the specific language governing permissions and
622 limitations under the License.
623 </xsl:text></xsl:comment>
624 &lf;&lf;
625 </xsl:template>
628 <xsl:template name="sepstring">
629 <xsl:text>============================================</xsl:text>
630 <xsl:text>========================</xsl:text>
631 </xsl:template>
634 <xsl:template name="sep">
635 <xsl:comment>
636 <xsl:text> </xsl:text>
637 <xsl:call-template name="sepstring" />
638 <xsl:text> </xsl:text>
639 </xsl:comment>
640 &lf;
641 </xsl:template>
643 <xsl:template name="head">
644 <xsl:param name="text" />
646 <xsl:variable name="s"><xsl:call-template name="sepstring" /></xsl:variable>
647 <xsl:variable name="empty" select="translate($s, '=', ' ')" />
649 <xsl:comment>
650 <xsl:text> </xsl:text>
651 <xsl:value-of select="substring(concat(normalize-space($text), $empty), 1,
652 string-length($empty))" />
653 <xsl:text> </xsl:text>
654 </xsl:comment>
655 &lf;
656 </xsl:template>
658 </xsl:stylesheet>