Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<xs:choice maxOccurs="unbounded"> does not produce array type #687

Open
marpetr opened this issue Jun 17, 2024 · 3 comments
Open

<xs:choice maxOccurs="unbounded"> does not produce array type #687

marpetr opened this issue Jun 17, 2024 · 3 comments

Comments

@marpetr
Copy link

marpetr commented Jun 17, 2024

Example input:

	<xs:complexType name="Fruits">
		<xs:choice maxOccurs="unbounded">
			<xs:element name="apple" type="js:Apple"/>
			<xs:element name="orange" type="js:Orange"/>
		</xs:choice>
	</xs:complexType>

Expected output: fruits: struct<apple: array<struct<...>>, orange: array<struct<...>>>

Actual output: fruits: struct<apple: struct<...>, orange: struct<...>>

Proposed fix:

-               if (element.getMaxOccurs == 1) {
+               if (element.getMaxOccurs == 1 && choice.getMaxOccurs == 1) {
@srowen
Copy link
Collaborator

srowen commented Jun 17, 2024

I think it would be fine to support this. I think the change is somewhat different though.

If an xs:element within the xs:choice has maxOccurs > 1, then that choice is an array type. That much works now.

If xs:choice has maxOccurs > 1, then the result isn't a struct, but an array of struct.
The resulting Seq of StructField would have to be wrapped up in another ArrayType in this case to express this, I think.

If you can try that and it works would you open a pull request to test?

@ranadheerg
Copy link

@marpetr @srowen can I take over this issue ? I would like to work on this if possible ?

@srowen
Copy link
Collaborator

srowen commented Jul 26, 2024

Sure, you can open a pull request if you like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants