我有一个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>
目的是指定一个封装的签名。我尝试了多种替代方法,包括include
,element ref=...
等,但无济于事。
答案 0 :(得分:0)
在您的XSD中,更改
<any namespace="http://www.w3c.org/2000/09/xmldsig#"
^
到
<any namespace="http://www.w3.org/2000/09/xmldsig#"
,您的XML将对您的XSD有效。