我在xml架構中有點新手。我將不勝感激,如果有人幫助我理解爲什麼我的XML不被與模式驗證:爲什麼我的測試xml與非常簡單的XSD架構失敗?
這裏是我的架構:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/testSchema" xmlns="http://www.example.org/testSchema">
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="Name">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" />
<xs:element name="LastName" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
這裏是我的測試XML:
<?xml version="1.0" encoding="UTF-8"?>
<Employee xmlns="http://www.example.org/testSchema">
<Name>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</Name>
</Employee>
我收到錯誤通過Eclipse的XML編輯器/驗證器:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'Name'. One of '{Name}' is expected.
我不明白是什麼這個模式或我的XML是錯誤的。
你可以發佈你試圖驗證的模式嗎? – 2010-05-13 15:29:53
架構現已在原始帖子中顯示。 道歉使用「答案」而不是編輯 – WSK 2010-05-13 15:41:04