views:

6

answers:

0

Hi All,

I have a very simple XSD like below

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="SEARCH_INCIDENT" type="SEARCH_INCIDENT" />
  <xs:complexType name="SEARCH_INCIDENT">
    <xs:sequence>
      <xs:element name="INCIDENT_NUMBER" type="xs:string" minOccurs="0" maxOccurs="1" />
      <xs:element name="AFFECTED_CONTACT" type="USER_INFO" minOccurs="0" maxOccurs="1" />
      <xs:element name="SUPPLIER_EXTERNAL_REFERENCE" type="xs:string" minOccurs="0" 
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="USER_INFO">
    <xs:sequence>
      <xs:element name="LAST_NAME" type="xs:string" minOccurs="0" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>

When i create a type using the xsd.exe and make a instance of class. I get Affected_Contact as null and I have explicitly instantiate type "USER_INFO" to access the LAST_NAME attribute.

Assume if I am using this with web services and I have to instantiate the complex type to access the attribute. This is a bit odd to me and I wonder if there is any solution to this?