According to w3schools, the group
element is a child element of the complexType
element.
Can the following XML Schema files (XSD) be used interchangeably?
XSD without group element:
<xs:complexType name="personInfo">
<xs:sequence>
<xs:element name="firstName" type="xs:string"/>
<xs:element name="lastName" type="xs:string"/>
</xs:sequence>
<xs:attribute name="personId" type="xs:string" use="required"/>
</xs:complexType>
<xs:element name="person" type="personInfo"/>
XSD with group element:
<xs:group name="personGroup">
<xs:sequence>
<xs:element name="firstName" type="xs:string"/>
<xs:element name="lastName" type="xs:string"/>
</xs:sequence>
<xs:attribute name="personId" type="xs:string" use="required"/>
</xs:group>
<xs:complexType name="personInfo">
<xs:group ref="personGroup"/>
</xs:complexType>
<xs:element name="person" type="personInfo"/>
If yes, what is their difference? Why use the group
element when complexType
has the same effect?