Skip to content

parsing choice sequence loses element ordering #29

@martaver

Description

@martaver

Trying to parse an XML file with a schema that contains a choice sequence:

      <xs:choice minOccurs="1" maxOccurs="unbounded">
        <xs:element name="Title" type="xs:string" />
        <xs:element name="Subtitle" type="xs:string" />
        <xs:element name="Html" type="xs:string" />
        <xs:element name="Vimeo" type="VimeoPart" />
        <xs:element name="Youtube" type="YoutubePart" />
        <xs:element name="Soundcloud" type="SoundcloudPart" />
        <xs:element name="Image" type="ImagePart" />
        <xs:element name="Link" type="LinkPart" />
      </xs:choice>

The above generates the following in a type:

        Html: string[];
	Image: ImagePart[];
	Link: LinkPart[];
	Soundcloud: SoundcloudPart[];
	Subtitle: string[];
	Title: string[];
	Vimeo: VimeoPart[];
	Youtube: YoutubePart[];

However, this structure loses the ordering of the elements. In my case, order is important because it contains site content.

I would have expected the following types, perhaps:

choices: (Html | Image | Link | Soundcloud | Subtitle | Title | Vimeo | Youtube)[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions