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

[Bug]: Incomplete error message on xml:fromString method #41668

Closed
SasinduDilshara opened this issue Nov 9, 2023 · 2 comments
Closed

[Bug]: Incomplete error message on xml:fromString method #41668

SasinduDilshara opened this issue Nov 9, 2023 · 2 comments
Assignees
Labels
Reason/Invalid Issue is invalid. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug userCategory/Compilation

Comments

@SasinduDilshara
Copy link
Contributor

Description

import ballerina/io;
public function main() {
    string a = string `
        <?xml version='1.0' encoding='UTF-8'?>
            <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
            xmlns:tns="http://www.example.com/">;
                <soap:Body>
            <tns:receive.cdiResponse>
            <Response>
            <Code>1000</Code>
            <Description><![CDATA[OK]]></Description>
            </Response>
            </tns:receive.cdiResponse>
                </soap:Body>
            </soap:Envelope>
        `;
    
    xml|error fromString = xml:fromString(a);
    io:println(fromString);
}

in here the program outputs,

error("failed to parse xml: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
 at [row,col {unknown-source}]: [2,13]")

This error message is not clear for the user. It is better to have a meaningful error message.

Affected version - 2201.8.0

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Nov 9, 2023
@MaryamZi MaryamZi added Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime and removed needTriage The issue has to be inspected and labeled manually labels Nov 13, 2023
@Nadeeshan96 Nadeeshan96 self-assigned this Nov 23, 2023
@Nadeeshan96 Nadeeshan96 moved this from BackLog to In Progress in Ballerina Team Main Board Nov 23, 2023
@Nadeeshan96
Copy link
Contributor

Here the error message is clear and correct. According to ballerina-platform/ballerina-spec#1225 (comment), we do not allow "xml" as a processing instruction target when parsing xml strings. Hence we cannot include the xml declaration also. If we change the processing instruction target to another value, say abc, it works without any problem.

@warunalakshitha
Copy link
Contributor

As per above comment I am closing the issue. Please reopen if you have further queries on this.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Ballerina Team Main Board Nov 23, 2023
@warunalakshitha warunalakshitha added the Reason/Invalid Issue is invalid. label Nov 23, 2023
@ballerina-platform ballerina-platform deleted a comment from github-actions bot Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason/Invalid Issue is invalid. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug userCategory/Compilation
Projects
Archived in project
Development

No branches or pull requests

5 participants