ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Incorrect error message for nested record types in `data.xmldata` module #7310

Open SasinduDilshara opened 3 weeks ago

SasinduDilshara commented 3 weeks ago

Description

Code

import ballerina/data.xmldata;
import ballerina/io;

public function main() {
    string xmlValue = string `
        <User>
            <id>1</id>
            <age>23</age>
            <nestedXml>
                <id>1</id>
                <age>23</age>
            </nestedXml>
        </User>`;

    record {
        int id;
        int age; 
        record {
            int id; 
            int age;
        } nestedXml;
    }|xmldata:Error user = xmldata:parseString(xmlValue);

    io:println(user);
}

The above code gives error Error ("required field 'age' not present in XML"). This error message incorrect since, is present in the XML.

This issue happens since outer and inner element both have same element name <age>.

Steps to Reproduce

$Description

Version

2201.10.2

Environment Details (with versions)

No response