p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XML (http://p2p.wrox.com/forumdisplay.php?f=91)
-   -   Mandatory date values (http://p2p.wrox.com/showthread.php?t=71333)

rajat_aggarwal03 November 6th, 2008 06:07 AM

Mandatory date values
 
Hi All,

I am defining an XSD for my XML file which contains an elemnet of date type. The definition of the element in the XSD is provided as follows:

<xsd:element name="createDate" type="xsd:date">

Is there any through which i can ensure that while creating the XML, the user mandatorily enters the value for the above tag?

Thanks in advance.

Thanks and regards,

Rajat Aggarwal

Thanks and Regards,

Rajat Aggarwal

joefawcett November 6th, 2008 06:36 AM

You can set the minOccurs='1' and maxOccurs='1'. These are the defaults however so if not defined the date will be mandatory.

--

Joe (Microsoft MVP - XML)

rajat_aggarwal03 November 6th, 2008 06:45 AM

Well, this was not what i wanted.
my problem is that when the user defines the XML,

the content should be like
<createDate>2008-11-11</createDate>

and not <createDate />

the point is, that the value contained in the tag should not be empty.

Please help

Thanks and regards,

Rajat Aggarwal

Quote:

quote:Originally posted by joefawcett
 You can set the minOccurs='1' and maxOccurs='1'. These are the defaults however so if not defined the date will be mandatory.

--

Joe (Microsoft MVP - XML)
Thanks and Regards,

Rajat Aggarwal

mhkay November 6th, 2008 09:47 AM

If the type is defined as xsd:date, then an empty element will be rejected by the validator. You don't need to do any more.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference


All times are GMT -4. The time now is 01:48 AM.

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