1

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)?

iDeal
  • 53
  • 2
  • 8
  • 1
    Possible duplicate of [What are the best practices for versioning XML schemas?](http://stackoverflow.com/questions/2014237/what-are-the-best-practices-for-versioning-xml-schemas) – Matthew Whited Jan 07 '16 at 19:26
  • If that is so, I apologize. I read that topic and did not feel it guided me in the direction I needed. Ahh, perhaps *http://www.w3.org/TR/xmlschema11-1/#cip* is what I need to be paying better attention to? If so, I'll do better to understand that concept. Perhaps I am looking for an example :-\ – iDeal Jan 07 '16 at 19:39
  • For example, in their example at w3, adding the vc xmlns seems fine and dandy, though I am not sure how the version attribute then would be passed into my processor – iDeal Jan 07 '16 at 19:47
  • This does not seem like a big change, only the content of one single element changes, so I'm not sure something like conditional inclusion is worth the effort. Why not just adapt the existing schema and make the new content optional (in fact, that's one of the [Xfront best practices](http://www.xfront.com/Versioning.pdf)). If you like, I can add an answer to give an example of that. – Mathias Müller Jan 07 '16 at 23:55
  • Up to you Mathias, I spoke with our team lead and he was suggesting doing a Mixed type: http://www.w3schools.com/xml/schema_complex_mixed.asp I felt like the problem with making the new content as optional, is if I can nest "elements" Since Product Type was an element initially, but is going to change to a complex type containing its own elements, I (thought) the schema would have a larger change. – iDeal Jan 08 '16 at 13:14

0 Answers0