Posted By

greystate on 06/29/06


Tagged

xslt monthnames


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

apawson
enajenkins


Monthnames in XSLT


 / Published in: XML
 

Building blocks for outputting a month's name in XSLT, using an old "assembler trick".

  1. <!-- Variable -->
  2. <xsl:variable name="monthnames">January February March April May June July August September October November December </xsl:variable>
  3.  
  4. <!-- Template -->
  5. <xsl:template match="@date" mode="month-name">
  6. <xsl:variable name="index" select="number(substring(., 6, 2)) - 1" />
  7. <xsl:value-of select="normalize-space(substring($monthnames, $index * 10, 10))" />
  8. </xsl:template>
  9.  
  10. <!-- Executioner -->
  11. <xsl:apply-templates select="@date" mode="month-name" />

Report this snippet  

You need to login to post a comment.