Generating cXML classes from xsd throws error “The element 'uri:ds:Signature' is missing.”

夙愿已清 提交于 2019-12-11 05:42:27

问题


I'm trying to generate cXML classes for version cXML 1.2.034 as per http://cxml.org/ XSD (converted by visual studio).

I converted the cXML.dtd to xsd. Then Tried running:

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

But it threw an error:

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

Then I found this issue here: Generating C# classes from XSD which seems relevant. So I downloaded xmldsig-core-schema.xsd from http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd

Then I ran

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

But that threw

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

I'm lost as to what "'uri:ds:Signature'" is supposed to be?

I can see that

<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">

seems wrong. I changed it to xmlns:ds="http://www.w3.org/2000/09/xmldsig#" but same issue persists.

I also tried adding reference to local signature xsd by adding

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/> and yes I have the file in the same directory as my own xsd file.


回答1:


I had the same problem. I tried several attemps like you (import the https://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd schema, but did find how).

In my case, I just remove the whole line that was problematic :

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

and it then work perfectly.



来源:https://stackoverflow.com/questions/45319188/generating-cxml-classes-from-xsd-throws-error-the-element-uridssignature-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!