|
Subject: RE: [xsl] How to access an array from a node-set variable From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx> Date: Mon, 11 Jul 2005 09:43:45 +0100 |
> This is my data:
>
> <Date>2004-08-02</Date>
>
> Which I would like to display as follows:
>
> 02 ao{t 2004
>
> I have placed an array of French month names in a node-set:
>
> <xsl:variable name="FrenchMonth">
> <MonthNames>
> <MonthName MonthNumber="01">janvier</MonthName>
> <MonthName MonthNumber="02">février</MonthName>
> <MonthName MonthNumber="03">mars</MonthName>
> <MonthName MonthNumber="04">avril</MonthName>
> <MonthName MonthNumber="05">mai</MonthName>
> <MonthName MonthNumber="06">juin</MonthName>
> <MonthName MonthNumber="07">juillet</MonthName>
> <MonthName MonthNumber="08">aouût</MonthName>
> <MonthName MonthNumber="09">septembre</MonthName>
> <MonthName MonthNumber="10">octobre</MonthName>
> <MonthName MonthNumber="11">novembre</MonthName>
> <MonthName MonthNumber="12">décembre</MonthName>
> </MonthNames>
> </xsl:variable>
>
> And I created the following template:
>
> <xsl:template name="FrenchDate">
> <xsl:variable name="year" select="substring-before(., '-')"/>
> <xsl:variable name="month" select="substring(.,6,2)"/>
> <xsl:variable name="day" select="substring(.,9,2)"/>
> <xsl:value-of select="$day"/>
> <xsl:text> </xsl:text>
> <xsl:value-of
> select="exsl:node-set($FrenchMonth)/MonthName[@MonthNumber=$month]"/>
> <xsl:text> </xsl:text>
> <xsl:value-of select="$year"/>
> </xsl:template>
>
> Which I attempt to call as follows:
>
> <xsl:template match="/">
> <xsl:for-each select="//Date">
> <xsl:call-template name="FrenchDate"/>
> <br/>
> </xsl:for-each>
> </xsl:template>
>
> How come it doesn't work?
Because you've used:
<xsl:value-of
select="exsl:node-set($FrenchMonth)/MonthName[@MonthNumber=$month]"/>
And you variable definition is:
<xsl:variable name="FrenchMonth">
<MonthNames>
<MonthName MonthNumber="01">janvier</MonthName>
..so you've left out <MonthNames> in the path. Correct that and it all should
work fine.
cheers
andrew
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] How to access an array fr, Maria Amuchastegui | Thread | [xsl] Process HTML with XSL, Esteban Fernández |
| [xsl] Optimising multiple document(, Hondros, Constantine | Date | Re: [xsl] Optimising multiple docum, Dimitre Novatchev |
| Month |