Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 3rd, 2011, 09:02 AM
Authorized User
Points: 138, Level: 2
Points: 138, Level: 2 Points: 138, Level: 2 Points: 138, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
Reply With Quote
  #2 (permalink)  
Old May 3rd, 2011, 09:07 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
  #3 (permalink)  
Old May 3rd, 2011, 09:08 AM
Authorized User
Points: 138, Level: 2
Points: 138, Level: 2 Points: 138, Level: 2 Points: 138, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
Reply With Quote
  #4 (permalink)  
Old May 4th, 2011, 04:10 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.