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

Re: format the date

Subject: Re: format the date
From: Richard Light <richard@xxxxxxxxxxxxxxxxx>
Date: Fri, 23 Jun 2000 10:16:55 +0100
xsl format iso date rss
In message <200006240843.KAA03336@xxxxxxxxxxxxxxxxx>, SAUREL Eric
<Eric.SAUREL@xxxxxxxxxxx> writes
>hi,
>i have : <date format="ISO-8601">2000-05-24</date>
>how can i have the date on this format : Vendredi 24 juin 2000
>[ i am french ].
>where i can find some informations about this.
>thank for your help.

This code (not tested, although it's based on a routine which has been)
should output "24 mai 2000" [sic] for the date you specify.  I haven't a
clue how to derive the day of the week in XSLT!

<xsl:template name="convertMonth">
  <xsl:variable name="month-as-number" select="number(substring-
before(substring-after(text(), '-'), '-'))"/>
  <xsl:choose>
    <xsl:when test="$month-as-number=1">janvier</xsl:when>
    <xsl:when test="$month-as-number=2">f&eacute;vrier</xsl:when>
    <xsl:when test="$month-as-number=3">mars</xsl:when>
    <xsl:when test="$month-as-number=4">avril</xsl:when>
    <xsl:when test="$month-as-number=5">mai</xsl:when>
    <xsl:when test="$month-as-number=6">juin</xsl:when>
    <xsl:when test="$month-as-number=7">juillet</xsl:when>
    <xsl:when test="$month-as-number=8">ao&ucirc;t</xsl:when>
    <xsl:when test="$month-as-number=9">septembre</xsl:when>
    <xsl:when test="$month-as-number=10">octobre</xsl:when>
    <xsl:when test="$month-as-number=11">novembre</xsl:when>
    <xsl:when test="$month-as-number=12">decembre</xsl:when>
    <xsl:otherwise><xsl:value-of select="concat('[invalid month: ',
'$month-as-number')"/></xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template xml:space="preserve" match="date[@format='ISO-8601']">
  <xsl:value-of select="substring-after(substring-after(text(), '-'),
'-')"/>
  <xsl:call-template name="convertMonth"/>
  <xsl:value-of select="substring-before(text(), '-')"/>
</xsl:template>

Hope this helps,

Richard Light.

Richard Light
SGML/XML and Museum Information Consultancy
richard@xxxxxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.