'XSD to XML Converter

I am trying to convert an XSD file into its corresponding XML document. Using IntelliJ's built-in tool makes this easy but something is wrong. It seems to be creating everything properly, and this is a large XSD, but on closer inspection, some elements are missing. The specific XSD I am using is from here: https://www.iata.org/contentassets/76a4543036794d59ad747f3d80bb9792/19.2-schemas-edist.zip. File is called IATAAirShoppingRS.xsd.
Here is a snippet of the file. After CarrierOffersSummary, there are supposed to be more elements that are created and expanded but there are just comments.

<iata:TotalAmount CurCode="token">1000.00</iata:TotalAmount>
          </iata:TotalPrice>
          <!--Optional:-->
          <iata:ValidatingCarrierCode>token</iata:ValidatingCarrierCode>
          <!--Optional:-->
          <iata:WebAddressURL>http://www.corp.com/pater/regina</iata:WebAddressURL>
        </iata:ALaCarteOffer>
        <!--Optional:-->
        <iata:CarrierOffersSummary>
          <!--Optional:-->
          <iata:HighestOfferPrice>
            <!--Optional:-->
            <iata:LoyaltyUnitAmount CurCode="token">1000.00</iata:LoyaltyUnitAmount>
            <!--Optional:-->
            <iata:LoyaltyUnitName>token</iata:LoyaltyUnitName>
            <!--Optional:-->
            <iata:TotalAmount CurCode="token">1000.00</iata:TotalAmount>
          </iata:HighestOfferPrice>
          <!--Optional:-->
          <!--Optional:-->
        </iata:CarrierOffersSummary>
        <!--Zero or more repetitions:-->
        <!--Zero or more repetitions:-->
      </iata:CarrierOffers>
    </iata:OffersGroup>
    <!--Optional:-->
    <!--Zero or more repetitions:-->
    <!--Zero or more repetitions:-->
    <!--Optional:-->
    <!--Zero or more repetitions:-->

I appreciate any help provided.



Solution 1:[1]

I assume you are referring to the 'Zero or mor repeatitions' comments?

I have not used IntelliJ's tool, but the Eclipse XML example document generator has settings to control the output, including whether anything gets generated for optional (minOccurs="0") elements. I suggest that you look at the documentation for the IntelliJ tool to see whether it has similar settings. However...

I am trying to convert an XSD file into its corresponding XML document.

For most XSDs, especially large and complex ones, there is no such thing. Any non-trivial XSD describes a whole family of XML documents. If you are using this tool to generate unit test data then be very careful about functional coverage. You should not trust any automated tool to generate useful data for your testing - that requires an understanding of the business requirements for your project.

Solution 2:[2]

As @kimbert points out, this is happening because the xsd file allows zero occurrences of these fields, and the generator is being lazy by taking that route. The quick and dirty solution to force Intellij to generate at least one element for each of these fields is to create a copy of the xsd, and in that copy, replace all occurrences of minOccurs="0" with minOccurs="1", which is easy with Intellij's replace all in file tool. Then you can generate your xml from that new xsd and at least one entry will be created for each field.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kimbert
Solution 2 sigma1510