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

Missing namespace information in generated XML for records with type inclusion #7403

Closed
Nuvindu opened this issue Nov 22, 2024 · 3 comments
Closed
Assignees
Labels
module/data.xmldata Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug

Comments

@Nuvindu
Copy link
Contributor

Nuvindu commented Nov 22, 2024

Description

When converting a record type annotated with @xmldata:Namespace to XML using the xmldata:toXml() function, the generated XML does not include the namespace information specified in the annotations.

Steps to Reproduce

  1. Run the following sample code
import ballerina/data.xmldata;
import ballerina/io;

@xmldata:Namespace {prefix: "soap", uri: "http://www.w3.org/2003/05/soap-envelope"}
public type Envelope record {
    *Body;
};

@xmldata:Namespace {prefix: "xs2", uri: "http://www.w3.org/2001/XMLSchema2"}
public type Body record {
    @xmldata:Namespace {prefix: "xs1", uri: "http://www.w3.org/2001/XMLSchema1"}
    string value;
};

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

Result:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><value>this is a string</value></soap:Envelope>

Expected Result:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><value xmlns:xs1="http://www.w3.org/2001/XMLSchema1">this is a string</value></soap:Envelope>

Version

2201.10.2

Environment Details (with versions)

No response

@SasinduDilshara
Copy link
Contributor

This happen because, the included records does not inherit its metadata informations.
Related spec issue - ballerina-platform/ballerina-spec#1311

So this issue should be fixed from the language repository.

@SasinduDilshara
Copy link
Contributor

Closed due to #7403 (comment)

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@SasinduDilshara SasinduDilshara self-assigned this Nov 25, 2024
@SasinduDilshara SasinduDilshara added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/data.xmldata Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Archived in project
Development

No branches or pull requests

2 participants