364,085 Members | 5378 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Create simpleType for date format

ZagrebMike
P: n/a
ZagrebMike
Hi,

I want to create a simpleType that will constrain an element to be a date of
the form dd/mm/yyyy.

I have this at the moment,

<xs:simpleType name="newDate">
<xs:restriction base="xs:string">
<xs:pattern
value="((0[1-9]|1\d|2[0-9])/([0][1-9]|1[0-2])|30/(0[13-9]|1[0-2])|31/(0[13578]|1[02]))/\d\d\d\d" />
</xs:restriction>
</xs:simpleType>

but that doesn't work for leap years. Is it possible to use the date base
type. Something like:
<xs:simpleType name="newDate">
<xs:restriction base="xs:date">
??? what goes here ???
</xs:restriction>
</xs:simpleType>

Thanks!
Mar 6 '06 #1
Share this Question
Share on Google+
2 Replies


Martin Honnen
P: n/a
Martin Honnen


ZagrebMike wrote:
[color=blue]
> I want to create a simpleType that will constrain an element to be a date of
> the form dd/mm/yyyy.[/color]

Consider using the predefined xs:date data type. If you need a different
format when representing dates later you can always transform from
yyyy-mm-dd to your format while using the predefined type in your XML
means any schema aware software will understand values to be of the type
date.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 6 '06 #2

ZagrebMike
P: n/a
ZagrebMike
Good thought, but I should have mentioned that this is part of a schema
defining the input in a BizTalk receive pipeline. The format is required to
check that the application generates the date in the correct format.

"Martin Honnen" wrote:
[color=blue]
>
>
> ZagrebMike wrote:
>[color=green]
> > I want to create a simpleType that will constrain an element to be a date of
> > the form dd/mm/yyyy.[/color]
>
> Consider using the predefined xs:date data type. If you need a different
> format when representing dates later you can always transform from
> yyyy-mm-dd to your format while using the predefined type in your XML
> means any schema aware software will understand values to be of the type
> date.
>
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
>[/color]
Mar 6 '06 #3

Post your reply

Help answer this question



Didn't find the answer to your .NET Framework question?

You can also browse similar questions: .NET Framework