0
我有一個不同類型的序列,對於他們中的一些我想確保,至多使用這些元素中的一個。以下是一些示例:<Synchronisation>
和<Link>
可能會發生一次。有像<TextBox>
,<Label>
,<CheckBox>
等元素。從這些元素,至多有一個允許。 <TextBox>
,<Label>
或<CheckBox>
。XSD:有一些選擇的序列
有效個XML:
<Property>
<Synchronisation/>
</Property>
<Property>
<Synchronisation/>
<Link/>
</Property>
<Property>
<Synchronisation/>
<Link/>
<TextBox/>
</Property>
<Property>
<Synchronisation/>
<Link/>
<Label/>
</Property>
無效的XML,爲<TextBox>
和<Label>
occures。
<Property>
<Synchronisation/>
<Link/>
<Label/>
<TextBox/>
</Property>
我試圖做這樣的XSD,但它不工作:
<xsd:complexType name="PropertyType">
<xsd:sequence minOccurs="0">
<xsd:element minOccurs="0" maxOccurs="1" name="Synchronisation" type="SynchronisationType"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Links" type="LinksType"/>
<xsd:element minOccurs="0" maxOccurs="1" ref="ElementType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ElementType">
<xsd:choice>
<xsd:element name="TextBox" type="TextBoxType"/>
<xsd:element name="Label" type="TextBoxType"/>
<xsd:element name="CheckBox" type="TextBoxType"/>
</xsd:choice>
</xsd:complexType>
你是什麼意思「不起作用「? –
在第5行有一個錯誤:''ElementType'元素沒有被聲明爲' – scher
呃,乍一看來,它似乎是使用'ref'而不是'type'作爲其他人的... –