Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2011, 09:02 AM
Authorized User
 
Join Date: May 2009
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default check if input value is Date

Hi Folks,
I am trying to implement a script where I want to check if the input value has date string in it or not. For example:

Code:
<ota:Caution ID="Alternative" Type="PackageDetail">Room</ota:Caution>
And

Code:
 

<ota:Caution ID="Alternative" Type="PackageDetail">2011-11-12</ota:Caution>

In the first example, the Caution element has value as "Room", which is not a date, hence the method should return false, otherwise true, as in case of example 2nd.

Any help please?
 
Old May 3rd, 2011, 09:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Assuming this is XSLT 2.0, use
Code:
ota:Caution castable as xs:date
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old May 3rd, 2011, 09:08 AM
Authorized User
 
Join Date: May 2009
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using xslt 1.0. Any help in that?
 
Old May 4th, 2011, 04:10 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I am using xslt 1.0.

You have my deep sympathy. Is it really impossible to move forward?

>Any help in that?

Unless you use extension functions (which are processor dependent), it's going to be fairly hard work. But it can be done. Check that the string-length is 10; use translate to strip the hyphens and check that string(number(x)) is not equal to "NaN"; use substring() to check that the characters in positions 5 and 8 are hyphens.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
date input + asp + sql adamhw Classic ASP Databases 1 January 25th, 2011 09:17 AM
Check for missing input g2000 Classic ASP Basics 3 September 1st, 2005 06:05 PM
Check-boxes on input form tmangus Access VBA 4 June 14th, 2005 11:40 AM
Need HELP!!! Record Input in Field - Check box on karlzoe BOOK: Beginning ASP 3.0 1 April 7th, 2005 09:51 AM
Need to check date a_rajasekhar Javascript How-To 1 March 25th, 2005 03:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.