Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect XML conversion for the record types with single \#content field #7423

Open
Nuvindu opened this issue Nov 29, 2024 · 0 comments
Open

Comments

@Nuvindu
Copy link
Contributor

Nuvindu commented Nov 29, 2024

Description

Consider this record type.

public type Data record {
    string \#content;
};

When trying to convert a record value from this type to an XML value, it only produces an incorrect value.

The output: this is a string
The expected output: <Data>this is a string</Data>

When using an additional attribute it will correctly prints the xml output.

public type Data record {
    string \#content;
    @xmldata:Attribute
    int number;
};

The output: <Data number="1">this is a string</Data>

Steps to Reproduce

Run the following code in a single Ballerina file.

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

public type Data record {
    string \#content;
};

public function main() returns error? {
    Data document = {
        \#content: "this is a string"
    };
    xml xmlDocument = check xmldata:toXml(document);
    io:println(xmlDocument);
}

Version

2201.10.0

Environment Details (with versions)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant