加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml模式验证错误“前缀未绑定”

发布时间:2020-12-16 07:53:16 所属栏目:百科 来源:网络整理
导读:我完全是 XML Schema的新手,我正在努力让基础知识失效.这是我的xml架构代码(filename:example1.xsd): ?xml version="1.0"?xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns:sample="http://www.example" targetNamespace="http://www.example.
我完全是 XML Schema的新手,我正在努力让基础知识失效.这是我的xml架构代码(filename:example1.xsd):
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sample="http://www.example" 
targetNamespace="http://www.example.com" 
elementFormDefault="qualified">

<xs:element name="school">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="element1" type="xs:string"/>
      <xs:element name="element2" type="xs:string"/>
      <xs:element name="element3" type="xs:string"/>
      <xs:element name="element4" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>

这是XML文档.

<?xml version="1.0" encoding="UTF-8"?>

<sample:school xmlns="http://www.example.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="./example1.xsd">

      <element1>hello</element1>
      <element2>hello</element2>
      <element3>hello</element3>
      <element4>hello</element4>

</sample:school>

在尝试验证xml文件时,我从netbeans得到一个错误,说:
元素“sample:school”的前缀“sample”未绑定. [9]

在您的XML中,您需要:

A.从样品中取出样品:前缀:school

要么

B.将xmlns =“http://www.example.com”更改为xmlns:sample =“http://www.example.com”,并将样本:前缀添加到其余元素(< sample: element1>,< sample:element2>等)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读