atviriduomenys / spinta

Spinta is a framework to describe, extract and publish data (a DEP Framework).
MIT License
10 stars 4 forks source link

XSD choice with maxOccurs=unbounded #610

Closed sirex closed 3 weeks ago

sirex commented 1 month ago

When we have XSD like this:

<choice maxOccurs="unbounded">
  <element name="a" />
  <element name="b" />
</choice>

This means, that there can be any number of a and b elements, basically this is the same as:

<element name="a" minOccurs="0"  maxOccurs="unbounded" />
<element name="b"  minOccurs="0"  maxOccurs="unbounded" />

Currently Spinta generate multiple options for each choice, but in this case, since maxOccurs="unbounded", choice itself can be repeated multiple times, with either a or b, which in the end means, that either a or b can appear multiple times in any order.

We should interpret these elements as optional.

If maxOccurs="1", for example:

<choice maxOccurs="1">
  <element name="a" />
  <element name="b" />
</choice>

Then we can generate multiple models with either a or b.

karina-klinkeviciute commented 1 month ago

done as a part of #160