2016-10-03 81 views
1

我无法解决有关<xs:element ref="ds:Signature"/>的此错误。 我需要一些帮助。XSD签名问题

版权(C)Microsoft Corporation。版权所有。 Schema 验证警告:'http://www.w3.org/2000/09/xmldsig#:Signature' 未被声明。第162行,第8位。

警告:架构无法验证。班级生成可能失败或 可能会产生不正确的结果。

警告:无法生成类,因为找不到具有 复杂类型的顶级元素。

XSD

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
    attributeFormDefault="unqualified" elementFormDefault="qualified"> 

    <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" 
      schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/> 

      <xs:complexType name="SobreCheques"> 
     <xs:annotation> 
      <xs:documentation>Definition of the ...</xs:documentation> 
     </xs:annotation> 
     <xs:sequence> 
      ... 
     <xs:element ref="ds:Signature"/> 
     </xs:sequence> 
    </xs:complexType> 
</xs:schema> 
+0

模式http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd可从机器访问? – ulab

+0

@ulab是的。 –

+0

好的。如果您在本地保存架构并将其引用到'schemalocation'中,那么它仍然无法解析名称空间。 – ulab

回答

4

从W3C网站检索xmldsig-core-schema.xsd可能需要很长的时间,造成超时。

相反,在相同的目录中XSD使用缓存的本地副本,

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" 
      schemaLocation="xmldsig-core-schema.xsd"/> 

或使用绝对路径如图@ulab in the comments

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" 
      schemaLocation="file:///D:/xmldsig-core-schema.xsd" /> 

参见How to reference a local XML Schema file correctly?

+0

另外,请确保W3C的XSD文件可以从浏览器访问。我有同样的问题,即使我本地添加文件,它不起作用。对我而言,问题在于我的电脑位于代理服务器的后面,W3C网站被封锁了。在我修复了对XSD文件的访问后,我能够生成这些类。不知道这个问题是否仅限于我的设置。 – adimoldovan