using xsd.exe to generate c# files with the standard UBL 2.0, getting error and warnings
I have the files
This is the command I'm running:
E:\Invoice\maindoc>xsd.exe /c UBL-Invoice-2.0.xsd UBL-CommonAggregat eComponents-2.0.xsd UBL-CommonBasicComponents-2.0.xsd UnqualifiedDataTypeSchemaModule-2.0.xsd UBL-CommonExtensionComponents-2.0.xsd UBL-QualifiedDatatypes-2.0.xsd
These are the errors I'm getting:
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.17929]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Type urn:un:unece:uncefact:codelist:specification:54 217:2001:CurrencyCodeContentType' is not declared, or is not a simple type. Line 72, position 14.
Schema validation warning: Type 'urn:un:unece:uncefact:codelist:specification:66 411:2001:UnitCodeContentType' is not declared, or is not a simple type. Line 1050, position 14.
Schema validation warning: Type 'urn:un:unece:uncefact:codelist:specification:66 411:2001:UnitCodeContentType' is not declared, or is not a simple type. Line 946, position 14.
Schema validation warning: Type urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003:BinaryObjec MimeCodeContentType' is not declared, or is not a simple type. Line 122, position 14.
Schema validation warning: Type 'urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003:BinaryObjectMimeCodeContentType' is not declared, or is not a simple type. Line 232, position 14.
Schema validation warning: Type 'urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003:BinaryObjectMimeCodeContentType' is not declared, or is not a simple type. Line 327, position 14.
Schema validation warning: Type 'urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003:BinaryObjectMimeCodeContentType' is not declared, or is not a simple type. Line 422, position 14.
Schema validation warning: Type 'urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003:BinaryObjectMimeCodeContentType' is not declared, or is not a simple type. Line 517, position 14.
Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.
Error: Error generating classes for schema 'UBL-Invoice-2_0_UBL-CommonAggregateComponents-2_0_UBL-CommonBasicComponents-2_0_UnqualifiedDataTypeSchemaModule-2_0_UBL-CommonExtensionComponents-2_0_UBL-QualifiedDatatypes-2_0'. - The datatype 'urn:un:unece:uncefact:codelist:specification:66411:2001:UnitCodeContentType' is missing.
If you would like more help, please type "xsd /?".
My code imports in file UBL-Invoice-2.0.xsd:
<!-- ===== xsd:schema Element With Namespaces Declarations ===== -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:
CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:
CommonBasicComponents-2"
xmlns:udt="urn:un:unece:uncefact:data:specification:
UnqualifiedDataTypesSchemaModule:2"
xmlns:ccts="urn:un:unece:uncefact:documentation:2"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:
CommonExtensionComponents-2"
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.0">
<!-- ===== Imports ===== -->
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" schemaLocation="UBL-CommonAggregateComponents-2.0.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" schemaLocation="UBL-CommonBasicComponents-2.0.xsd"/>
<xsd:import namespace="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" schemaLocation="UnqualifiedDataTypeSchemaModule-2.0.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" schemaLocation="UBL-CommonExtensionComponents-2.0.xsd"/>
<xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" schemaLocation="UBL-QualifiedDatatypes-2.0.xsd"/>
<!-- ===== Root Element ===== -->
Most likely, there is another schema involved, and include schema, that has to be accounted for in the build.
If the XSD is valid, then you should be able to pull all schemas involved into a project by using VS Project Add Existing Item, which will resolve or expose all problems with the XML schema.
The one area that you can look it is the <namespace
tag, which indicates
what namespace the XML is in and is using.
Make sure that you put in all xsd files, e.g.:
xsd.exe /c sample1.xsd sample2.xsd sample2.xsd