Issue with sequence with choice
Hello,
I noticed an issue with the generated classes. From this sequence
<xs:sequence>
<xs:group ref="ipxact:nameGroup"/>
<xs:element ref="ipxact:activeInterface"/>
<xs:choice>
<xs:sequence>
<xs:element ref="ipxact:activeInterface" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="hierInterface" type="ipxact:hierInterfaceType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:element name="hierInterface" type="ipxact:hierInterfaceType" maxOccurs="unbounded"/>
</xs:choice>
<xs:element ref="ipxact:vendorExtensions" minOccurs="0"/>
</xs:sequence>
It generates this:
active_interface: list[ActiveInterface] = field(
default_factory=list,
metadata={
"name": "activeInterface",
"type": "Element",
"min_occurs": 2,
"sequence": 1,
},
)
hier_interface: list[HierInterfaceType] = field(
default_factory=list,
metadata={
"name": "hierInterface",
"type": "Element",
"min_occurs": 1,
"sequence": 1,
},
)
Problem is the sequence value is 1 for both ActiveInterface and HierInterfaceType.
This makes it so that serialized data becomes interleaved if the active_interface is a list of multiple elements.
Basically I get this:
<ipxact:interconnection>
<ipxact:name>intc_3805385578664854469</ipxact:name>
<ipxact:activeInterface componentInstanceRef="i_gpio" busRef="IPReset"/>
<ipxact:hierInterface busRef="rst"/>
<ipxact:activeInterface componentInstanceRef="i_timer" busRef="APBReset"/>
</ipxact:interconnection>
And this does not validate against the schema as it is expected to be like this:
<ipxact:interconnection>
<ipxact:name>intc_3805385578664854469</ipxact:name>
<ipxact:activeInterface componentInstanceRef="i_gpio" busRef="IPReset"/>
<ipxact:activeInterface componentInstanceRef="i_timer" busRef="APBReset"/>
<ipxact:hierInterface busRef="rst"/>
</ipxact:interconnection>
For repeating choices or complex sequence elements give the compound fields a try.
It seems to me with --compound-fields or --no-compound-fields the generation of this class remain the same.
Yes, I confirm that this issue does not get fixed by using --compound-fields. Currently I manually fix the issue as luckily this construct does not appear often. Could the tool at least issue a warning in such cases, or is it difficult to even detect this?