p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XML
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 23rd, 2009, 10:04 AM
Authorized User
Points: 156, Level: 3
Points: 156, Level: 3 Points: 156, Level: 3 Points: 156, Level: 3
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 23rd, 2009, 10:32 AM
samjudson's Avatar
Friend of Wrox
Points: 4,453, Level: 28
Points: 4,453, Level: 28 Points: 4,453, Level: 28 Points: 4,453, Level: 28
Activity: 61%
Activity: 61% Activity: 61% Activity: 61%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,359
Thanks: 0
Thanked 31 Times in 31 Posts
Default

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 -/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old October 23rd, 2009, 10:41 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 23rd, 2009, 10:43 AM
Authorized User
Points: 156, Level: 3
Points: 156, Level: 3 Points: 156, Level: 3 Points: 156, Level: 3
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create xml from xml schema in java zhebincong XML 1 October 6th, 2009 05:10 AM
W3C XML Schema Validation Problem tclotworthy XML 4 August 28th, 2009 01:11 PM
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 06:51 AM
Problem creating temp XML SCHEMA COLLECTION bijgupt SQL Server 2005 0 May 4th, 2007 12:58 AM
XML, XML Schema, JavaScript, ASP cyberjames2003 XML 0 June 4th, 2003 05:49 AM



All times are GMT -4. The time now is 05:15 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc