Skip to content

Get invalid error for array fields in Sequence Groups #8663

@Nuvindu

Description

@Nuvindu

Area

Area/Library

Description

In the data.xmldata module, when a field inside a @xmldata:SequenceGroup is typed as an array (for example, RecordValue[]), parsing XML values with parseAsType produces a false-positive error:

'RecordValue' occurs more than the maximum allowed number of times in 'sequenceGroup'.

Steps to Reproduce

Run the following sample

import ballerina/data.xmldata;

public type DataType record {|
    @Sequence {minOccurs: 0, maxOccurs: 1}
    SequenceGroup sequenceGroup;
|};

public type SequenceGroup record {|
    @SequenceOrder {value: 1}
    RecordValue[] RecordValue;      // array — should allow multiple occurrences

    @SequenceOrder {value: 2}
    Extensions Extensions;
|};

xml data = xml `<DataType>
    <RecordValue>...</RecordValue>
    <RecordValue>...</RecordValue>
    <Extensions>...</Extensions>
</DataType>`;

public function main() returns error? {
       DataType result = check xmldata:parseAsType(data); // error thrown
}

Current behaviour: An error is thrown after the second element.

Expected behaviour: Parsing should succeed, collecting all elements into the RecordValue[] array.

Version

1.6.0

Environment Details (with versions)

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions