For XSD, there are two ways to define a composite element:
One, directly within the element declaration, this method can only use this element
<xs:elementname= "Employee"> <Xs:complextype> <xs:sequence> <xs:elementname= "FirstName"type= "Xs:string"/> <xs:elementname= "LastName"type= "Xs:string"/> </xs:sequence> </Xs:complextype></xs:element>
Second, declared in a separate type, this method, the type can be shared across multiple elements
<xs:elementname= "Employee"type= "Personinfo"/><Xs:complextypename= "Personinfo"> <xs:sequence> <xs:elementname= "FirstName"type= "Xs:string"/> <xs:elementname= "LastName"type= "Xs:string"/> </xs:sequence></Xs:complextype>
XSD has four types of composite elements, and below we learn the definition of each element
One, empty elements
<pid= "1345"/>
The above element, which does not contain child content, contains only one attribute, declared as follows:
< xs:element name = "Product" > < xs:complextype > < xs:attribute name = "pid" type =" Xs:positiveinteger " /> </ xs:complextype > </ xs:element >
Ii. elements that contain other elements
< Employee > < FirstName > John</firstname> <LastName> Smith</lastname></employee>
The top content contains only two child elements, with no attributes, declared as follows:
<xs:elementname= "Person"> <Xs:complextype> <xs:sequence> <xs:elementname= "FirstName"type= "Xs:string"/> <xs:elementname= "LastName"type= "Xs:string"/> </xs:sequence> </Xs:complextype></xs:element>
Three, only the elements of the text (this is not particularly clear)
<type= "Dessert">Ice cream</Food>
This element is a separate blank text, it should be a simple type, it needs to be declared using simplecontent, but not specifically why it is used as a composite type, not knowing whether it is because of the attribute , it is declared as follows:
<xs:elementname= "Food"> <Xs:complextype> <xs:simplecontent> <xs:extensionBase= "Xs:string"> <Xs:attributename= "Dessert"type= "Xs:string" /> </xs:extension> </xs:simplecontent> </Xs:complextype></xs:element>
Iv. elements that contain elements and text
< Description > <lang= "Norwegian">03.03.99</Date > ... . </ Description >
In order for the character data to appear between the child elements of "description", the mixed property must be set to "true" in the,<xs:sequence> property needs to appear sequentially
<xs:elementname= "description"> <Xs:complextypeMixed= "true"> <xs:sequence> <xs:elementname= "Norwegian"type= "Xs:string"/> </xs:sequence> </Xs:complextype></xs:element>
Note: Each of these elements can contain attributes
[XSD learning] composite elements