[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Date formatting using XSLT extensions functions
http://www.topxml.com/code/default.asp?p=3&id=v20021212030100 ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL "Kaine Varley" <kaine.varley@xxxxxxxxxxxxxxxxxx> wrote in message news:D95333E1DFE4D511B30500065B39139B36EC84@xxxxxxxxxxx > Hi, > > I have an input date in a format like this: 13/03/2003 4:58:32 pm which I'd > like to format into the following: 13 March > > I have tried the following two extension functions, without success I'm > afraid. The first uses VBScript and the second JavaScript. I haven't > attempted to convert the month number to a name yet. Are the built script > language functions and objects not available from the extensions? > > VBScript version: > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:extra="urn:extra-functions"> > <msxml:script xmlns:msxml="urn:schemas-microsoft-com:xslt" > language="VBScript" implements-prefix="extra"> > Function DateFormat(InputDate) > If IsDate(InputDate) Then > DateFormat = Day(InputDate) & " " & > Month(InputDate) > End If > End Function > </msxml:script> > > <xsl:output method="xml" version="1.0" encoding="UTF-8" > indent="yes"/> > > > > <xsl:template name="format-date"> > <xsl:param name="date-to-format" /> > > > <xsl:value-of select="extra:DateFormat($date-to-format)" /> > </xsl:template> > > </xsl:stylesheet> > > > > JavaScript version: > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:extra="urn:extra-functions"> > > <msxml:script xmlns:msxml="urn:schemas-microsoft-com:xslt" > language="JavaScript" implements-prefix="extra"> > function formatDate(dte){ > var dateToFormat = new Date(dte); > > return dateToFormat.getDay() + ' ' + > dateToFormat.getMonth(); > }; > </msxml:script> > > <xsl:output method="xml" version="1.0" encoding="UTF-8" > indent="yes"/> > > > > <xsl:template name="format-date"> > <xsl:param name="date-to-format" /> > > > <xsl:value-of select="extra:formatDate($date-to-format)" /> > </xsl:template> > > </xsl:stylesheet> > > > Regards, > > > Kaine > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|