You could use some heuristics. For example, you could do the following:
* Check if the length of the text is 8 characters (mmddyyyy)
* Use translate() or similar to remove all digits and ensure you have
nothing left (which checks that your 8 characters were all digits)
* Use substring to split out the year, month and day and then check:
* The year is in some sensible range (1900 - 2010, for example).
* The month is in the range 1 to 12.
* The day is in the range 1 to 31.
However it would be better if you could do any or all of the following:
* Adjust the incoming XML so that you know what fields are dates,
perhaps by marking them with an attribute
* Use XSD data types to mark date fields (not that XSL supports XSD
datatypes, but XSD provides a perfectly good XML dialect for notating
datatypes, so you might as well use it!)
* Learn from the providers of the incoming XML which fields are dates
(anything with the word 'Date' in it, for example)
* Change the date format to be more friendly, such as yyyy-mm-dd. Note
that using year then month then date corresponds to better to the
ISO date formats and means that if you ever need to sort your data
then you can do so with a simple string sort.
Hope that helps,
Dan.
--
Danny Yates
Technical Architect
Abbey National Treasury Services
E-mail: Danny(_dot_)Yates(_at_)ants(_dot_)co(_dot_)uk
Phone: +44 20 7756 5012
Fax: +44 20 7612 4342
-----Original Message-----
From: Joerg Heinicke [mailto:joerg(_dot_)heinicke(_at_)gmx(_dot_)de]
Sent: 02 December 2002 08:41
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Date
There is nothing known about DATE in XSLT, i.e. there is no data type
DATE. You must know, what is a DATE. Or you must use some extension
function, but they are processor dependent.
Joerg
Vijaya Kumar Y wrote:
Sorry , Sorry the question was how to identify that it is a date value(or
in
the other words how do u decide whether it is date)
like in any other languages we check like IsDate("23122002") ,
in same way can i know whether it is a date based on that i would like to
format the date part
regards
Vijay
-----Original Message-----
From: Stevenson Ngila
[mailto:Stevenson(_at_)epr(_dot_)footman-walker(_dot_)com]
Try:
<xsl:value-of
select="substring(Row[(_at_)id='0']/Col[(_at_)name='MfgDate'][(_at_)value],1,2
)"
<xsl:value-of
select="substring(Row[(_at_)id='0']/Col[(_at_)name='MfgDate'][(_at_)value],3,2
)"
<xsl:value-of
select="substring(Row[(_at_)id='0']/Col[(_at_)name='MfgDate'][(_at_)value],5,4
)"
Am not very sure about the path, but the general idea is to use the
substring function.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
***************************************************************************
This communication (including any attachments) contains confidential
information. If you are not the intended recipient and you have received this
communication in error, you should destroy it without copying, disclosing or
otherwise using its contents. Please notify the sender immediately of the
error.
Internet communications are not necessarily secure and may be intercepted or
changed after they are sent. Abbey National Treasury Services plc does not
accept liability for any loss you may suffer as a result of interception or any
liability for such changes. If you wish to confirm the origin or content of
this communication, please contact the sender by using an alternative means of
communication.
This communication does not create or modify any contract and, unless otherwise
stated, is not intended to be contractually binding.
Abbey National Treasury Services plc. Registered Office: Abbey National House,
2 Triton Square, Regents Place, London NW1 3AN. Registered in England under
Company Registration Number: 2338548. Regulated by the Financial Services
Authority (FSA).
***************************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list