We Recommend

Beginning XML Beginning XML
The perfect resource for beginning XML programmers, this guidebook shows you what XML is, how to use it, and what technologies surround it. The authors build on the strengths of previous editions while covering the latest changes in the XML landscape such as XQuery, RSS and Atom, and Ajax.


Posted By

greystate on 06/29/06


Tagged

xslt monthnames


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

apawson


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.