使用xsd.exe生成带有标准UBL 2.0的c#文件,获取错误和警告
我有文件
这是我正在运行的命令:
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
这些是我得到的错误:
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 /?".
我的代码导入文件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 ===== -->
答案 0 :(得分:1)
最有可能的是,还有另一个模式,包括模式 在构建中考虑。
如果XSD有效,那么您应该能够提取所有涉及的模式 使用VS Project Add Existing Item进入项目,它将解析或 公开XML模式的所有问题。
您可以查看的一个区域是<namespace
标记,表示
XML正在使用什么命名空间。
确保输入所有xsd文件,例如:
xsd.exe / c sample1.xsd sample2.xsd sample2.xsd