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

前端之家收集整理的这篇文章主要介绍了xml模式验证错误“前缀未绑定”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我完全是 XML Schema的新手,我正在努力让基础知识失效.这是我的xml架构代码(filename:example1.xsd):
  1. <?xml version="1.0"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  3. xmlns:sample="http://www.example"
  4. targetNamespace="http://www.example.com"
  5. elementFormDefault="qualified">
  6.  
  7. <xs:element name="school">
  8. <xs:complexType>
  9. <xs:sequence>
  10. <xs:element name="element1" type="xs:string"/>
  11. <xs:element name="element2" type="xs:string"/>
  12. <xs:element name="element3" type="xs:string"/>
  13. <xs:element name="element4" type="xs:string"/>
  14. </xs:sequence>
  15. </xs:complexType>
  16. </xs:element>
  17.  
  18. </xs:schema>

这是XML文档.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <sample:school xmlns="http://www.example.com"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="./example1.xsd">
  6.  
  7. <element1>hello</element1>
  8. <element2>hello</element2>
  9. <element3>hello</element3>
  10. <element4>hello</element4>
  11.  
  12. </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>等)

猜你在找的XML相关文章