ballerina-platform / ballerina-library

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

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

Closed Nuvindu closed 17 hours ago

Nuvindu commented 3 days ago

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 commented 18 hours ago

This happen because, the included records does not inherit its metadata informations. Related spec issue - https://github.com/ballerina-platform/ballerina-spec/issues/1311

So this issue should be fixed from the language repository.

SasinduDilshara commented 17 hours ago

Closed due to https://github.com/ballerina-platform/ballerina-library/issues/7403#issuecomment-2497216696

github-actions[bot] commented 17 hours ago

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.