I am working on an application that takes XML requests and delivers responses. An XSD schema is used to help validate these requests and defines the structure of the XML request (and response).
I never worked with XSD schemas before and my Googling is not proving helpful!
A chunk of the XML old request is :
<Products id="847DD">
<ProductType>ASD LFGA</ProductType>
<ProductType>DDD DDD2</ProductType>
<ProductType>KLO O947</ProductType>
</Products>
The portion of the XSD looks like:
<xs:complexType name="Products">
<xs:sequence>
<xs:element name="ProductType" type="xs:string" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
Now I have been requested to expand the product type element to include three child elements: so the new XML will look like:
<Products id="0002N">
<ProductType>
<Ind>0</Ind>
<ProductTypeCode>KKK</ProductTypeCode >
<lob>AAW</lob>
</ProductType>
<ProductType>
<Ind>0</Ind>
<ProductTypeCode>DD98</ProductTypeCode >
<lob>SSE</lob>
</ProductType>
<ProductType>
<Ind>K</Ind>
<ProductTypeCode>LKO9</ProductTypeCode >
<lob>XSD</lob>
</ProductType>
</Products>
My hang up is with the versioning of the schema. This is version 1.0 of the schema. And we are not sure how many customers are using this XML requesting service. So we cannot simply ditch version 1.0 and use version 2.0.
It has been requested to maintain backwards compatibility with old structured XML requests.
I feel like I can grasp the programming (Java) aspect of this, later in the XSD schema there is a version attribute that I could lean on to figure out what java logic should be used to read through the XML document.
How do I properly version this XSD? Do I have to make a brand new XSD? Or can I include the new structure inside here? I know that I likely need to turn ProductType from an element to another ComplexType (For V2 only), I assume I can nest those? (ComplextType inside a ComplexType)?