繁体   English   中英

使用xsd.exe从多个xsd方案(标准UBL 2.0)生成c#文件

[英]using xsd.exe to generate c# files from multiple xsd scheme, with the standard UBL 2.0

使用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 ===== -->

最有可能的是,涉及另一个架构,包括架构,必须在构建中加以考虑。

如果XSD有效,那么您应该能够使用VS Project Add Existing Item将涉及的所有架构拉入项目,这将解决或暴露XML架构的所有问题。

您可以看到的一个区域是<namespace标记,它指示XML处于和正在使用的命名空间。

确保放入所有xsd文件,例如:

xsd.exe / c sample1.xsd sample2.xsd sample2.xsd

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM