[Mono-devel-list] XML deserialization - System.FormatException on System.DateTime.ParseExact()

Atsushi Eno atsushi at ximian.com
Sun May 29 22:25:59 EDT 2005


> I do have an XSD that describes that piece of XML and the type is
> xs:date, I am using a codegen tool (a modified xsd.exe) to create
> classes from the XSD; the output of which, "PublishedDate" type is
> System.DateTime, and has an attribute
> [System.Xml.Serialization.XmlElementAttribute(DataType="date")]. 
> According to W3C, xs:date can have an optional timezone property
> (http://www.w3.org/TR/xmlschema-2/#date) so "yyyy-MM-dd" pattern will
> fail if a timezone is present.

Hmm, sure, then apparently XmlSerializer does not conform to XML
Schema specification and my patch is insane as well as MS.NET.
Note that even if we fix this behavior to conform to W3C spec (it
is desirable), your xs:dateTime instance will still be rejected.

The better solution in that sense is to accept
yyyy-MM-dd(zzzzzzz)? and reject your instance.

So both solutions have pros/cons, I leave it to Lluis who rules ;)

Atsushi Eno

More information about the Mono-devel-list mailing list