当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema 所有元素
The all element specifies that the child elements can appear in any order and that each child element can occur zero or one time.
all 元素[所有元素]指明了子元素可以以任何顺序出现,并且每个子元素可以不出现或出现1次。
<all id=ID maxOccurs=1 minOccurs=0|1 any attributes > (annotation?,element*) </all> |
(The ? sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times inside the all element)
“?”符号用于声明元素可以出现的次数(0次或1次),“*”符号用于声明元素可以在all元素中出现的次数(0次或多次)。
属性 | 描述 |
---|---|
id | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
maxOccurs | Optional. Specifies the maximum number of times the element can occur. The value must be 1. 可选参数。指定元素可以出现的最大次数。值必须是1 |
minOccurs | Optional. Specifies the minimum number of times the element can occur. The value can be 0 or 1. Default value is 1 可选参数。指定元素可以出现的最小次数。值可以是0或1。默认值是1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定其它的属性(这些属性无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> |
The example above indicates that the "firstname" and the "lastname" elements can appear in any order but both elements MUST occur once and only once!
上述案例指定了“firstname”和“lastname”可以以任何顺序出现,但是二者仅能出现一次。
<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> |
The example above indicates that the "firstname" and the "lastname" elements can appear in any order and each element CAN appear zero or one time!
上述案例指定了“firstname”和“lastname”可以以任何顺序出现,二者可以出现零次或一次。