Re: [xsl] Change Months from English to French [XSLT 1.0]

Subject: Re: [xsl] Change Months from English to French [XSLT 1.0]
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Sat, 31 Jul 2010 10:37:00 -0400
You are correct, 1.0 does not have analyze-string. No regular
expression capability iun 1.0 at all. You can, however, parse on the
space that is between the month name and the year.

I believe the following XSLT 1.0 template will do what you asked for.
But you may need to be more robust. E.g., this template will fail if
the input contains "august 2009" instead of "August", or even if it
has a preceding blank: " August 2009".

  <xsl:template match="date-printed">
    <xsl:variable name="month-en" select="substring-before(.,' ')"/>
    <xsl:variable name="year" select="substring-after(.,' ')"/>
    <xsl:variable name="month-fr">
      <xsl:choose>
        <xsl:when test="$month-en = 'January'">janvier</xsl:when>
        <xsl:when test="$month-en = 'February'">fivrier</xsl:when>
        <xsl:when test="$month-en = 'March'">mars</xsl:when>
        <xsl:when test="$month-en = 'April'">avril</xsl:when>
        <xsl:when test="$month-en = 'May'">peut</xsl:when>
        <xsl:when test="$month-en = 'June'">juin</xsl:when>
        <xsl:when test="$month-en = 'July'">juillet</xsl:when>
        <xsl:when test="$month-en = 'August'">ao{t</xsl:when>
        <xsl:when test="$month-en = 'September'">septembre</xsl:when>
        <xsl:when test="$month-en = 'October'">octobre</xsl:when>
        <xsl:when test="$month-en = 'November'">novembre</xsl:when>
        <xsl:when test="$month-en = 'December'">dicembr</xsl:when>
      </xsl:choose>
    </xsl:variable>
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:attribute name="xml:lang">fr</xsl:attribute>
      <xsl:value-of select="$month-fr"/>
      <xsl:text> </xsl:text>
      <xsl:value-of select="$year"/>
    </xsl:copy>
  </xsl:template>

> I have an element, which is looks like something below.
>             <date-printed>August 2010</date-printed>
>
> I need to change the all English months (For instance August here
> to French Aout). I can understand that I could have something like
> below in XSLT 2.0. But for this particular case I've to use 1.0 and
> not getting clue.
>
>
>         <xsl:variable name="months" as="element()+">
>                 <month name="August" num="Aout"/>
> ................
> .................
>
> And then could have attempted
>
>         <xsl:variable name="re" select="
>            REGULAR EXPRESSION HERE$'"/>
>         <xsl:analyze-string select="." regex="{ $re }">
>         <xsl:matching-substring>
>
> I believe <xsl:analyze-string> is not supported in 1.0 and that
> becoming issue here. Any ideas How can this be done in 1.0.
>
> Any direction in this regard will be highly appreciated. (NOTE:
> Input will be <date-printed>August 2010</date-printed> i.e., Month
> name [space] Year. Output required is Aout 2010)

Current Thread