limit a date with XML Schema

S

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
 
M

Martin Honnen

Stefan said:
Hi, I want to limit a date to a minDate and a maxDate -
I assume it is only possible with "pattern".

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,851
Latest member
CliftonCor

Latest Threads

Top