We can classify xs:simpleTypes into 4 categories
These are the built in types, and map directly to the native language types.
Types created using the xs:list construct are generated as arrays of items.
Example XSD |
Copy Code
|
---|---|
<xs:element name="ListOfStrings" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType> <xs:list itemType="xs:string" /> </xs:simpleType> </xs:element> |
Generated Code |
Copy Code
|
---|---|
public string[] ListOfStrings {get;set;} |
If a type is formed using the xs:union notation from several different simple types then a class is generated from it (see handling xs:union)
If a xs:restriction is applied to an existing type (in our example we are RestrictedString restricts xs:string), then the native type that represents the XSD type being restricted (xs:string -> System.String) is still used as the type. Details of the restriction are added as attributes against the property. This has no impact on the interface generated, but affects the validation performed during serialization and deserialization.
Example XSD |
Copy Code
|
---|---|
<xs:element name="RestrictedString"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="(\d)*" /> <xs:length value="5" /> </xs:restriction> </xs:simpleType> </xs:element> |
Generated Code |
Copy Code
|
---|---|
[LxElementValue("RestrictedString", "", LxValueType.Value, XsdType.XsdString, Length="5", Pattern="(\\d)*"] public System.String RestrictedString{ get; set; } = ""; |