XML 架构验证错误:内容以 开头无效



我有一个XML文档,它未能通过XML架构验证,并出现错误:

发现以元素"签名"开头的无效内容。"{WC["http://www.w3c.org/2000/09/xmldsig#"]}"之一是预期的。

下面是 XML 示例:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CMAC_Alert_Attributes xmlns="cmac:1.0">
<CMAC_response_code>Monitor</CMAC_response_code>
<CMAC_note />
<CMAC_Digital_Signature>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod
Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<Reference URI="">
<Transforms>
<Transform
Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<DigestValue>pdcsgn0sXaV1cvzpXaoG1nIxC/kDm2I6iFPI87u7s5c=
</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>ZrpBOAWuttOIWgfhdfghdghf5rFUqMiqaBJps9w1AWlfPZIxrT9r/D7LByFZBAsXOPjREjPGM7gRANSRFlqaWX
8z6e5WrlwaHsnbhML810DSaP2rbnoSM6saXyt+s3gj2KLJPn3TWT+UQ7lvmoe11uWL3Bs+frh/fs
eyvLVlE0z0dfghS9JrioksKT8GrF7aglCLEEecfdghdfghdfghir2GSXFTvtGJ6oRaOYAZVj60JaeY/p5lqAP/qWh+BI
tRz8LLYLwkfSUtlhiNTG46mciCwTDhZdfghdfghylG9O2FIUeGGQWMWUI223oHow+QsVRGUvHDsD36DOGN7d
/Ywht8nftbWBSAUuTDqfJVKye8q+lw6f7VYPHg==
</SignatureValue>
</Signature>
</CMAC_Digital_Signature>
</CMAC_Alert_Attributes>

这是 XSD:

<?xml version = "1.0" encoding = "UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="cmac:1.0" xmlns:cmac="cmac:1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<element name="CMAC_Alert_Attributes">
<complexType>
<sequence>
<element name="CMAC_response_code" type="string"
minOccurs="0" maxOccurs="unbounded" />
<element name="CMAC_note" type="string" minOccurs="0"
maxOccurs="unbounded" />
<element name="CMAC_Digital_Signature" minOccurs="0">
<complexType>
<sequence>
<any namespace="http://www.w3c.org/2000/09/xmldsig#"
processContents="lax" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="valueName" type="string" />
<element name="value" type="string" />
</schema>

目的是指定信封签名。我尝试了许多替代方法,包括includeelement ref=...等,但无济于事。

在 XSD 中,更改

<any namespace="http://www.w3c.org/2000/09/xmldsig#"
^

<any namespace="http://www.w3.org/2000/09/xmldsig#"

并且您的 XML 将对您的 XSD 有效。

相关内容

  • 没有找到相关文章

最新更新