微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

xml – 错误:未绑定属性“xsi:schemaLocation”的前缀“xsi”

我在针对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)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。