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'">février</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'">décembr</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)
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--