This is xsd output. Here is the schema code for the ContractDefinitions
collection:
<xs:element name="Contract">
<xs:complexType>
<xs:sequence>
<xs:element name="Definitions">
<xs:complexType>
<xs:sequence>
<xs:element name="Terms" type="Definition" />
</xs:sequence>
</xs:complexType>
</xs:element>
Something seems wrong with the code above for some reason and I can't put my
finger on it. It is supposed to be an element in an xml file called
Definitions (the "collection") representing up to an unlimited amount of
terms ("word/definition pairs"). So for example, when I want to searialize
the Contract class, the saved file (as far as the Definitions collection)
will look like this:
<Contract>
<Definitions>
<Term Word="Host" Definition="The person who pays for or signs this
contract" />
< !-- and so on with the Term element above -->
</Definitions>
< !-- and continuing on with other contract elements -->
</Contract>
I think possibly my design here messed up my output or something. Any advice
on how to fix it here? And I note that it should maybe be fixed here since
the below message says that the xsd output should have created the
collections by itself instead of me having to hand write it. Or did I not
understand that part?
Thanks for the help...
[quoted text, click to view] "Marc Gravell" <marc.gravell@gmail.com> wrote in message
news:3ec621de-765c-4b2e-b28a-39d64752d5ff@z38g2000hsc.googlegroups.com...
> You haven't indicated how ContractDefinitions is declared? I've made
> an assmuption of:
>
> class ContractDefinitions : Collection<Definition> { }
>
> (since if it had been an array I wouldn't expect to see a type called
> ContractDefinitions)
>
> With which (having fixed the other issues [below]) works just fine. In
> real code I would expect the definitions field to auto-initialize to
> an empty collection and only have a getter (not least; since this
> makes deserialization possible), but "as is" you have to use the code
> as you posted:
>
> ContractDefinitions DefinitionsCollection = new
> ContractDefinitions();
> DefinitionsCollection.Add(Host);
> Contract.Definitions = DefinitionsCollection;
>
>
> It doesn't help that this isn't the exact code - as:
> * the field is named the same as the property (compile fail)
> * minor typos (bracket, etc - compile fail)
> * I would expect xsd.exe to output a getter only for a collection (is
> this xsd.exe output?)
>
> Marc
>