Re: Deserializing xs:choice with xs:sequence problem
- From: "Sergey Poberezovskiy" <SergeyPoberezovskiy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 25 Oct 2005 22:29:02 -0700
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
>
>
>
.
- References:
- Re: Deserializing xs:choice with xs:sequence problem
- From: Zafar Abbas
- Re: Deserializing xs:choice with xs:sequence problem
- Prev by Date: RE: Xml Versioning Tool
- Next by Date: Re: how to generate xml schema with UTF-8 instead of UTF-16
- Previous by thread: Re: Deserializing xs:choice with xs:sequence problem
- Next by thread: how to generate xml schema with UTF-8 instead of UTF-16
- Index(es):
Relevant Pages
|