It's because
>             <xs:element name="i" type="xs:integer"/>

should be
             <xs:element name="i" type="xs:int"/>

HTH
Merak

> -----Original Message-----
> From: Matevz Gacnik [mailto:[EMAIL PROTECTED]]
> Sent: 16 July 2002 10:19
> To: [EMAIL PROTECTED]
> Subject: [ADVANCED-DOTNET] XSD type system conversion with xsd.exe
>
>
> Hey,
>
> Simple XML Schema:
>
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>    <xs:element name="doc">
>       <xs:complexType>
>          <xs:sequence>
>             <xs:element name="i" type="xs:integer"/>
>             <xs:element name="l" type="xs:long"/>
>             <xs:element name="f" type="xs:float"/>
>             </xs:sequence>
>       </xs:complexType>
>    </xs:element>
> </xs:schema>
>
> If I push this one through xsd.exe /c I get:
>
> //
> // This source code was auto-generated by xsd,
> Version=1.0.3705.209. // using System.Xml.Serialization;
>
>
> /// <remarks/>
> [System.Xml.Serialization.XmlRootAttribute(Namespace="",
> IsNullable=false)] public class doc {
>
>     /// <remarks/>
>     [System.Xml.Serialization.XmlElementAttribute(DataType="integer")]
>     public string i;
>
>     /// <remarks/>
>     public long l;
>
>     /// <remarks/>
>     public System.Single f;
> }
>
> Why is my integer value compiled into string typed field and
> annoteded with integer datatype XmlElementAttribute? Any
> specific reasons that it is not converted to integer in the
> programmatic type system?
>
> The problem is, that this allows me to do:
>
> doc objDoc = new doc();
> objDoc.i = "Lala";
>
> And when I serialize using XmlSerializer I don't get a valid
> XML (for given schema). Actualy I get this:
>
> <?xml version="1.0"?>
> <doc xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>    <i>Lala</i>
>    <l>21020012121</l>
>    <f>9.876</f>
> </doc>
>

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to