Next in thread → Next in month →

Re: [xml-dev] can attribute in XML schema hold value and unit

From
Rick Jelliffe <>
To
Date
2006-03-08T14:15:54Z
ID
<>
Thread
Re: [xml-dev] can attribute in XML schema hold value and unit
Chiusano Joseph wrote:

> Yes, but per my message below, how would you validate using regular 
> expressions *only* that the date value is not (for example) February 30th?

With a regex you could use something like this
     [1,2,4-9][0-9]?"-"[1-9][0-2]?-"[0-9]{4}  |
      [3] ( [0]"-"[1-9][02]?"-"[0-9]  {4})  |
           ([1]? "-" [1-9][0-2] "-" [0-9]{4} )

In Schematron, you could express the constraint using something like this:
 
<sch:rule context="thing[@date]">
   <sch:let     name="day"         value="substring( @date, 1, 2)" />
   <sch:let     name="month"      value="substring( @date, 3, 2" />
   <sch:assert test="not( $month = 2  and $day= 30)">
    The date value should not be February 30
   </sch:assert>
</sch:rule>
  
Cheers
Rick Jelliffe
Next in thread → Next in month →