【发布时间】:2015-08-03 06:24:01
【问题描述】:
对 xml 很陌生。验证器抛出错误。
完全错误与元素类型“mpreader”关联的属性“xsi:schemaLocation”的前缀“xsi”未绑定。
这是 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>
还有一个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:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
【问题讨论】:
-
您可以尝试在 xs:schema 元素中将 'targetNamespace="C:\Users\Dallan\Desktop\Mpreader\" ' 添加到您的 xsd 中吗?
-
没有用。
标签的语法是否正确?这就是验证器似乎遇到的问题 -
我的猜测是这是一个命名空间问题。这就是我建议的原因。也许另一个您可以尝试验证它的想法是从您的 XML 中删除默认命名空间和命名空间位置。然后我们知道它是否确实是命名空间。