XML Schema 参考手册 完整 XML Schema 参考手册 The group element is used to define the group of elements used in a complex type definition. 父元素: Schema, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent) (? The symbol is declared in the group element, which can appear zero or once. ) Attribute Description Id Optional. Specifies the unique ID of the element. Name Optional. Specifies the name of the group. The name must be a colon-free name (NCName) defined in the XML namespace specification. This attribute is used only if the schema element is the parent of the group element. In this case, group is the model group used by the complexType, choice, and sequence elements. The name property and the ref property cannot appear at the same time. Ref Optional. Reference the name of another group. The ref value must be QName. Ref can contain namespace prefixes. The name property and the ref property cannot appear at the same time. MaxOccurs Optional. Specifies the maximum number of times an group element can appear in the parent element. The value can be an integer greater than or equal to zero. If you do not want to set any limit on the maximum number of times, use the string “unbounded”. The default value is 1. MinOccurs Optional. Specifies the minimum number of times an group element can appear in the parent element. The value can be an integer greater than or equal to zero. The default value is 1. Any attributes Optional. Specifies any other attributes with the non-schema namespace. The following example defines a group that contains a sequence of four elements and uses this group element in a complex type definition:Definition and usage ¶
Element information ¶
Grammar ¶
<group
id=ID
name=NCName
ref=QName
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
*any attributes*
>
(annotation?,(all|choice|sequence)?)
</group>
Example 1 ¶
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="custGroup">
<xs:sequence>
<xs:element name="customer" type="xs:string"/>
<xs:element name="orderdetails" type="xs:string"/>
<xs:element name="billto" type="xs:string"/>
<xs:element name="shipto" type="xs:string"/>
</xs:sequence>
</xs:group>
<xs:element name="order" type="ordertype"/>
<xs:complexType name="ordertype">
<xs:group ref="custGroup"/>
<xs:attribute name="status" type="xs:string"/>
</xs:complexType>
</xs:schema>