I have the ISO 20022 standard .xsd
files for camt.026 ISO message and the possible external codes it can use based on it's conf
element on the complex type InvestigationStatus5Choice
.
camt.026 xsd:
<xs:complexType name="InvestigationStatus5Choice">
<xs:choice>
<xs:element name="Conf" type="ExternalInvestigationExecutionConfirmation1Code"/>
...
</xs:choice>
</xs:complexType>
The same camt.026 xsd file also declares this ExternalInvestigationExecutionConfirmation1Code
type as
<xs:simpleType name="ExternalInvestigationExecutionConfirmation1Code">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="4"/>
</xs:restriction>
</xs:simpleType>
The external code sets xsd is supposed to have the type declaration for this ExternalInvestigationExecutionConfirmation1Code
type with possible enumeration values.
<xs:simpleType name="ExternalInvestigationExecutionConfirmation1Code">
...
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="4"/>
<xs:enumeration value="ACDA">
...
</xs:enumeration>
<xs:enumeration value="ACNR">
...
</xs:enumeration>
<xs:enumeration value="ACVA">
...
...
...
It seems every time I generate code using xsd.exe
it generates based off the simple type found in the camt.026 xsd and it is not including the possible enumeration values found in the external code sets xsd.
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:iso:std:iso:20022:tech:xsd:camt.029.001.09")]
public partial class InvestigationStatus5Choice {
private object[] itemsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("AssgnmtCxlConf", typeof(bool))]
[System.Xml.Serialization.XmlElementAttribute("Conf", typeof(string))] // <-- This should be of type ExternalInvestigationExecutionConfirmation1Code
[System.Xml.Serialization.XmlElementAttribute("DplctOf", typeof(Case5))]
[System.Xml.Serialization.XmlElementAttribute("RjctdMod", typeof(ModificationStatusReason1Choice))]
public object[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}
How can I make it include the enumeration values? I tried putting the external code sets xsd before and after the camt.026 xsd as I figured order mattered but no luck.
My folder structure is unique here but the files are resolvable and I am trying:
xsd.exe /classes ..\..\..\2Q2023_ExternalCodeSets_v1.xsd .\iso\camt.029.001.09.xsd
and
xsd.exe /classes iso\camt.029.001.09.xsd .\..\..\..\2Q2023_ExternalCodeSets_v1.xsd
The file
camt.029.001.12.xsd
does not actually reference the external code set file, so XSD.exe can't pick up the enum values defined in the external code set file.As the other answer mentioned, the decoupling between the 2 schemas is deliberate.
The only way to get XSD.exe to generate enums for the
ExternalInvestigationExecutionConfirmation1Code
simple type is to modifycamt.029.001.12.xsd
.I think you should probably weigh up whether or not it's worth manually modifying the schema for your purposes. I find when using the generated code to create and save new XML documents, having the generated enum values available via Intellisense is really helpful, but if you're using generated code to just read XML documents, it's probably enough to just read the enum values as a plain string.
Open the
camt.029.001.12.xsd
file, and add the 'ExternalCodeSets' namespace to thexs:schema
element:Then add the
xs:import
statement (as the first child element of thexs:schema
element):Then you have to replace the local reference to ExternalInvestigationExecutionConfirmation1Code to the external reference:
So now, the InvestigationStatus5Choice element type looks like:
Re run Xsd.exe (
xsd 2Q2023_ExternalCodeSets_v1.xsd camt.029.001.12.xsd /classes
) and it will then generate: