Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

user-defined date format in XML schema

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can i define my own date format for data-type "date" in Schema? i know that the default format is CCYY-MM-DD, but i want my date format to be DD/MM/CCYY. how can i do that in order to validate the date in xml?
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can do what you want....ie; DD/MM/CCYY.
That may be possible with the schema but I will have to get back on "if so how" part of your post....
Haven't read everything on this link, but follow
this link, which is a discussion on the date.
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#date
- madhav.....polishing that rusted portion of my brain!
[ July 01, 2003: Message edited by: Madhav Lakkapragada ]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think changing the format of an element or attribute declared as type 'xsd:Date' data type is possible. When an element or attribute is defined as 'type' 'xsd:Date', the xml processor tries to validate the date in the xml document against the format CCYY-MM-DD.
I havent tried it out practically..any one who did that?
U have to write ur own custom code to achive the format DD/MM/CCYY by 'restricting' a 'string' data type.
[ July 02, 2003: Message edited by: Madhav Lakkapragada ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think changing the format of an element or attribute declared as type 'xsd:Date' data type is possible
Sorry, my mistake for not being very clear.....
I was hoping the Schema would provide some "format selection" attribute or something. That's what I was hoping for, didn't mean to suggest that we can change the schema type itself.
Anyways, as I said I didn't read the entire date explanation....
- madhav
[ July 02, 2003: Message edited by: Madhav Lakkapragada ]
 
iyven koh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there's no attribute that i can use to customise the format of date to what i want. i think the only way is write the code as what you have suggested but it is a bit tedious. coz i have to verify whether it is a valid date eg.30/2/2003 is invalid. anybody has written the code before?
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic