Monthnames in XSLT


/ Published in: XML
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.