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

Support new options in xml conversion #42440

Merged
merged 13 commits into from
Apr 5, 2024

Conversation

mindula
Copy link
Contributor

@mindula mindula commented Mar 30, 2024

Purpose

$title.

Fixes #42385

Approach

Describe how you are implementing the solutions along with the design details.

Samples

Provide high-level details about the samples related to this feature.

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@mindula mindula requested a review from hevayo as a code owner March 30, 2024 16:45
@CLAassistant
Copy link

CLAassistant commented Mar 30, 2024

CLA assistant check
All committers have signed the CLA.

@mindula mindula requested a review from hasithaa April 1, 2024 05:04
@prakanth97
Copy link
Contributor

Build failed due to the checkstyle failure, can you take a look?

@prakanth97
Copy link
Contributor

prakanth97 commented Apr 1, 2024

This PR did not include tests. Right? Shall we add considerable amount of tests for the changes.

@mindula mindula marked this pull request as ready for review April 2, 2024 08:36
@hasithaa
Copy link
Contributor

hasithaa commented Apr 2, 2024

@prakanth97 @mindula Do we need a config for explicitly adding attributes? I guess, currently we add the annotation by default. But runtime logic doesn't depend on this annotation. So someone can decide to omit it. Having a way to configure the behavior useful. But this can later.

@mindula
Copy link
Contributor Author

mindula commented Apr 2, 2024

@prakanth97 @mindula Do we need a config for explicitly adding attributes? I guess, currently we add the annotation by default. But runtime logic doesn't depend on this annotation. So someone can decide to omit it. Having a way to configure the behavior useful. But this can later.

Are you suggesting to add another configuration option to include attributes or not?

example:

<book>
    <title lang="en">string</title>
</book>

Without attributes

@xmldata:Name {value: "book"}
type Book record {
    string title;
};

With attributes

type Title record {
    string \#content;
    @xmldata:Attribute
    string lang;
};

@xmldata:Name {value: "book"}
type Book record {
    Title title;
};

Copy link

codecov bot commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 76.74%. Comparing base (1874440) to head (8a3614e).
Report is 278 commits behind head on master.

Files Patch % Lines
...ina/xmltorecordconverter/XMLToRecordConverter.java 92.30% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #42440       +/-   ##
=============================================
+ Coverage      0.00%   76.74%   +76.74%     
- Complexity        0    53828    +53828     
=============================================
  Files             9     2913     +2904     
  Lines            35   203404   +203369     
  Branches          0    26525    +26525     
=============================================
+ Hits              0   156107   +156107     
- Misses           35    38764    +38729     
- Partials          0     8533     +8533     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mindula mindula requested review from prakanth97 and nipunayf April 3, 2024 04:10
@prakanth97
Copy link
Contributor

<book xmlns="http://example.com/book">
    <id>601970</id>
    <title>string</title>
    <author>string</author>
</book>

the name space is applied to all the elements and the attribute in the child of book and element book as well.

Hence the expected record should be

@xmldata:Namespace {uri: "http://example.com/book"}
@xmldata:Name {value: "book"}
type Book record {
    @xmldata:Namespace {uri: "http://example.com/book"}
    int id;
    @xmldata:Namespace {uri: "http://example.com/book"}
    string title;
    @xmldata:Namespace {uri: "http://example.com/book"}
    string author;
};

But what we generate at the moment is

@xmldata:Name {value: "book"}
type Book record {
    int id;
    string title;
    string author;
    @xmldata:Attribute
    string 'xmlns;
};

This seems wrong.

@hasithaa hasithaa added this to the 2201.9.0 milestone Apr 4, 2024
@mindula mindula requested a review from prakanth97 April 4, 2024 11:41
string xmlns\:xsi = "http://www.w3.org/2001/XMLSchema-instance";
@xmldata:Attribute
string xsi\:nil;
string nil;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did not add the namespace annotation here, seems wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a example where we have namespace for the attribute?

@prakanth97
Copy link
Contributor

prakanth97 commented Apr 4, 2024

Shall we add few tests for disabling namespace?

Copy link
Contributor

@prakanth97 prakanth97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LakshanWeerasinghe LakshanWeerasinghe merged commit c4cd054 into ballerina-platform:master Apr 5, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Support new options in XML conversions
8 participants