ballerina-platform / ballerina-spec

Ballerina Language and Platform Specifications
Other
168 stars 53 forks source link

Clarification on xml elements created via xml:createElement() #996

Open rdhananjaya opened 2 years ago

rdhananjaya commented 2 years ago

Description:

import ballerina/io;

public function main() {
    map<string> attrs = {"{http://www.w3.org/2000/xmlns/}xmlns": "url"};
    xml:Element e1 = xml:createElement("{url}Elem", attrs); 
    xml:Element e2 = xml:createElement("Elem", attrs);        

    io:println(e1); // <Elem xmlns="url"/>
    io:println(e2); // <Elem xmlns="url"/>

    io:println(e1 == e2); // Currently `false`, should this be `true`? 
}

Suggested Labels:

Code sample that shows issue:

Related Issues:

jclark commented 2 years ago

The expanded name in the created element singleton should be exactly what was specified in the first argument to createElement. So false is correct.

But I would need to think further about how serializing should deal with this (or whether this should be a runtime error, either at creation or serialization time).