language.xsl revision db878466c5e95073429dda0bdd001f45e9486e16
<?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
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.
-->
<!DOCTYPE xsl:stylesheet [
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="">
<xsl:output
method="xml"
encoding="utf-8"
indent="no"
/>
<xsl:param name="type" />
<xsl:param name="langs" />
<!-- ==================================================================== -->
<!-- / -->
<!-- bootstrap -->
<!-- ==================================================================== -->
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$type = 'list'">
<language-list>
&lf;
<xsl:call-template name="language-list">
<xsl:with-param name="langs" select="normalize-space($langs)" />
</xsl:call-template>
</language-list>
&lf;
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
<!-- language-list -->
<!-- generate language list -->
<!-- ==================================================================== -->
<xsl:template name="language-list">
<xsl:param name="langs" />
<xsl:if test="string-length($langs)">
<lang>
<xsl:value-of select="substring-before(concat($langs, ' '),' ')" />
</lang>
&lf;
<xsl:call-template name="language-list">
<xsl:with-param name="langs" select="normalize-space(substring-after(
concat($langs, ' '), ' '))" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- ==================================================================== -->
<!-- <language-list> -->
<!-- generate stuff from language list -->
<!-- ==================================================================== -->
<xsl:template match="/language-list">
<xsl:choose>
<xsl:when test="$type = 'design'">
<items>
&lf;
<xsl:for-each select="lang">
'.xml'))/language" />
</item>
&lf;
</xsl:for-each>
</items>
&lf;
</xsl:when>
<xsl:when test="$type = 'targets'">
<xsl:apply-templates select="/language-list" mode="targets" />
</xsl:when>
<xsl:when test="$type = 'desc'">
<xsl:apply-templates select="/language-list" mode="desc" />
</xsl:when>
<xsl:when test="$type = 'modlists'">
<xsl:apply-templates select="/language-list" mode="modlists" />
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
<!-- <language-list> -->
<!-- generate target list from language list -->
<!-- ==================================================================== -->
<xsl:template match="/language-list" mode="targets">
<xsl:call-template name="copyright" />
<xsl:call-template name="head">
<xsl:with-param name="text" select="'this file contains language specific
targets and will be included'" />
</xsl:call-template>
<xsl:call-template name="head">
DO NOT TOUCH!'" />
</xsl:call-template>
<xsl:call-template name="sep" />
<project name="lang-targets">
&lf;&lf;
<!-- build *-all targets -->
<!-- =================== -->
<target name="all"
description="- builds all HTML files and nroff man pages">
<xsl:attribute name="depends">
<xsl:value-of select="." />
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:attribute>
</target>
&lf;
<target name="zip-all"
description="- builds all zip download packages">
<xsl:attribute name="depends">
<xsl:text>zip-</xsl:text>
<xsl:value-of select="." />
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:attribute>
</target>
&lf;
<target name="war-all"
description="- builds all war download packages">
<xsl:attribute name="depends">
<xsl:text>war-</xsl:text>
<xsl:value-of select="." />
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:attribute>
</target>
&lf;
<!-- single language targets -->
<!-- ======================= -->
<xsl:for-each select="lang">
<xsl:sort select="." />
'.xml'))/language" />
&lf;
<xsl:call-template name="head">
</xsl:call-template>
<xsl:call-template name="sep" />
&lf;
<xsl:text> </xsl:text>
<html.generic lang="{.}" />&lf;
<xsl:if test=". = 'en'">
<xsl:text> </xsl:text><runtarget target="man-en" />&lf;
</xsl:if>
</target>
&lf;
<target name="-off-{.}" depends="metafiles"
unless="-off.{.}.done">&lf;
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
<property name="-off.{.}.done" value="yes" />&lf;
</target>
&lf;
<target name="zip-{.}" depends="-off-{.}"
<xsl:text> </xsl:text>
<zip.generic lang="{.}" />&lf;
</target>
&lf;
<target name="war-{.}" depends="-off-{.}"
<xsl:text> </xsl:text>
<war.generic lang="{.}" />&lf;
</target>
&lf;
<target name="chm-{.}"
<xsl:text> </xsl:text>
<chm.generic lang="{.}" />&lf;
</target>
&lf;
</xsl:if>
<target name="man-{.}"
<xsl:text> </xsl:text>
<nroff.generic lang="{.}" />&lf;
</target>
&lf;
</xsl:if>
<xsl:if test=". = 'en'">
<target name="latex-en"
description="- builds the English latex file">&lf;
<xsl:text> </xsl:text>
<latex.generic lang="en" />&lf;
</target>
&lf;
</xsl:if>
</xsl:if>
</xsl:for-each>
&lf;
<!-- XML validation -->
<!-- ============== -->
<xsl:call-template name="head">
<xsl:with-param name="text" select="'XML validation.'" />
</xsl:call-template>
<xsl:call-template name="head">
<xsl:with-param name="text" select="'If you get an error during
transformation, this task may be useful'" />
</xsl:call-template>
<xsl:call-template name="head">
<xsl:with-param name="text" select="'because it mostly gives you a
hint, where you forgot the </p> ;-)'" />
</xsl:call-template>
<xsl:call-template name="sep" />
<target name="validate-xml" description="- validates all XML source files">
&lf;
<xsl:text> </xsl:text>
<xmlvalidate lenient="false" failonerror="false" warn="true">
&lf;
<xsl:text> </xsl:text>
<xmlcatalog refid="w3c-catalog" />&lf;
<xsl:text> </xsl:text>
<fileset dir="../">&lf;
<xsl:for-each select="lang">
<xsl:sort select="." />
<xsl:variable name="file" select="document(concat(
'/lang/', ., '.xml'))
/language" />
<xsl:text> </xsl:text>
<include name="**/*{$file/source-ext}" />&lf;
</xsl:if>
</xsl:for-each>
&lf;
<xsl:text> </xsl:text>
<patternset refid="excludes" />&lf;
<xsl:text> </xsl:text>
<patternset refid="scratch" />&lf;
<xsl:text> </xsl:text>
</fileset>
&lf;
<xsl:text> </xsl:text>
</xmlvalidate>
&lf;
</target>
&lf;&lf;
</project>
</xsl:template>
<!-- ==================================================================== -->
<!-- <language-list> -->
<!-- generate list of modulelists -->
<!-- ==================================================================== -->
<xsl:template match="/language-list" mode="modlists">
<items>
&lf;
<xsl:for-each select="lang">
<xsl:sort select="." />
<xsl:variable name="file" select="document(concat(
'/lang/', ., '.xml'))
/language" />
<item lang="{.}">
</item>
&lf;
</xsl:for-each>
</items>
</xsl:template>
<!-- ==================================================================== -->
<!-- <language-list> -->
<!-- generate project description -->
<!-- ==================================================================== -->
<xsl:template match="/language-list" mode="desc">
<xsl:call-template name="copyright" />
<description><xsl:text>
This build file contains all operations that are necessary for building
the Apache httpd documentation. It is called by invoking build.bat (Win32)
For example, if you want to build the Japanese HTML files, type:
/build.sh ja
Some targets have additional requirements:
* 'metafiles' and 'modulelists' need perl in PATH. (It's checked automatically
and skipped if perl is not available)
* 'chm-foo' targets need:
- the HTML Help compiler in PATH (or modify this build file). The
compiler (hhc.exe) is part of the HTML Help Workshop which is freely
available and can be downloaded from
the compiler is not able to build the fulltext search index correctly and
the TOC may be garbled, too. In particular:
</xsl:text>
<xsl:for-each select="lang">
<xsl:sort select="." />
'.xml'))/language" />
<xsl:text> + chm-</xsl:text>
<xsl:value-of select="." />
<xsl:text>: </xsl:text>
&lf;
</xsl:if>
</xsl:for-each>
&lf;
</description>
</xsl:template>
<!-- ==================================================================== -->
<!-- <language> -->
<!-- generate language specific xslt -->
<!-- ==================================================================== -->
<xsl:template match="/language">
<xsl:call-template name="copyright" />
<xsl:element name="xsl:stylesheet" namespace="&xsl;">
<xsl:attribute name="version">1.0</xsl:attribute>
&lf;
&lf;
<xsl:element name="xsl:output">
<xsl:attribute name="method">
<xsl:choose>
<xsl:when test="$type = 'manual' or
$type = 'chm' or
$type = 'zip'">
<xsl:text>xml</xsl:text>
</xsl:when>
<xsl:when test="$type = 'hhc' or
$type = 'hhp' or
$type = 'man'">
<xsl:text>text</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:text>Unknown style type '</xsl:text>
<xsl:value-of select="$type" />
<xsl:text>'!</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="encoding">
<xsl:choose>
<xsl:when test="$type = 'chm' or
$type = 'hhc' or
$type = 'hhp'">
</xsl:when>
<xsl:when test="$type = 'man'">
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="charset" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="indent">no</xsl:attribute>
<xsl:if test="$type = 'manual' or
$type = 'chm' or
$type = 'zip'">
<xsl:attribute name="doctype-public">
<xsl:text>-//W3C//DTD XHTML 1.0 Strict//EN</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:if test="$type = 'manual'">
<xsl:attribute name="doctype-system">
</xsl:attribute>
</xsl:if>
<xsl:if test="$type = 'chm' or
$type = 'zip'">
<xsl:attribute name="omit-xml-declaration">yes</xsl:attribute>
</xsl:if>
</xsl:element>
&lf;&lf;
<xsl:comment>
<xsl:text> Read the localized messages from the specified </xsl:text>
<xsl:text>language file </xsl:text>
</xsl:comment>
&lf;
<xsl:element name="xsl:variable">
<xsl:attribute name="name">message</xsl:attribute>
<xsl:attribute name="select">
<xsl:text>document('</xsl:text>
<xsl:if test="$type != 'manual'">../</xsl:if>
<xsl:text>lang/</xsl:text>
<xsl:value-of select="@id" />
</xsl:attribute>
</xsl:element>
&lf;
<xsl:if test="$type != 'man'">
<xsl:element name="xsl:variable">
<xsl:attribute name="name">doclang</xsl:attribute>
<xsl:value-of select="@id" />
</xsl:element>
&lf;
<xsl:element name="xsl:variable">
<xsl:attribute name="name">allmodules</xsl:attribute>
<xsl:attribute name="select">
<xsl:text>document('</xsl:text>
<xsl:if test="$type != 'manual'">../</xsl:if>
</xsl:attribute>
</xsl:element>
&lf;
</xsl:if>
&lf;
<xsl:if test="$type != 'man'">
<xsl:comment>
<xsl:text> some meta information have to be passed to </xsl:text>
<xsl:text>the transformation </xsl:text>
</xsl:comment>
&lf;
</xsl:if>
<xsl:if test="$type = 'manual' or
$type = 'chm' or
$type = 'zip' or
$type = 'hhc'">
<xsl:element name="xsl:variable">
<xsl:attribute name="name">output-encoding</xsl:attribute>
<xsl:choose>
<xsl:when test="$type = 'chm' or
$type = 'hhc'">
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(charset)" />
</xsl:otherwise>
</xsl:choose>
</xsl:element>
&lf;
</xsl:if>
<xsl:if test="$type = 'manual' or
$type = 'chm' or
$type = 'zip'">
<xsl:element name="xsl:variable">
<xsl:attribute name="name">is-chm</xsl:attribute>
<xsl:attribute name="select">
<xsl:choose>
<xsl:when test="$type = 'chm'">
<xsl:text>true()</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>false()</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
&lf;
<xsl:element name="xsl:variable">
<xsl:attribute name="name">is-zip</xsl:attribute>
<xsl:attribute name="select">
<xsl:choose>
<xsl:when test="$type = 'zip'">
<xsl:text>true()</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>false()</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
&lf;&lf;
</xsl:if>
<xsl:if test="$type = 'hhc'">
<xsl:element name="xsl:variable">
<xsl:attribute name="name">toc-font</xsl:attribute>
</xsl:element>
&lf;
<xsl:element name="xsl:variable">
<xsl:attribute name="name">xml-ext</xsl:attribute>
<xsl:value-of select="normalize-space(source-ext)" />
</xsl:element>
&lf;&lf;
</xsl:if>
<xsl:if test="$type = 'hhp'">
<xsl:element name="xsl:variable">
<xsl:attribute name="name">hhp-lang</xsl:attribute>
</xsl:element>
&lf;&lf;
</xsl:if>
<xsl:comment> Now get the real guts of the stylesheet </xsl:comment>
&lf;
<xsl:element name="xsl:include">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="$type = 'chm' or
$type = 'zip'">
</xsl:when>
<xsl:when test="$type = 'hhc'">
</xsl:when>
<xsl:when test="$type = 'hhp'">
</xsl:when>
<xsl:when test="$type = 'man'">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
&lf;&lf;
</xsl:element>
</xsl:template>
<!-- /language -->
<xsl:template name="copyright">
&lf;
<xsl:comment><xsl:text>
Copyright 2002-2006 The Apache Software Foundation or its licensors,
as applicable.
Licensed 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
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.
</xsl:text></xsl:comment>
&lf;&lf;
</xsl:template>
<xsl:template name="sepstring">
<xsl:text>============================================</xsl:text>
<xsl:text>========================</xsl:text>
</xsl:template>
<xsl:template name="sep">
<xsl:comment>
<xsl:text> </xsl:text>
<xsl:call-template name="sepstring" />
<xsl:text> </xsl:text>
</xsl:comment>
&lf;
</xsl:template>
<xsl:template name="head">
<xsl:param name="text" />
<xsl:variable name="s"><xsl:call-template name="sepstring" /></xsl:variable>
<xsl:variable name="empty" select="translate($s, '=', ' ')" />
<xsl:comment>
<xsl:text> </xsl:text>
<xsl:value-of select="substring(concat(normalize-space($text), $empty), 1,
string-length($empty))" />
<xsl:text> </xsl:text>
</xsl:comment>
&lf;
</xsl:template>
</xsl:stylesheet>