xsdata icon indicating copy to clipboard operation
xsdata copied to clipboard

Preserve all repeatable choices

Open tefra opened this issue 4 years ago • 2 comments

Currently we generate compound fields only when it's absolutely necessary in order to maintain elements ordering between roundtrips. It would be nice to have an option to always group together choice elements just to be explicit with what is truly expected.

Original issue #561

Blocking issues

I have a couple of blocking cases that unfortunately I can't seem to find a proper way to tackle them

  1. repeatable sequences
  <xsd:group name="G1">
    <xsd:choice>
      <xsd:sequence>
        <xsd:element name="date" type="xsd:date"/>
        <xsd:element name="marked" type="xsd:boolean"/>
      </xsd:sequence>
      <xsd:sequence>
        <xsd:element name="num" type="xsd:int"/>
      </xsd:sequence>
    </xsd:choice>
  </xsd:group>
  1. Repeatable groups
	<xsd:complexType name="PurchaseOrderType">
		<xsd:sequence>
			<xsd:element ref="ipo:ExternFirstElement"/>
			<xsd:choice>
				<xsd:group ref="ipo:shipAndBill"/>
				<xsd:element name="singleAddress" type="ipo:AddressType"/>
			</xsd:choice>
			<xsd:element ref="ipo:comment" minOccurs="0"/>
			<xsd:element name="items" type="ipo:ItemsType"/>
		</xsd:sequence>
		<xsd:attribute name="orderDate" type="xsd:date"/>
	</xsd:complexType>

tefra avatar Jul 30 '21 21:07 tefra

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Jul 30 '21 21:07 sonarqubecloud[bot]

One approach would be to identify these cases and fallback to the original simplify case??? I 've been thinking this one for days now...

tefra avatar Jul 30 '21 21:07 tefra

This was addressed in #747

tefra avatar Feb 21 '23 17:02 tefra