[xsl] Convert ISO8601 Date with XSLT

Subject: [xsl] Convert ISO8601 Date with XSLT
From: "Snow, Corey" <CSNOW@xxxxxxxxx>
Date: Wed, 6 Feb 2002 15:07:50 -0800
Hi all,

I have an XML document that looks like the following (sanitized):

<log>
	<logentry class="Information">
		<logtime>2002-02-06T14:46:52</logtime>
		<event>Log Cleared</event>
	</logentry>
</log>

I also have an XML schema that defines the content of the "logtime" element
to be a dateTime value. This document validates properly against my schema,
and I can display the document properly using my XSLT stylsheet, which
basically just formats the document as a table- the real thing has many log
entries, obviously.

Here's the problem: I may have a need to work with this date value in
various other locations, using tools such as VBScript. Unfortunately, the
string value above isn't recognized as a valid date by the various
date-handling functions in VBScript, such as IsDate() or FormatDateTime().
The irony is that in order to generate an ISO8601-compliant datetime value
when writing the file, I had to write a custom function to convert the
datetime representation created by VBScript into ISO8601 format. I suppose I
could have simply made the content of the "logtime" element a string and be
done with it, but that didn't seem very clean to me.

What I need to know is the "best" method to convert this date into another
format using XSLT. I could, of course, simply use the substring-before() and
substring-after() functions to modify the display of information, which is
what I am currently assuming is the way to go. There's other ways also- by
using VBScript it would be trivial to take the string apart. I'm mostly
looking to see if this problem is one that others have had and what the most
portable way of solving it is.

Regards,

Corey Snow

#########################################################
The information contained in this e-mail and subsequent attachments may be privileged, 
confidential and protected from disclosure.  This transmission is intended for the sole 
use of the individual and entity to whom it is addressed.  If you are not the intended 
recipient, any dissemination, distribution or copying is strictly prohibited.  If you 
think that you have received this message in error, please e-mail the sender at the above 
e-mail address.
#########################################################

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread