我對XML Schema完全陌生,並且試圖讓基礎知識失效。這是我的xml架構代碼(文件名:example1.xsd):xml架構驗證錯誤「前綴未綁定」
<?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的一個錯誤,指出: 爲元素的前綴「樣品」,「樣品:學校」未綁定。 [9]