Reputation: 13
I'm attempting to generate class files from the XSD files provided on the IRS website:
https://www.irs.gov/businesses/corporations/fatca-xml-schemas-and-business-rules-for-form-8966
schema documents downloadable here: https://www.irs.gov/pub/fatca/fatcaxml_v2.0.zip
(FATCAXML_v2.0 (25KB) - Main schema for FATCA reporting.)
The zip file contains 4 documents:
In the first document, FatcaXML_v2.0.xsd, there are 3 xsd:import nodes which appear to reference the 3 other xsd documents.
When attempting to generate my classes using xsd.exe against FatcaXML_v2.0.xsd, I get multiple errors about types not being declared, e.g:
Schema validation warning: Type 'urn:oecd:ties:stffatcatypes:v2:StringMax200_Type' is not declared. Line 259, position 5.
However, I do see a declaration for this type in stffatcatypes_v2.0.xsd (which was imported to the top of 'FatcaXML_v2.0.xsd') :
<xsd:simpleType name="StringMax200_Type">
<xsd:annotation>
<xsd:documentation>Defines a string with maximum length of 200
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:minLength value="0"/>
<xsd:maxLength value="200"/>
</xsd:restriction>
</xsd:simpleType>
How I get xsd.exe to recognize these type definitions?
thanks in advance
Upvotes: 1
Views: 1389
Reputation: 1679
In order to get XSD.exe to 'honour' schemas imported using the
<xsd:import namespace="importNamespace" schemaLocation="schema.xsd"/>
declaration, the schemas need to be located in the same folder and you need to specify all of them in the command line. They should also be specified in order of use from the base schema to the parent. So if you have a schema, parent.xsd
which imports child.xsd
which in turn imports base.xsd
then your command line needs to be as follows
xsd base.xsd child.xsd parent.xsd [options]
N.B. the schemas may not need to all be in the same location but if not I suspect that the relative location(relative to where you are running XSD which should be in the folder of the primary schema) would need to be specified on the command line for each schema and should probably match the <import schemaLocation
attribute but I'm not in a position to confirm this at the moment.
Upvotes: 3