Src-resolve.4.2:解析组件'ds:Signature'时出错



我正在从xsd验证XML,但当我说它必须验证签名标记时,我出现了一个错误

这是XML:

<?xml version="1.0" encoding="UTF-8"?>
<ValidaLinea>
<cveBanco>40058</cveBanco>
<importe>0</importe>
<fechaHoraEnvio>2002-05-30T09:00:00</fechaHoraEnvio>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">...
</Signature>
</ValidaLinea>

这是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#"
>
<xs:complexType name="ValidaLinea">
<xs:sequence>
<xs:element name="cveBanco">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{5}" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="importe">
<xs:simpleType>
<xs:restriction base="xs:long">
<xs:totalDigits value="14" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="fechaHoraEnvio">
<xs:simpleType>
<xs:restriction base="xs:dateTime">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Signature" type="ds:Signature"/>
</xs:sequence>
</xs:complexType> 
<xs:element name="ValidaLinea" type="ValidaLinea"/>
</xs:schema>

当我尝试进行验证时,显示的错误如下:

Src解析。4.2:解析组件"ds:Signature"时出错
检测到"ds:Signature"在命名空间中http://www.w3.org/2000/09/xmldsig#',
但是此命名空间中的组件不可从架构文档"null"中引用。

可能已经太晚了,但是您错过了导入XSD

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

最新更新