Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

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

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 08-30-2007   #1 (permalink)
eyiu.ca
Guest


 

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
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking a list and adding item if not present Jsimpson PowerShell 2 07-23-2008 08:44 AM
Re: Display Item in Drop Down List McKirahan VB Script 1 06-13-2008 11:03 AM
WPF: Own Control Derived From TextBox hufaunder@yahoo.com Avalon 5 07-29-2007 08:49 PM
GUI application unable to display info derived from registry Tony Vista General 3 02-05-2007 08:44 AM


Update your Vista Drivers Update Your Vista Drivers Now!!

Vistax64.com 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 2005-2008