XSD Только элементы
Элемент сложного типа «только элементы» — это элемент, который может содержать только другие элементы.
Сложный тип, содержащий только элементы
XML-элемент «person» содержит только другие элементы:
<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>
Вы можете определить элемент «person» в схеме следующим образом:
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Обратите внимание
Кроме того, вы можете дать элементу complexType имя, и тогда атрибут type элемента "person" будет ссылаться на это имя (при таком подходе несколько элементов могут ссылаться на один и тот же сложный тип):
<xs:element name="person" type="persontype"/>
<xs:complexType name="persontype">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="persontype">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>