I have the following simple type defined in an XSD:
<xs:simpleType name="TimeOfDay">
<xs:annotation>
<xs:documentation xml:lang="en">The representation of a time value that does not include time zone/offset information.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:time">
<xs:minInclusive value="00:00:00"/>
<xs:pattern value="(([01][0-9])|(2[0-3]))(:[0-5][0-9]){2}(\.[0-9]+)?"/>
</xs:restriction>
</xs:simpleType>
When I generate the C# code from this using the WCF code-gen feature in .NET 4.5, it maps this type to DateTime. As a result, when we serialize the data contract to XML, the value fails schema validation because it contains the full date/time value, "dd-mm-yyyyThh:mm:ss.fff".
Any idea how we can either:
- Have the generated code implement the necessary restrictions
- Customize the serialization process so only the time component of the value is written into the XML output