select/option xml multilangues
Bonjour,
Je suis en train de fabriquer un formulaire xml xsl, en différentes langues.
le tout étant séparé en 3 fichiers :
formulaire.xsl
formulaire.xml
labels.xml
formulaire.xsl
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:variable name="thelang" select="string('fr')"/>
<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/loose.dtd" />
<xsl:template name="gln_form">
<xsl:param name="locale" />
<xsl:param name="key" />
<xsl:value-of select="document('labels.xml')//locale[@xml:lang=$locale]/label[@key=$key]" />
</xsl:template>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head><body>
<xsl:apply-templates select="//applicant/dynamicfield-0/field">
<xsl:with-param name="nomenclature" select="//nomenclature/ldm" />
<xsl:with-param name="id">ldm</xsl:with-param>
<xsl:with-param name="class">field</xsl:with-param>
<xsl:with-param name="size">1</xsl:with-param>
<option value="1">
<xsl:call-template name="gln_form">
<xsl:with-param name="locale" select="$thelang" />
<xsl:with-param name="key" select="string('ARB')" />
</xsl:call-template>
</option>
<option value="2">
<xsl:call-template name="gln_form">
<xsl:with-param name="locale" select="$thelang" />
<xsl:with-param name="key" select="string('FIN')" />
</xsl:call-template>
</option>
<option value="3">
<xsl:call-template name="gln_form">
<xsl:with-param name="locale" select="$thelang" />
<xsl:with-param name="key" select="string('CEE')" />
</xsl:call-template>
</option>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
</xsl:stylesheet> |
formulaire.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="formulaire.xsl" type="text/xsl"?>
<nomenclature>
<ldm>
<item name="ARB" value="1"/>
<item name="FIN" value="2"/>
<item name="CEE" value="3"/>
</ldm>
<nomenclature>
<applicant>
<dynamicfield-0><field name="ldm" type="ENUM" value=""/></dynamicfield-0>
</applicant> |
labels.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<?xml version="1.0" encoding="UTF-8"?>
<labels>
<locale xml:lang="fr">
<label key="ARB">pain</label>
<label key="FIN">eau</label>
<label key="CEE">noix</label>
</locale>
<locale xml:lang="en">
<label key="ARB">bred</label>
<label key="FIN">water</label>
<label key="CEE">nuts</label>
</locale>
</labels> |
je ne comprends pas la manière de passer les paramètres pour le changement de langue pour les listes de type « select ».
Après plusieurs essais, le label ne change jamais et le label de la « key » n’est jamais remplacée.
le résultat reste invariablement
Code:
1 2 3 4 5 6 7
|
<select size="1" id="ldm" class="field" name="ldm">
<option value=""></option>
<option value="1">ARB</option>
<option value="2">FIN</option>
<option value="3">CEE</option>
</select> |
Quelqu'un pourrait-il m'expliquer ce qu'il manque à mon code pour que la "key" du label soit remplacée par le texte correspondant?
Thx
zwaldo