【发布时间】:2012-03-17 10:04:06
【问题描述】:
我对 XML Schema 完全陌生,并且正在努力学习基础知识。这是我的 xml 架构代码(文件名: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 xsd xsd-validation