April 28, 2003

Pattern Restrictions on xsd:dateTime

Adding in the regexp suggested by Sam for RFC-822 format dates to the RSS 2.0 schema, I have come to the conclusion that I must be missing the point somewhere.

I am using the following schema construct:

<xs:element name="pubDate" type="tRfc822FormatDate"/>
<xs:simpleType name="tRfc822FormatDate">
  <xs:restriction base="xs:dateTime">
    <xs:pattern value="(((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?\d\d? +((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +\d\d(\d\d)? +\d\d:\d\d(:\d\d)? +(([+-]?\d\d\d\d)|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\w)"/>
  </xs:restriction>
</xs:simpleType>

I get the following error:

The element: 'pubDate' has an invalid value according to its data type.
<pubDate>Sun, 30 March 2003 12:48:13 GMT</pubDate>

If I change the schema to be <xs:restriction base="xs:string"> instead, then of course it works. However in that case, although I get the syntactic validation of the data, I have lost the semantic meaning of the schema type model.

Am I missing something obvious here?

From some items found by a Google search, I don't think so, but an extra 2000 pairs of eyes on a problem always help....

Entry categories: RSS XML
Posted by Jorgen Thelin at April 28, 2003 05:09 PM - [PermaLink]
 
Traceback List
Comments
"Mar", not "March". :) Posted by: Mark Nottingham on April 29, 2003 12:33 AM
Nowhere near an XSD expert, but I believe the main problem can be found in section 3.2.7.1 of the XML Schema Part 2: Datatypes spec, which begins by saying: "A single lexical representation, which is a subset of the lexical representations allowed by [ISO 8601], is allowed for dateTime..." The definition (in the same document) of the pattern facet reads "pattern is a constraint on the ·value space· of a datatype which is achieved by constraining the ·lexical space· to literals which match a specific pattern. The value of pattern ·must· be a ·regular expression·" There's obviously conflict here, since 3.2.7.1 specifically says you there's only one possible lexical representation, and the pattern facet essentially tries to alter that. Quite honestly, I'm not even sure why said facet is allowed for dateTime. Posted by: Tomas Restrepo on April 29, 2003 03:11 AM
Arrgh. You spotted my deliberate copy-n-paste error, Mark. I was playing around with the data and did not copy back the original value :-( I get the same failure with either "Sun, 30 March 2003 12:48:13 GMT" or "Sun, 30 Mar 2003 12:48:13 GMT" Posted by: Jorgen Thelin on April 29, 2003 06:30 AM
That's roughly where my thought process ended up, Tomas - I just can't see how pattern and dateTime could ever usefully be used together. Posted by: Jorgen Thelin on April 29, 2003 06:34 AM
You program VB Jorgen? Posted by: Marco Island on August 4, 2003 01:42 PM