I try to design a XSD with CTA. I have the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="test.xsd">
    <person version="1">
        <firstname>toto</firstname>
        <lastname>tutu</lastname>
    </person>
    <person version="2">
        <firstname>toto</firstname>
        <lastname>tutu</lastname>
        <birthdate>2017-12-18</birthdate>
    </person>
</persons>
The XSD looks like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
    elementFormDefault="qualified"
    vc:minVersion="1.1"> 
    <xs:complexType name="person_v1">
        <xs:sequence>
            <xs:element name="firstname" type="xs:token"/>
            <xs:element name="lastname" type="xs:token"/>
        </xs:sequence>
        <xs:attribute name="version" type="xs:token" use="required" fixed="1"/>
    </xs:complexType>
    <xs:complexType name="person_v2">
        <xs:sequence>
            <xs:element name="firstname" type="xs:token"/>
            <xs:element name="lastname" type="xs:token"/>
            <xs:element name="birthdate" type="xs:date"/>
        </xs:sequence>
        <xs:attribute name="version" type="xs:token" use="required" fixed="2"/>
    </xs:complexType>
    <xs:element name="person">
        <xs:alternative test="@version=1" type="person_v1"/>        
        <xs:alternative test="@version=2" type="person_v2"/>
    </xs:element>
    <xs:element name="persons">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="person" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
The XML is validated against the XSD, but in the XSD:
- If I delete the version attribute, it validates,
- If I replace the version 1 by 3, it validates,
- If I delete all the content of person, it validates.
There must be something missing on my XSD.
 
    