ballerina-platform / ballerina-library

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

Namespace informations not preserved for`nested records` in toXml function in data.xmldata module #7390

Open SasinduDilshara opened 1 day ago

SasinduDilshara commented 1 day ago

Description

import ballerina/data.xmldata;
import ballerina/io;
public function main() {
    record {
        record {
            @xmldata:Namespace {
                uri: "http://example3.com/",
                prefix: "c"        
            }
            string c;

            @xmldata:Namespace {
                uri: "http://example1.com/",
                prefix: "a"        
            }
            string a;

            @xmldata:Namespace {
                uri: "http://example3.com/",
                prefix: "b"        
            }
            string b;
        } name;
    } a = {name: {b: "B", a: "A", c: "C"}};
    xml|xmldata:Error xmlResult = xmldata:toXml(a);
    io:println(xmlResult);
}

The above code provides following invalid results

<name><c>C</c><a>A</a><b>B</b></name>

The result doesn't contains any namespace informations

Steps to Reproduce

$Description

Version

2201.10.2

Environment Details (with versions)

No response