Re: Deserializing xs:choice with xs:sequence problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



Zafar,

Unfortunately I have to live with 1.1 - but changing

public string Item;
to
public string[] Items;

worked!!! - the only thing is that I will have to manually modify the
generated file every time I need to change my schema - a small price to pay.

Thanks again.

Sergey

"Zafar Abbas" wrote:

> The .NET framework 2.0 behavior is better: It flattens the choice, but it
> still allows you to create and read valid instances:
>
> public partial class test {
>
> /// <remarks/>
>
> [System.Xml.Serialization.XmlElementAttribute("e1")]
>
> [System.Xml.Serialization.XmlElementAttribute("e2")]
>
> [System.Xml.Serialization.XmlElementAttribute("e3")]
>
> [System.Xml.Serialization.XmlElementAttribute("e4")]
>
> [System.Xml.Serialization.XmlElementAttribute("e5")]
>
> [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
>
> public string[] Items;
>
> /// <remarks/>
>
> [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
>
> [System.Xml.Serialization.XmlIgnoreAttribute()]
>
> public ItemsChoiceType[] ItemsElementName; }
>
>
>
> "Sergey Poberezovskiy" <SergeyPoberezovskiy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
> in message news:D7083112-67B7-49A7-99DB-B22809CFEA2F@xxxxxxxxxxxxxxxx
> > Hi,
> >
> > If I define my schema as
> >
> > <xs:choice>
> > <xs:sequence>
> > <xs:element ref="el_1" />
> > <xs:element ref="el_2" />
> > </xs:sequence>
> > <xs:sequence>
> > <xs:element ref="el_3" />
> > <xs:element ref="el_4" />
> > <xs:element ref="el_5" />
> > </xs:sequence>
> > <xs:choice>
> >
> > and compile it with .Net 2003 xsd.exe, then I receive only one
> >
> > [ ... choice element attributes ..]
> > public string Item;
> > // with the choice type one of the following:
> > public enum ItemChoiceType
> > { el_1, el_2, el_3, el_4, el_5 }
> >
> > So instead of choosing between two sequences, XmlSerialiser chooses
> between
> > the first two elements in those sequences, and the rest is just ignored!!!
> >
> > I NEED the rest as well.
> >
> > Can anyone please point me in the right direction on how to read the rest
> of
> > the sequences?
> >
> > Thanks in advance,
> >
> > Sergey
>
>
>
.



Relevant Pages

  • Re: Deserializing xs:choice with xs:sequence problem
    ... The .NET framework 2.0 behavior is better: It flattens the choice, ... public partial class test { ... public string[] Items; ... > the first two elements in those sequences, and the rest is just ignored!!! ...
    (microsoft.public.dotnet.xml)
  • XML Inheritance
    ... I have a question regarding how the .Net framework interprets schema ... public string __Address1; ... [XmlIgnore] ...
    (microsoft.public.dotnet.xml)
  • RE: Parsing WSDL and System.Web.Services.Description
    ... Document/literal the schema xs:element referenced by the wsdl:part element ... or a method taking Strings instance with parameter style bare ... public string Add ... attributes, nested groups, element references, and so on. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Could not find schema information for the element
    ... I get 5 messages about "could not find schema": ... Could not find schema information for the element 'testsystem'. ... public string DefaultConnectionStringName ...
    (microsoft.public.dotnet.framework.aspnet)
  • XSD.exe and nested attribute group
    ... nest an attributegroup inside another one I miss the nested attribute ... Second Schema: ... public string attributo2; ...
    (microsoft.public.dotnet.xml)