2016-10-03 52 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