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

[Improvement]: Handle intersecting and differencing fields of the XML nodes with same name #41310

Closed
AzeemMuzammil opened this issue Aug 29, 2023 · 2 comments
Assignees
Labels
Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Improvement
Milestone

Comments

@AzeemMuzammil
Copy link
Member

Description

When there are two XML nodes with the same name present, those two nodes should be converted into one Ballerina record, and the intersecting and differencing fields in those nodes should also be handled as below,

<catalog>
    <book id="bk102">
        <author>Gambardella, Matthew</author>
        <title>XML Developer's Guide</title>
        <price>44.95</price>
        <description>Really good book for developers</description>
    </book>
    <book id="bk102">
        <author>Ralls, Kim</author>
        <title>Midnight Rain</title>
        <price>5.95</price>
    </book>
</catalog>

For this XML, Ballerina Record should look like,

type Book record {
    string author;
    string title;
    decimal price;
    string description?;
    @xmldata:Attribute
    string id;
};

@xmldata:Name {
    value: "catalog"
}
type Catalog record {
    Book[] book;
};

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Other Area

Related issue(s) (optional)

#41180

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@AzeemMuzammil AzeemMuzammil self-assigned this Aug 29, 2023
@AzeemMuzammil AzeemMuzammil added the Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) label Aug 29, 2023
@ballerina-bot ballerina-bot added the needTriage The issue has to be inspected and labeled manually label Aug 29, 2023
@AzeemMuzammil AzeemMuzammil removed the needTriage The issue has to be inspected and labeled manually label Aug 29, 2023
@aneeshafedo aneeshafedo moved this from In Progress to On Hold in Ballerina Team Main Board Sep 21, 2023
@NipunaRanasinghe NipunaRanasinghe moved this from On Hold to In Progress in Ballerina Team Main Board Oct 12, 2023
@ayeshLK ayeshLK moved this from In Progress to Planned for Sprint in Ballerina Team Main Board Oct 19, 2023
@KavinduZoysa
Copy link
Contributor

             <ZASN_SDTX SEGMENT="1">
                <TDID>ZCA8</TDID>
                <TDSPRAS>E</TDSPRAS>
                <ZASN_SDTXP SEGMENT="1">
                   <TDLINE>GS~012430880~925159POHC</TDLINE>
                </ZASN_SDTXP>
             </ZASN_SDTX>
             <ZASN_SDTX SEGMENT="1">
                <TDID>ZEDH</TDID>
                <TDSPRAS>E</TDSPRAS>
                <ZASN_SDTXP SEGMENT="1">
                   <TDFORMAT>/</TDFORMAT>
                   <TDLINE>X12-LIFNR-WE=ST~9~0124308800009</TDLINE>
                </ZASN_SDTXP>
                <ZASN_SDTXP SEGMENT="1">
                   <TDFORMAT>/</TDFORMAT>
                   <TDLINE>X12-LIFNR-ST=ST~9~0124308800009~8691 JESSIE B SMITH</TDLINE>
                </ZASN_SDTXP>
             </ZASN_SDTX>

Please check the above xml. Created record containing a field for ZASN_SDTXP but should be an array of ZASN_SDTXP.

@KavinduZoysa
Copy link
Contributor

KavinduZoysa commented Oct 30, 2023

Please consider following case.

<Rec2>
    <Rec1>
        <i>144</i>
        <s>s1</s>
        <!-- <Rec1>
            <i>144</i>
            <s>s1</s>
        </Rec1>     -->
        <Rec1>
            <i>144</i>
            <s>s1</s>
            <Rec1>
                <i>144</i>
                <s>s1</s>
                <Rec1>
                    <i>144</i>
                    <s>s1</s>
                </Rec1>    
                <Rec1>
                    <i>144</i>
                    <s>s1</s>
                </Rec1>
            </Rec1>        
        </Rec1>
    </Rec1>
</Rec2>

This xml generates the records as follows.

type Rec1 record {
    int i;
    string s;
    Rec1 Rec1;
};

type Rec2 record {
    Rec1 Rec1;
};

IMO there are two issues here.

  1. Rec1 should be an array.
  2. Rec1 should be an optional field.

If you uncomment the commented lines, the array will be generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Improvement
Projects
Archived in project
Development

No branches or pull requests

4 participants