當我試圖驗證此代碼,我得到一個錯誤......爲什麼我會收到有關子元素命名空間的錯誤?
<?xml version="1.0"?>
<h:hotel xmlns:h="hotel">
<h:existingRooms>
<room>101</room>
<room>102</room>
<room>201</room>
</h:existingRooms>
</h:hotel>
錯誤:
cvc-complex-type.2.4.a: Invalid content was found starting with element '{"hotel":existingRooms}'. One of '{existingRooms}' is expected.
當我編輯XML到這一點,我沒有得到的錯誤了:
<?xml version="1.0"?>
<h:hotel xmlns:h="hotel">
<existingRooms>
<room>101</room>
<room>102</room>
<room>201</room>
</existingRooms>
</h:hotel>
我的XSD是(有)中的錯誤是:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:h="hotel"
targetNamespace="hotel">
<element name="hotel">
<complexType>
<sequence>
<element name="existingRooms">
<complexType>
<sequence>
<element name="room" type="integer" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
我看不到你的原始XML和編輯一個... – potame
任何區別我不好,我貼了2次相同的代碼,現在我修好了。 – stijnpiron