Hello,
i'm trying to implement the generic language switching as mentioned in
http://wiki.apache.org/lenya/HowToLanguageSwitching at the bottom of the
page. Here's my page2xhtml.xls

<?xml version="1.0" encoding="UTF-8" ?>
<!--
  Copyright 1999-2004 The Apache Software Foundation

  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

      http://www.apache.org/licenses/LICENSE-2.0

  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.
-->

<!-- $Id: page2xhtml.xsl 170255 2005-05-15 19:58:26Z gregor $ -->

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns="http://www.w3.org/1999/xhtml";
    xmlns:xhtml="http://www.w3.org/1999/xhtml";
    xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0";
    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0";
    xmlns:dc="http://purl.org/dc/elements/1.1/";
    xmlns:dcterms="http://purl.org/dc/terms/";
    xmlns:i18n="http://apache.org/cocoon/i18n/2.1";
    exclude-result-prefixes="page xhtml"
    >


<!-- {context-prefix}/{publication-id}/{area} -->
<xsl:param name="root"/>

<xsl:param name="document-id"/>
<xsl:param name="raw"/>

<xsl:param name="contextprefix"/>
<xsl:param name="publicationid"/>
<xsl:param name="area"/>
<xsl:param name="documentextension"/>
<xsl:param name="chosenlanguage"/>
<xsl:param name="tab"/>

<!-- i.e. doctypes/xhtml-document -->
<xsl:param name="document-type"/>

<!-- The rquest url i.e. /lenya/doctypes/xhtml-document_en.html -->
<xsl:param name="url"/>

<!-- The chosen language -->
<xsl:param name="language"/>

<!-- All available languages for the specific page in a comma-separated
list
-->
<xsl:param name="languages"/>

<xsl:variable name="extension"><xsl:if test="$documentextension !=
''">.</xsl:if><xsl:value-of select="$documentextension"/></xsl:variable>

<xsl:template match="cmsbody">
  <html>
    <head>
      <link rel="stylesheet" href="{$root}/css/screen.css" type="text/css"
media="screen"/>
      <meta content="Apache Lenya" name="generator"/>
      <meta http-equiv="Content-Type" content="application/xhtml+xml;
charset=UTF-8"/>
      <script type="text/javascript" src="{$root}/javascript/layout.js">
      </script>
      <title><xsl:value-of select="//lenya:meta/dc:title"/></title>
    </head>
    <body onload="correct_layout()">
      <div id="page">
        <div id="top_section">
          <xsl:choose>
            <xsl:when test="$language = 'de'">
              <img src="{$root}/images/unilogo.png" id ="unilogo"
alt="Logo
der Universität Ulm"/>
              <a class="title" href="http://www.uni-ulm.de"; hreflang="de">
                Universit&#228;t Ulm
              </a>
              <a class="subtitle" href="http://www.mathematik.uni-ulm.de";
hreflang="de">
                Fakult&#228;t für Mathematik und
Wirtschaftswissenschaften
              </a>
              <img src="{$root}/images/geb.png" id ="geb"
alt="Fakult&#228;t
f&#252;r Mathematik &#038; Wirtschaftswissenschaften"/>
            </xsl:when>
            <xsl:otherwise>
              <img src="{$root}/images/unilogo.png" id ="unilogo"
alt="logo of
the university of ulm"/>
              <a class="title" href="http://www.uni-ulm.de"; hreflang="de">
                University of Ulm
              </a>
              <a class="subtitle" href="http://www.mathematik.uni-ulm.de";
hreflang="de">
                Faculty of Mathematics and Economics
              </a>
              <img src="{$root}/images/geb.png" id ="geb"
alt="Fakult&#228;t
f&#252;r Mathematik &#038; Wirtschaftswissenschaften"/>
            </xsl:otherwise>
          </xsl:choose>
        </div>

        <!-- we need no tabs (horizontal navigation on top
        <xsl:if test="$raw != 'true'">
          <xsl:apply-templates select="xhtml:[EMAIL PROTECTED] = 'tabs']"/>
        </xsl:if>
        -->
        <div id="main_section">
          <div id="navigation">
            <xsl:if test="$raw != 'true'">
              <xsl:apply-templates select="xhtml:[EMAIL PROTECTED] = 'menu']"/>
            </xsl:if>
            <!-- searchfield -->
            <div id="searchbox">
              <xsl:apply-templates select="xhtml:[EMAIL PROTECTED] = 
'search']"/>
            </div>
            <div id="w3cbuttons">
              <a href="http://validator.w3.org/check/referer";>
                <img class="w3cbutton1" src="{$root}/images/xhtml10.png"
