views:

1086

answers:

2

I am creating an xml schema, and I want to support a custom date format:
Thu Dec 11 14:17:20 2008

Currently I'm using the following pattern type:

<xs:simpleType name="Date_Type">
 <xs:restriction base="xs:token">
  <xs:pattern value="(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|June|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]{4}"/>
 </xs:restriction>
</xs:simpleType>

Is there a simpler (more elegant) way of doing this using XML-schema?

+1  A: 

Have you read http://www.w3.org/TR/xmlschema-2/#dateTime ?

abatishchev
+1  A: 

XML with schema is intended to store data; as other have pointed out there is alreay a standard way to store dates. It look like you want to store formatted data, which is mixing the model and the view, as it were.

It's possible that you'll be be fine doing this, but eventually you might want to do something like an XSLT filter that picks out items whose dates are between two given dates. Then you'll be in trouble.

David Norman