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 XML Structure When Converting Record with Type Inclusion to XML #6704

Open AzeemMuzammil opened 4 months ago

AzeemMuzammil commented 4 months ago

Description: When converting a record object to XML, attributes from included types are incorrectly treated as nested elements rather than attributes. This issue occurs specifically when the record uses type inclusion to inherit attributes, which should be rendered as XML attributes, not child elements. Below are the examples demonstrating the expected and the actual XML output for clarity:

type Child record {
    string childField;
    @xmldata:Attribute
    string childAttr?;
    *Parent;
};

type Parent record {
    @xmldata:Attribute
    string parentAttr?;
};

Generated

<Child childAttr="ChildAttr">
    <childField>ChildField</childField>
    <parentAttr>ParentAttr</parentAttr>
</Child>

Expected

<Child childAttr="ChildAttr" parentAttr="ParentAttr">
    <childField>ChildField</childField>
</Child>

Steps to reproduce:

Affected Versions: 2201.9.2-test-pack

OS, DB, other environment details and versions:

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

prakanth97 commented 4 months ago

Due to #38535