我在针对XSD验证
XML时遇到问题.验证器抛出
The prefix “xsi” for attribute “xsi:schemaLocation” associated with an
element type “mpreader” is not bound.
这是一个XML剪辑
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <mpreader xmlns="C:\Users\Dallan\Desktop\Mpreader\" xmlns:xs="http://www.w3.org/20one/XMLSchema-instance" xsi:schemaLocation="C:\Users\Dallan\Desktop\Mpreader\mpreaderschemafinal.xsd"> <firmware>"3.4.16"</firmware> <hardware>"2.3.53"</hardware> <sn>"234-1three5"</sn> <devices> </devices> </mpreader>
这是XSD剪辑
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="C:Users/Dallan/Desktop/Mpreader/" elementFormDefault="qualified" targetNamespace="C:\Users\Dallan\Desktop\Mpreader\"> <xs:element name="mpreader"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element name="firmware" type="xs:string"/> <xs:element name="hardware" type="xs:string"/> <xs:element name="sn" type="xs:string"/> <xs:element name="devices"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
“与元素类型”mpreader“相关联的属性”xsi:schemaLocation“的前缀”xsi“未绑定.”
然后绑定它,亲爱的达兰,亲爱的达兰…
只需添加一个命名空间声明,将前缀xsi绑定到命名空间http://www.w3.org/2001/XMLSchema-instance
(https://en.wikipedia.org/wiki/There%27s_a_Hole_in_My_Bucket)