Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Why XSD.exe does not add XmlArrayItemAttribute for the derived type in the list item?

 
 
Old 08-30-2007   #1 (permalink)
eyiu.ca


 
 

Why XSD.exe does not add XmlArrayItemAttribute for the derived type in the list item?

I have this XSD schema. I used XSD.exe to create the cs file, but only
XmlArrayItemAttribute for the base type is specified for the list item
(Not the derived type). Why is the derived type not added? Can anyone
tell me how to solve this problem?

My XSD Schema:

<?xml version = "1.0" encoding = "UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/" xmlns="http://
example.org/" elementFormDefault="qualified">
<xsd:element name="baseInstance" type="MyBaseType" abstract="true" /
Quote:

>
<xsd:complexType name="MyBaseType">
<xsd:sequence>
<xsd:element name="Field1" type="xsd:string"/>
<xsd:element name="Field2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>


<xsd:complexType name="BaseListType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
ref="baseInstance" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="BaseList" type="BaseListType" />

<xsd:element name="derivedAInstance" type="DerivedTypeA"
substitutionGroup="baseInstance" />
<xsd:complexType name="DerivedTypeA">
<xsd:complexContent>
<xsd:extension base="MyBaseType">
<xsd:attribute name="ExtraInfoForA" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:element name="derivedBInstance" type="DerivedTypeB"
substitutionGroup="baseInstance" />
<xsd:complexType name="DerivedTypeB">
<xsd:complexContent>
<xsd:extension base="MyBaseType">
<xsd:attribute name="ExtraInfoForB" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:element name="myThings" type="MyThingsType" />
<xsd:complexType name="MyThingsType">
<xsd:sequence>
<xsd:element ref="BaseList" />
</xsd:sequence>
</xsd:complexType>

</xsd:schema>


The following code for the MyThingsType class was generated. Why
derivedAInstance and derivedBInstance are not added?


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd",
"2.0.50727.312")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://
example.org/")]
[System.Xml.Serialization.XmlRootAttribute("myThings",
Namespace="http://example.org/", IsNullable=false)]
public partial class MyThingsType {

private MyBaseType[] baseListField;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("baseInstance",
IsNullable=false)] <-- Why derivedAInstance and derivedBInstance
are not added here by xsd.exe?
public MyBaseType[] BaseList {
get {
return this.baseListField;
}
set {
this.baseListField = value;
}
}
}

Regards,
Peter


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Solved Deleting unused item from Startup list. Possible? General Discussion
Checking a list and adding item if not present PowerShell
Re: Display Item in Drop Down List VB Script


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46