all 元素規(guī)定子元素能夠以任意順序出現(xiàn),每個(gè)子元素可出現(xiàn)零次或一次。
出現(xiàn)次數(shù) | 一次 |
父元素 | group、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)、complexType |
內(nèi)容 | annotation、element |
<all id=ID maxOccurs=1 minOccurs=0|1 any attributes > (annotation?,element*) </all>
(? 符號(hào)聲明該元素可出現(xiàn)零次或一次,而 * 符號(hào)聲明該元素可在所有元素中出現(xiàn)零次或多次。)
屬性 | 描述 |
---|---|
id | 可選。該元素的唯一標(biāo)識(shí)符。 |
maxOccurs | 可選。元素可出現(xiàn)的最大次數(shù)。 該值必須是 1。 |
minOccurs | 可選。元素可出現(xiàn)的最小次數(shù)。 該值可以是整數(shù) 0 或 1。若要指定該元素是可選的,請(qǐng)將該屬性設(shè)置為 0。 默認(rèn)值為 1。 |
any attributes | 可選。規(guī)定帶有 non-schema 命名空間的任何其他屬性。 |
<xs:element name="person"> <xs:complexType> <xs:all> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType> </xs:element>
上面的例子指示 "firstname" 和 "lastname" 元素能夠以任何順序出現(xiàn),兩個(gè)元素都必須且只能出現(xiàn)一次!
<xs:element name="person"> <xs:complexType> <xs:all minOccurs="0"> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType> </xs:element>
上面的例子指示 "firstname" 和 "lastname" 元素能夠以任何順序出現(xiàn),每個(gè)元素都能出現(xiàn)零次或一次!
如對(duì)本文有疑問(wèn),請(qǐng)?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會(huì)為你解答?。?點(diǎn)擊進(jìn)入論壇