2
我工作的一個非常基本的XML模式,我在NetBeans接收XSD錯誤:元素是一個簡單的類型,所以它必須沒有元素信息項[兒童]
cvc-type.3.1.2: Element 'creator' is a simple type, so it must have no element information item [children]. [8]
,當我嘗試驗證XML。我遵循W3學校教程,看起來我的代碼與他們的代碼很相似。我很困惑,當我宣稱它是複雜的時,錯誤狀態創建者是如何簡單的。我是否錯誤地將創建者元素聲明爲複雜類型?
XML文檔:
<?xml version="1.0" encoding="UTF-8" ?>
<gallery
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Proj1Schema.xsd">
<creator>
<name>John Doe</name>
</creator>
</gallery>
模式:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://xml.netbeans.org/schema/gallery"
elementFormDefault="qualified">
<xs:element name="creator">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="gallery">
<xs:complexType>
<xs:sequence>
<xs:element name="creator" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
你已經向我說清楚了。感謝您分享你的知識! :) –