|
|
 |
| XML General XML discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XML section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

October 23rd, 2009, 10:04 AM
|
|
Authorized User
|
|
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Problem with date format in XML and XML Schema
Hi All,
I have created Xml Schema file which validate Xml document.In xml document i have a date attribute which i validate thorugh xsd but the problem is type xs:date of Xml Schema only allows date format as yyyy/mm/dd.
In my Xml document i want to enter date format as dd/mm/yyyy.
Can anyone show me how to achieve this. please provide some example or code.
Thanks for your help.
-Nelly
|

October 23rd, 2009, 10:32 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,359
Thanks: 0
Thanked 31 Times in 31 Posts
|
|
xs:date has a defined format, there is nothing you can do about that.
You'll just have to use xs:string instead, possibly with a regular expression restriction. This doesn't stop the user entering an invalid date however.
__________________
/- Sam Judson : Wrox Technical Editor -/
|

October 23rd, 2009, 10:41 AM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
If you're prepared to explore the bleeding edge, Saxon-EE 9.2 has an extension that allows you to define reformatting to be applied to an element or attribute before validation. So you could write an XPath expression that rearranges the components of the date into standard ISO order (yyyy-mm-dd), and then validates as an xs:date.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|

October 23rd, 2009, 10:43 AM
|
|
Authorized User
|
|
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Thanks sam for your reply.
Is there anyway to validate the value if user enter the wrong date. if am using xs:string and regular expression ?
If yes please give me some hint .
Thanks
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |