xml - Use XSLT to convert date time to full words -
i starting learn xslt , hoping convert xml time , date data spelled out. while have seen methods have date information output words (12 december) don't see allows convert time (6:30 6 thirty) or year (2005 2 thousand five).
is there standard way of doing this? if not feasible (if lengthy) using xsl:if? can limit inputs quarter hours.
what year?
in xslt 2.0, can use the format-date(), format-time() , format-datetime() functions format dates , time in variety of ways, example:
xml
<input>2014-04-30t15:45:12</input>   xslt 2.0
<xsl:stylesheet version="2.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>  <xsl:template match="/">     <output>         <xsl:value-of select="format-datetime(input,              'the [dwwo] day of [mnn] in year [yww], @ [hww] hours , [mwv] minutes [pn]'             )" />        </output> </xsl:template>  </xsl:stylesheet>   result
<?xml version="1.0" encoding="utf-8"?> <output>the thirtieth day of april in year 2 thousand , fourteen, @ 3 hours , forty 5 minutes p.m.</output>      
Comments
Post a Comment