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

limit a date with XML Schema

Stefan Reiter
P: n/a
Stefan Reiter
Hi, I want to limit a date to a minDate and a maxDate -
is that possible, and how?

<xs:simpleType>
<xs:restriction base="xs:date">
<xs:
</xs:restriction>
</xs:simpleType>

I assume it is only possible with "pattern".


Cheers,

Stefan
Jan 6 '06 #1
Share this Question
Share on Google+
1 Reply


Martin Honnen
P: n/a
Martin Honnen


Stefan Reiter wrote:
[color=blue]
> Hi, I want to limit a date to a minDate and a maxDate -[/color]
[color=blue]
> I assume it is only possible with "pattern".[/color]

Using minInclusive and maxInclusive for example works for me with MSXML
4 and with Xerces-Java, example schema is

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">

<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="date" maxOccurs="unbounded">
<xs:simpleType>
<xs:restriction base="xs:date">
<xs:minInclusive value="2005-01-01" />
<xs:maxInclusive value="2006-01-01" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

Example XML document is

<root>

<date>2005-03-01</date>
<date>2005-01-01</date>
<date>2006-01-01</date>

<date>2007-01-01</date>

</root>

The last date element is flagged by both validators as being invalid.

I am not sure however why <http://www.w3.org/TR/xmlschema-2/#date> does
not list any possible constraining facets for that date data type.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 6 '06 #2

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