【问题标题】:Generating cXML classes from xsd throws error "The element 'uri:ds:Signature' is missing."从 xsd 生成 cXML 类会引发错误“缺少元素 'uri:ds:Signature'。”
【发布时间】:2017-07-26 06:35:30
【问题描述】:

我正在尝试根据http://cxml.org/ XSD(由 Visual Studio 转换)为版本 cXML 1.2.034 生成 cXML 类。

我将 cXML.dtd 转换为 xsd。然后尝试运行:

xsd.exe cXML.xsd /c /language:CS /n:MyNamespace

但它抛出了一个错误:

Error: Error generating classes for schema 'cXML'. - The element 'uri:ds:Signature' is missing.

然后我在这里发现了这个问题:Generating C# classes from XSD 这似乎很相关。于是我从http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd

下载了 xmldsig-core-schema.xsd

然后我跑了

xsd.exe cXML.xsd xmldsig-core-schema.xsd /c /language:CS /n:MyNamespace

但那扔了

Error: Error generating classes for schema 'cXML_xmldsig-core-schema'. - The element 'uri:ds:Signature' is missing.

我不知道“'uri:ds:Signature'”应该是什么?

我看出来了

<xs:schema xmlns="http://tempuri.org/cXML" xmlns:ds="uri:ds" elementFormDefault="qualified" targetNamespace="http://tempuri.org/cXML" xmlns:xs="http://www.w3.org/2001/XMLSchema">

似乎错了。我将其更改为xmlns:ds="http://www.w3.org/2000/09/xmldsig#",但同样的问题仍然存在。

我还尝试通过添加来添加对本地签名 xsd 的引用

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/> 是的,我的文件与我自己的 xsd 文件位于同一目录中。

【问题讨论】:

  • 您是否也下载并转换了fulfill.dtd ?

标签: xml xsd dtd xsd.exe cxml


【解决方案1】:

我遇到了同样的问题。我尝试了几次像你这样的尝试(导入 https://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd 架构,但确实找到了方法)。

就我而言,我只是删除了有问题的整行:

<!-- COMMENTED <xs:element minOccurs="0" maxOccurs="unbounded" ref="ds:Signature" /> -->

然后它就可以完美地工作了。

【讨论】:

  • 可能对某人有用。实际上,我们最终转向了 SAP OCI,事实证明,实施起来要容易得多。
  • 谢谢,在 2021 年(VS2019)也能正常工作,只是去掉了这条线!
猜你喜欢
  • 1970-01-01
  • 2013-05-01
  • 2015-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-20
  • 1970-01-01
  • 2010-09-20
相关资源
最近更新 更多