0
我想能夠多次指定一個元素,在我的情況下爲Param
。 這是XSD:一個元素多次
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Abc">
<xs:complexType>
<xs:sequence>
<xs:element name="Def" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<!-- ... other elements ... -->
<xs:element name="Param" minOccurs="0" maxOccurs="unbounded"> <!-- Using unbounded is not allowed here -->
<xs:complexType>
<xs:attribute name="Name"/>
<xs:attribute name="Value"/>
</xs:complexType>
</xs:element>
<!-- ... other elements ... -->
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
這是相應的XML:
<Abc xsi:noNamespaceSchemaLocation="SourcesSchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Def>
<Param Name="one" Value="blue"/>
<Param Name="two" Value="yellow"/>
<Param Name="three" Value="green"/>
</Def >
</Abc>
嘗試,我得到以下異常:
Cos-all-limited.2: The {max Occurs} Of An Element In An 'all' Model Group Must Be 0 Or 1. The Value '-1' For Element 'Param' Is Invalid.