XML Type Support Implementation Notes

This topic describes some implementation details that you want to be aware of.

The IList, ICollection, IEnumerable, Type[], and String types are used to represent XML Schema definition language (XSD) list types.

Union types are represented using the XmlAtomicValue or String type. The source type or the destination type must therefore always be either String or XmlAtomicValue.

If the XmlSchemaDatatype object represents a list type the object converts the input string value to a list of one or more objects. If the XmlSchemaDatatype represents a union type then an attempt is made to parse the input value as a member type of the union. If the parse attempt fails then the conversion is attempted with the next member of the union and so on until the conversion is successful, or there are no other member types to try, in which case an exception is thrown.

The following describes certain mismatches that can occur between CLR types and XML data types and how they are handled.

Note Note

The xs prefix is mapped to the http://www.w3.org/2001/XMLSchema and namespace URI.

The xs:duration type is partially ordered in that there are certain duration values that are different but equivalent. This means that for the xs:duration type value such as 1 month (P1M) is less than 32 days (P32D), larger than 27 days (P27D) and equivalent to 28, 29 or 30 days.

The TimeSpan class does not support this partial ordering. Instead, it picks a specific number of days for 1 year and 1 month; 365 days and 30 days respectively.

For more information on the xs:duration type, see the W3C XML Schema Part 2: Datatypes Recommendation at http://www.w3.org/TR/xmlschema-2/.

When an xs:time value is mapped to a DateTime object, the MinValue field is used to initialize the date properties of the DateTime object (such as Year, Month, and Day) to the smallest possible DateTime value.

Similarly, instances of xs:gMonth, xs:gDay, xs:gYear, xs:gYearMonth and xs:gMonthDay are also mapped to a DateTime object. Unused properties on the DateTime object are initialized to those from MinValue.

Note Note

You cannot rely on the DateTime.Year value when the content is typed as xs:gMonthDay. The DateTime.Year value is always set to 1904 in this case.

When an instance of xs:anyURI that represents a relative URI is mapped to a Uri, the Uri object does not have a base URI.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft