W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2004

Date validating regexp in pattern facet yields invalid results?

From: Johann Sijpkes <jsijpkes@tiscali.nl>
Date: Tue, 13 Jul 2004 23:31:54 +0200
To: xmlschema-dev@w3.org
Message-ID: <40F470EA.32102.EE47B4@localhost>
Hi,

I want to validate dates using a schema but somehow the regexp used to do this 
is not performed by the validator?

I have a small regular expression which works fine, but the long beast just
validates, also on invalid dates like 35/07/04 (dd/mm/yy). Anyway, in the
online regexp tester it works fine ? (And I believe it is a rather popula regexp to 
validate dates..)
I have no idea why this is.. The other restrictions trigger OK.
Is the expression too long? If so, is there a workaround?

Thanks,
Johann

This is the code:

<xsd:simpleType name="date_type" >
<xsd:restriction base="xsd:string">
<xsd:minLength value="8" />
<xsd:maxLength value="8" />
<xsd:pattern value="^\d{2,2}/\d{2,2}/\d{2,2}$" /> <!-- This regexp
works, the next does not -->

<xsd:pattern value=
"^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/(\d{2}))|((0[1-9]|[12]\d|30)\/(
0[13456789]|1[012])\/(\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/(\d{2}))|(29\/02\/((
0[48]|[2468][048]|[13579][26])|(00))))$" />
</xsd:restriction>
</xsd:simpleType>

<!-- Credits for the regular expression go to Dany Lauener who posted this
on the regexp library
http://www.regexlib.com/REDetails.aspx?regexp_id=488

Regular expressions can be tested at :
http://www.regexlib.com/RETester.aspx

The test file is available at 
http://student.kitcampus.com/Projects/group94/stud15/pl_test_schema_fail.xml

Thanks again,
Johann
Received on Wednesday, 14 July 2004 15:56:10 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:10 UTC