My input XML has dates in the format yyyymmdd (20060503) & my target XML output needs dates in the format dd mmmmm yyyy (3 May 2006). I've used the following to re-format:
Code:
<xsl:choose>
<xsl:when test="substring(BookingData/GeneralInformation/PNRCreationDate,5,2)='01'">
<xsl:value-of select="concat(substring(BookingData/GeneralInformation/PNRCreationDate,7,2),
' January ' , substring(BookingData/GeneralInformation/PNRCreationDate,1,4))" />
</xsl:when>
<xsl:when test="substring(BookingData/GeneralInformation/PNRCreationDate,5,2)='02'">
<xsl:value-of select="concat(substring(BookingData/GeneralInformation/PNRCreationDate,7,2),
' February ' , substring(BookingData/GeneralInformation/PNRCreationDate,1,4))" />
</xsl:when> etc.....
long-winded, but it works. However each XML file has at least 3 dates which means I'm replicating the same logic for each one. Is there a way of "calling a function" so I only have one piece of date-formatting code? or at worst is there an easy way of determining the month name instead of the way I'm doing it (some sort of array lookup in programming terms)
as always - thanks in advance.