[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: Change Months from English to French [XSLT 1.0]
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 31 Jul 2010 16:24:17 +0200
Re:  Change Months from English to French [XSLT 1.0]
pankaj.c@xxxxxxxxxxxxxxxxxx wrote:

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)

As long as that format is ensured it should be easy simply create a secondary XML document which maps the English names to the French names e.g.


<map>
  <!-- put complete mapping here -->
  <month en="August" fr="Aout"/>
</map>

then load that file with the document function e.g.

<xsl:variable name="month-map" select="document('map.xml')"/>


then define a key e.g.


<xsl:key name="mk" match="month" use="@en"/>

then process e.g.

<xsl:template match="date-printed">
  <xsl:copy>
    <xsl:variable name="em" select="substring-before(., ' ')"/>
    <xsl:for-each select="$month-map">
      <xsl:value-of select="key('mk', $em)/@fr"/>
    </xsl:for-each>
    <xsl:value-of select="concat(' ', substring-after(., ' '))"/>
  </xsl:copy>
</xsl:emplate>

--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.