src-resolve:无法将名称“ds:Signature"解析为“元素声明"组件 [英] src-resolve: Cannot resolve the name 'ds:Signature' to an 'element declaration' component
问题描述
我想使用 XSD 文件进行架构验证.当我将 XSD 文件导入 Eclipse 时,没有运行验证类,出现以下错误:
I want to do schema validation using an XSD file. When I import the XSD file to Eclipse, without running the validation class, I have the following error:
src-resolve:无法将名称ds:Signature"解析为元素"声明组件
src-resolve: Cannot resolve the name 'ds:Signature' to an 'element declaration' component
我对 XML 与 XSD 验证过程有点陌生.虽然我在谷歌上寻找过类似的问题,但我无法弄清楚这里出了什么问题.
I am kinda new to XML vs XSD validation process. Although I have looked for similar questions on google, I couldn't figure out what's wrong here.
XSD 文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xerces="http://xerces.apache.org"
xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:abc="http://abc.123.com" targetNamespace="http://abc.123.com"
xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:import namespace="http://uri.etsi.org/01903/v1.3.2#" schemaLocation="XAdES.xsd"/>
<xs:import namespace="http://uri.etsi.org/01903/v1.4.1#" schemaLocation="XAdESv141.xsd"/>
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
<xs:complexType name="headerType">
<xs:sequence>
<xs:element name="doorNumber" type="xs:int"/>
<xs:element ref="ds:Signature"/>
</xs:sequence>
</xs:complexType>
我应该如何修改 XSD 来修复这个错误?
How should I modify the XSD to fix this error?
推荐答案
如果您有 xmldsig-core-schema.xsd
与您的 XSD 位于同一目录中,<强>如果它与 此 XSD,那么您不应该收到关于解析 ds:Signature
失败的错误.
If you have xmldsig-core-schema.xsd
in the same directory as your XSD, and if it is the same as this XSD, then you should not be getting an error about a failure to resolve ds:Signature
.
因此,我怀疑您的导入失败,并且您丢失或忽略了如下警告:
Therefore, I suspect that your import is failing, and you're missing or ignoring a warning such as the following:
[警告] try.xsd:9:56: schema_reference.4: 读取架构失败文档xmldsig-core-schema.xsd",因为 1) 找不到文档;2) 无法读取文件;3) 的根元素该文档不是
.
[Warning] try.xsd:9:56: schema_reference.4: Failed to read schema document 'xmldsig-core-schema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not
<xsd:schema>
.
试试这个 XSD 作为测试;它直接从 xmldsig-core-schema.xsd
的 URL 加载:
Try this XSD as a test; it loads directly from the URL for xmldsig-core-schema.xsd
:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:abc="http://abc.123.com"
targetNamespace="http://abc.123.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<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="headerType">
<xs:sequence>
<xs:element name="doorNumber" type="xs:int"/>
<xs:element ref="ds:Signature"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
我已经测试了上述 XSD,发现它消除了您所看到的分辨率错误.
I've tested the above XSD and found that it eliminates the resolution error that you were seeing.
这篇关于src-resolve:无法将名称“ds:Signature"解析为“元素声明"组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!