There is an XML code
<?xml version="1.0" encoding="utf-8" ?> <A> <BC="1234">d</B> <BC="4211">b</B> <BC="0312">b</B> <BC="1543">d</B> <BC="2345">b</B> <DC="1233">d</D> <DC="4321">b</D> </A> And to him there is a scheme
<?xml version="1.0" encoding="utf-8" ?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:attribute name="C"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:totalDigits value="4" /> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:element name="A"> <xs:complexType> <xs:sequence> <xs:element name="B" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute ref="C" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="D" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute ref="C" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Then, there is a piece of the scheme that needs to be added to the main part:
<xs:element name="elementName"> <!— Parent name —> <xs:complexType> <xs:choice> <xs:element name="A" type="xs:string" /> <xs:element name="B" type="xs:string" /> <xs:element name="C" type="xs:string" /> <xs:element name="D" type="xs:string" /> <xs:element name="E" type="xs:string" /> <xs:element name="F" type="xs:string" /> </xs:choice> </xs:complexType> </xs:element> How to do it right? In ComplexType extension and choice syntax can not be put together. Accordingly, adding to an already existing item will fail. If taken out separately, it is not clear how to make reference. If taken out separately, then in the tree they are displayed as additional elements (which is in general logical, but not true). How to be?