The first problem is addressing "The system identifies that it is a
major/minor version change from B" wrt the instance in scenarios A
and B. I'm going to assume a version of the UBL solution, and say that this is
accomplished by requiring new elements which are semantics-changing == 'must
understand' to be in a different namespace from the target namespace of the
B schema. Detection can either be done OOB, or by changing the
wildcard in B to be namespace="##this"
, in which
case the W(B) will not be schema-valid per B.
This solves all of the four sub-cases as written. Here are the schemas in detail:
<xs:schema targetNamespace="B"> <xs:complexType> <xs:sequence> <xs:element name="title"/> <xs:element name="author"/> <xs:element name="price"/> <xs:any minOccurs="0" namespace="##targetNamespace"/> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema targetNamespace="B"> <xs:complexType> <xs:sequence> <xs:element name="title"/> <xs:element name="author"/> <xs:element name="price"/> <xs:element name="editor"/> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema targetNamespace="W(B)"> <xs:import namespace="B"/> <xs:complexType> <xs:sequence> <xs:element ref="B:title"/> <xs:element ref="B:author"/> <xs:element ref="B:price"/> <xs:element name="discount"/> </xs:sequence> </xs:complexType> </xs:schema>
What about the larger issue raised, namely "This use case [should extend]
to multiple levels of versioning". If we assume that changes are
monotonic, we can add another <xs:any minOccurs="0" namespace="##targetNamespace"/>
and it will all work OK.