Import schema not generating right object types

Mar 24, 2014 at 11:32 PM
I'm having an issue generating correct classes for some schemas. They generate but the object types need to be manually changed when a schema is imported. Example:

The first schema looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="XSG_CalibrationFile/Risks/RNHW2_MC" targetNamespace="XSG_CalibrationFile/Risks/RNHW2_MC" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wmh="http://www.wmhelp.com/2003/eGenerator" elementFormDefault="qualified" version="1.0">
  <xs:annotation>
    <xs:documentation>
      Calibration data structure for a market consistent calibration of an interest rate model
    </xs:documentation>
  </xs:annotation>
  <xs:element name="Risk">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AssetType"/>
        <xs:element ref="CalibrationType"/>
        <xs:element ref="Model"/>
        <xs:element ref="AnnealingSettings"/>
        <xs:element ref="TargetSwaptions"/>
        <xs:element ref="YieldCurve"/>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
and the second looks like this
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="XSG_CalibrationFile/Risks" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wmh="http://www.wmhelp.com/2003/eGenerator" xmlns:RNHW2_MC="XSG_CalibrationFile/Risks/RNHW2_MC" elementFormDefault="qualified" version="1.0">
  <xs:annotation>
    <xs:documentation>
      Top level XSD that holds the rest of the calibration risk XSDs in a collection
    </xs:documentation>
  </xs:annotation>
<xs:import namespace="XSG_CalibrationFile/Risks/RNHW2_MC" schemaLocation="D:/Development/XSG/Source/XSG_Calibration/XSG_CalibrationFile/CalibrationData_RNHW2_MC.xsd"/>
  <xs:element name="Risks">
    <xs:complexType>
      <xs:sequence>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="RNHW2_MC:Risk"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
The first schema generates the C# code fine. However the second schema which imports the first, when generated has a line that looks like this for the choice:
        [System.Xml.Serialization.XmlElementAttribute("Risk", typeof(Risk), Namespace="XSG_CalibrationFile/Risks/RNHW2_MC", Order=0)]
Now this doesn't work because of the
typeof(Risk) 
bit. I'd like it to say
typeof(RNHW2_MC.Risk)
because of the C# namespace I want to use.

Is there a way of achieving this? Is there a certain argument I need to include when running XSD2Code.exe?