alt="Valid XHTML1.0"/>
              </a>
              <a href="http://jigsaw.w3.org/css-validator/check/referer";>
                <img class="w3cbutton2" src="{$root}/images/css.png"
alt="Valid CSS"/>
              </a>
            </div>
          </div>
          <div id="main">
            <div id="main_header">
              Graduiertenkolleg 1100
              <span class="flags">
                <!-- insert flags for the available languages
                     call the flags template with parameter of available
language versions for the specific
                     document -->
                <xsl:call-template name="languageflags">
                  <xsl:with-param name="available_languages">
                    <xsl:value-of select="$languages"/>
                  </xsl:with-param>
                </xsl:call-template>
              </span>
            </div>
            <div id="main_content"
style="background-image:url(images/saeulen.png);background-repeat:no-repeat;">
              <xsl:if test="$raw != 'true'">
                <xsl:apply-templates select="xhtml:[EMAIL PROTECTED] =
'breadcrumb']"/>
              </xsl:if>
              <xsl:apply-templates select="xhtml:[EMAIL PROTECTED] = 'body']"/>
            </div>
            <div id="main_footer">
              <address>
                <xsl:apply-templates
select="lenya:meta/dcterms:modified"/>
                <xsl:apply-templates select="lenya:meta/dc:publisher"/>
              </address>
            </div>
          </div>
        </div>
      </div>
    </body>
  </html>
</xsl:template>

<xsl:template match="dcterms:modified">
  <xsl:variable name="date"><xsl:value-of select="."/></xsl:variable>
  <i18n:text>last_published</i18n:text>:
    <xsl:if test="$date!=''">
    <i18n:date-time src-pattern="yyyy-MM-dd HH:mm:ss" pattern="EEE, d MMM
yyyy
HH:mm:ss z" value="{$date}"/>
  </xsl:if>
</xsl:template>

<xsl:template match="dc:publisher">
  <xsl:variable name="user"><xsl:value-of select="."/></xsl:variable>
  <xsl:variable name="user-id"><xsl:value-of
select="substring-before($user,'|')"/></xsl:variable>
  <xsl:variable name="rest"><xsl:value-of
select="substring-after($user,'|')"/></xsl:variable>
  <xsl:variable name="user-name"><xsl:value-of
select="substring-before($rest,'|')"/></xsl:variable>
  <xsl:variable name="user-email"><xsl:value-of
select="substring-after($rest,'|')"/></xsl:variable>

  <xsl:if test="$user != ''">
    <xsl:choose>
      <xsl:when test="$user-email != ''">
      / <a>
          <xsl:attribute name="href"><xsl:value-of
select="concat('mailto:',
$user-email)"/></xsl:attribute>
          <xsl:value-of select="$user-name"/>
        </a>
      </xsl:when>
      <xsl:otherwise>
       / <xsl:value-of select="$user-name"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:if>
</xsl:template>

<xsl:template match="@*|node()" priority="-1">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template name="languageflags">
  <xsl:param name="available_languages"/>
  <xsl:choose>
    <xsl:when test="not(contains($available_languages,','))">
      <xsl:call-template name="languageflag">
        <xsl:with-param name="flag_language">
          <xsl:value-of select="$available_languages"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="head">
        <xsl:value-of select =
"substring-before($available_languages,',')" />
      </xsl:variable>
      <xsl:variable name="tail">
        <xsl:value-of select = "substring-after($available_languages,',')"
/>
      </xsl:variable>
      <xsl:call-template name="languageflags">
        <xsl:with-param name="available_languages">
          <xsl:value-of select="$head"/>
        </xsl:with-param>
      </xsl:call-template>
      <xsl:call-template name="languageflags">
        <xsl:with-param name="available_languages">
          <xsl:value-of select="$tail"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="languageflag">
  <xsl:param name="flaglanguage"/>
    <a id="{$flaglanguage}"
href="{$root}{$document-id}_{$flaglanguage}.html">
      <img src="{$root}/images/{flaglanguage}.png" alt="{$flaglanguage}"/>
    </a>
</xsl:template>

</xsl:stylesheet>

Now there's the variable $languages, which should contain the available
languages, but it's empty. Maybe someone has a idea where I have to enable
the function, that this variable will be passed to this file.
(Maybe also someone has implemented this feature already and can post his
xsl
file?)

Thanks in advance

Mario Rometsch


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to