Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 October 23rd, 2009, 09:04 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
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
 
Old October 23rd, 2009, 09:32 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 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 -/

Think before you post: What have you tried?
 
Old October 23rd, 2009, 09:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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
 
Old October 23rd, 2009, 09:43 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
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





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





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