cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Arbogast <sebastien.arbog...@gmail.com>
Subject [I18N] [Samples] [XSLT] Something I don't understand in I18N samples
Date Mon, 16 May 2005 23:07:51 GMT
Hi,

I'm trying to add some locale chooser widget to my user interface
using an auto-submit select element instead of the simple links showed
in I18N samples.
The problem I came to is the value of the URL to point towards to
change the locale: in
cocoon-2.1.7\build\webapp\samples\i18n\simple2page.xsl on line 112,
the href attribute of a is given the value '{@href}' and I had never
seen this syntax before in XSLT. Could someone explain to me what this
means and possibly what link I should use to make the current page
reloaded in the new language ?

I already have all the code :

locales.xml
========

<locales>
    <locale code="fr_FR" label="Fran├žais (France)" flag="fr_FR.gif"/>
    <locale code="en_US" label="English (US)" flag="en_US.gif"/>
</locales>


locales.xsl
========

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
    
    <xsl:param name="current_locale" select="'fr_FR'"></xsl:param>
    
    <xsl:template match="/locales">
        <div>
        <form action="" >
            <select size="1" name="locale" id="locale_chooser"
                onchange="document.href=[........]"
                <xsl:apply-templates/>
            </select>
        </form>
        </div>
    </xsl:template>
    
    <xsl:template match="locale">
        <option>
            <xsl:if test="$current_locale = @code">
                <xsl:attribute name="selected">
                    <xsl:value-of select="'selected'"/>
                </xsl:attribute>
            </xsl:if>
            <xsl:attribute name="value">
                <xsl:value-of select="@code"/>
            </xsl:attribute>
            <xsl:value-of select="@label"/>
        </option>
    </xsl:template>
    
    <xsl:template match="node()|@*" priority="-1">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

And everything is displayed fine. I just miss what I should put
instead of "[......]".

Thx in advance.
-- 
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message