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

我完全是 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>等)

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念